1. svn -> git

This commit is contained in:
2017-04-12 01:23:07 +09:00
commit daaaf2997b
406 changed files with 68990 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
using UnityEngine;
using UnityEditor;
[CanEditMultipleObjects]
[CustomEditor(typeof(D2D_Anchor))]
public class D2D_Anchor_Editor : D2D_Editor<D2D_Anchor>
{
protected override void OnInspector()
{
DrawDefault("Radius");
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 86957fea163f95e48aa5258ea8b9d704
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@@ -0,0 +1,12 @@
using UnityEngine;
using UnityEditor;
[CanEditMultipleObjects]
[CustomEditor(typeof(D2D_AutoPolygonCollider))]
public class D2D_AutoPolygonCollider_Editor : D2D_Collider_Editor<D2D_AutoPolygonCollider>
{
protected override void OnInspector()
{
base.OnInspector();
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 36ed20a27ed98c445add19717f9592a5
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@@ -0,0 +1,52 @@
using UnityEngine;
using UnityEditor;
[CanEditMultipleObjects]
[CustomEditor(typeof(D2D_Breakable))]
public class D2D_Breakable_Editor : D2D_Editor<D2D_Breakable>
{
protected override void OnInspector()
{
if (Any(t => t.GetComponent<D2D_DestructibleSprite>().AllowSplit == false))
{
if (HelpButton("Breakable sprites require Allow Split", MessageType.Error, "Set Allow Split", 50.0f) == true)
{
Each(t => t.GetComponent<D2D_DestructibleSprite>().AllowSplit = true);
}
}
if (Any(t => t.GetComponent<Rigidbody2D>().isKinematic == false))
{
if (HelpButton("Breakable sprites require Is Kinematic", MessageType.Error, "Set Is Kinematic", 50.0f) == true)
{
Each(t => t.GetComponent<Rigidbody2D>().isKinematic = true);
}
}
DrawDefault("ChangeColliderType");
if (Any(t => t.ChangeColliderType == true))
{
DrawDefault("NewColliderType");
if (Any(t => t.NewColliderType == D2D_SpriteColliderType.Edge))
{
if (HelpButton("Dynamic edge colliders may not work well", MessageType.Warning, "Change", 50.0f) == true)
{
Each(t => {if (t.NewColliderType == D2D_SpriteColliderType.Edge) t.NewColliderType = D2D_SpriteColliderType.AutoPolygon; });
}
}
if (Any(t => t.NewColliderType == t.GetComponent<D2D_DestructibleSprite>().ColliderType))
{
EditorGUILayout.HelpBox("This is the same Collider Type as the source.", MessageType.Warning);
}
}
BeginError(Any(t => t.Anchors.Count == 0));
{
DrawDefault("Anchors");
}
EndError();
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3b7b26c214aacad41b43412fc62d9828
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@@ -0,0 +1,55 @@
using UnityEngine;
using UnityEditor;
public abstract class D2D_Collider_Editor<T> : D2D_Editor<T>
where T : D2D_Collider
{
private static bool hide;
protected override void OnInspector()
{
DrawHide();
DrawDefault("IsTrigger");
DrawDefault("Material");
foreach (var t in Targets)
{
t.UpdateColliderSettings();
t.SetHideFlags(hide);
}
EditorGUILayout.Separator();
}
protected void BeginChangeCheck()
{
EditorGUI.BeginChangeCheck();
}
protected void EndChangeCheck()
{
if (EditorGUI.EndChangeCheck() == true)
{
foreach (var t in Targets)
{
if (t != null)
{
t.MarkAsDirty();
}
}
}
}
private void DrawHide()
{
var position = D2D_Helper.Reserve();
if (D2D_Helper.BaseRectSet == true)
{
position.x = D2D_Helper.BaseRect.x;
position.width = D2D_Helper.BaseRect.width;
}
hide = EditorGUI.Toggle(position, "Hide", hide);
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b443d662ea688434b9e17d1d8e6f1456
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@@ -0,0 +1,26 @@
using UnityEngine;
using UnityEditor;
[CanEditMultipleObjects]
[CustomEditor(typeof(D2D_DamageableSprite))]
public class D2D_DamageableSprite_Editor : D2D_Editor<D2D_DamageableSprite>
{
protected override void OnInspector()
{
DrawDefault("Damage");
EditorGUILayout.Separator();
DrawDefault("AllowDestruction");
if (Any(t => t.AllowDestruction == true))
{
DrawDefault("DamageLimit");
DrawDefault("ReplaceWith");
}
EditorGUILayout.Separator();
DrawDefault("DamageLevels");
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: be46c5e59ac012d4cb2d95c64da82a8d
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@@ -0,0 +1,90 @@
using UnityEngine;
using UnityEditor;
[CanEditMultipleObjects]
[CustomEditor(typeof(D2D_DestructibleSprite))]
public class D2D_DestructibleSprite_Editor : D2D_Editor<D2D_DestructibleSprite>
{
protected override void OnInspector()
{
DrawAlphaTex();
DrawDefault("DensityTex");
BeginError(Any(t => t.SourceMaterial == null));
{
DrawDefault("SourceMaterial");
}
EndError();
if (Any(t => t.SourceMaterial != null && AssetDatabase.Contains(t.SourceMaterial) == false))
{
EditorGUILayout.HelpBox("This material isn't an asset, so you won't be able to store this Destructible Sprite in a prefab.", MessageType.Warning);
}
if (Any(t => t.SourceMaterial != null && t.SourceMaterial.HasProperty("_AlphaTex") == false))
{
EditorGUILayout.HelpBox("This material lacks the _AlphaTex property, so it will not render correctly.", MessageType.Error);
}
DrawDefault("Sharpness");
EditorGUILayout.Separator();
DrawDefault("ColliderType");
if (Any(t => t.ColliderType == D2D_SpriteColliderType.AutoPolygon && t.AlphaTex != null && t.AlphaTex.width * t.AlphaTex.height > 400 * 400))
{
if (HelpButton("Your Alpha Tex is quite large, and it may run slowly with this Collider Type. Consider lowering its resolution.", MessageType.Warning, "Halve Alpha Tex", 50.0f) == true)
{
Each(t => t.HalveAlphaTex());
}
}
EditorGUILayout.Separator();
DrawDefault("AllowSplit");
if (Any(t => t.AllowSplit == true && t.AlphaTex != null && t.AlphaTex.width * t.AlphaTex.height > 400 * 400))
{
if (HelpButton("Your Alpha Tex is quite large, and it may run slowly with Allow Split. Consider lowering its resolution.", MessageType.Warning, "Halve Alpha Tex", 50.0f) == true)
{
Each(t => t.HalveAlphaTex());
}
}
if (Any(t => t.AllowSplit == true))
{
DrawDefault("SplitMinPixels");
DrawDefault("SplitThreshold");
DrawDefault("SplitOrder");
}
if (Targets.Length == 1 && AssetDatabase.Contains(Target) == false)
{
EditorGUILayout.Separator();
EditorGUI.BeginDisabledGroup(true);
{
EditorGUILayout.IntField("Solid Pixel Count", Target.SolidPixelCount);
EditorGUILayout.IntField("Original Solid Pixel Count", Target.OriginalSolidPixelCount);
EditorGUILayout.Slider("Solid Pixel Ratio", Target.SolidPixelRatio, 0.0f, 1.0f);
}
EditorGUI.EndDisabledGroup();
}
}
private void DrawAlphaTex()
{
var newAlphaTex = (Texture2D)EditorGUI.ObjectField(D2D_Helper.Reserve(), "Alpha Tex", Target.AlphaTex, typeof(Texture2D), false);
if (newAlphaTex != Target.AlphaTex)
{
D2D_Helper.Record(Targets, "Replace Destructible Sprite Alpha");
foreach (var t in Targets)
{
t.ReplaceAlphaWith(newAlphaTex); t.RecalculateOriginalSolidPixelCount(); D2D_Helper.SetDirty(t);
}
}
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c466f1ced95651f40819391968a6cd22
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@@ -0,0 +1,12 @@
using UnityEngine;
using UnityEditor;
[CanEditMultipleObjects]
[CustomEditor(typeof(D2D_DynamicMass))]
public class D2D_DynamicMass_Editor : D2D_Editor<D2D_DynamicMass>
{
protected override void OnInspector()
{
DrawDefault("MassPerPixel");
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 971a59b36bd50894ab5197ed429afc3b
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@@ -0,0 +1,21 @@
using UnityEngine;
using UnityEditor;
[CanEditMultipleObjects]
[CustomEditor(typeof(D2D_EdgeColliders))]
public class D2D_EdgeColliders_Editor : D2D_Collider_Editor<D2D_EdgeColliders>
{
private static bool hideColliders;
protected override void OnInspector()
{
base.OnInspector();
BeginChangeCheck();
{
DrawDefault("CellSize");
DrawDefault("Tolerance");
}
EndChangeCheck();
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: dc588e4e2ce390b4eab278efa7470f5e
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@@ -0,0 +1,141 @@
using UnityEngine;
using UnityEditor;
using System.Linq;
public abstract class D2D_Editor<T> : Editor
where T : MonoBehaviour
{
protected T Target;
protected T[] Targets;
public override void OnInspectorGUI()
{
D2D_Helper.BaseRect = D2D_Helper.Reserve(0.0f);
D2D_Helper.BaseRectSet = true;
EditorGUI.BeginChangeCheck();
serializedObject.UpdateIfDirtyOrScript();
Target = (T)target;
Targets = targets.Select(t => (T)t).ToArray();
EditorGUILayout.Separator();
OnInspector();
EditorGUILayout.Separator();
serializedObject.ApplyModifiedProperties();
if (EditorGUI.EndChangeCheck() == true)
{
GUI.changed = true; Repaint();
foreach (var t in Targets)
{
D2D_Helper.SetDirty(t);
}
}
D2D_Helper.BaseRectSet = false;
}
public virtual void OnSceneGUI()
{
Target = (T)target;
OnScene();
if (GUI.changed == true)
{
D2D_Helper.SetDirty(target);
}
}
protected void Each(System.Action<T> update)
{
foreach (var t in Targets)
{
update(t);
}
}
protected bool Any(System.Func<T, bool> check)
{
foreach (var t in Targets)
{
if (check(t) == true)
{
return true;
}
}
return false;
}
protected bool All(System.Func<T, bool> check)
{
foreach (var t in Targets)
{
if (check(t) == false)
{
return false;
}
}
return true;
}
protected bool Button(string text)
{
var rect = D2D_Helper.Reserve();
return GUI.Button(rect, text);
}
protected bool HelpButton(string helpText, UnityEditor.MessageType type, string buttonText, float buttonWidth)
{
var clicked = false;
EditorGUILayout.BeginHorizontal();
{
EditorGUILayout.HelpBox(helpText, type);
var style = new GUIStyle(GUI.skin.button); style.wordWrap = true;
clicked = GUILayout.Button(buttonText, style, GUILayout.ExpandHeight(true), GUILayout.Width(buttonWidth));
}
EditorGUILayout.EndHorizontal();
return clicked;
}
protected void BeginError(bool error = true)
{
EditorGUILayout.BeginVertical(error == true ? D2D_Helper.Error : D2D_Helper.NoError);
}
protected void EndError()
{
EditorGUILayout.EndVertical();
}
protected void DrawDefault(string proeprtyPath)
{
EditorGUILayout.BeginVertical(D2D_Helper.NoError);
{
EditorGUILayout.PropertyField(serializedObject.FindProperty(proeprtyPath), true);
}
EditorGUILayout.EndVertical();
}
protected virtual void OnInspector()
{
}
protected virtual void OnScene()
{
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: dca63b284a7b1ee4f8fbe4edc4d10b49
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@@ -0,0 +1,19 @@
using UnityEngine;
using UnityEditor;
[CanEditMultipleObjects]
[CustomEditor(typeof(D2D_ExplosionForce))]
public class D2D_ExplosionForce_Editor : D2D_Editor<D2D_ExplosionForce>
{
protected override void OnInspector()
{
DrawDefault("Layers");
DrawDefault("Radius");
DrawDefault("Force");
DrawDefault("Samples");
EditorGUILayout.Separator();
DrawDefault("HasExploded");
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fe7add65c216c6c4399e6d3e58403285
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@@ -0,0 +1,21 @@
using UnityEngine;
using UnityEditor;
[CanEditMultipleObjects]
[CustomEditor(typeof(D2D_ExplosionStamp))]
public class D2D_ExplosionStamp_Editor : D2D_Editor<D2D_ExplosionStamp>
{
protected override void OnInspector()
{
DrawDefault("Layers");
DrawDefault("StampTex");
DrawDefault("Hardness");
DrawDefault("Size");
DrawDefault("AngleOffset");
DrawDefault("AngleRandomness");
EditorGUILayout.Separator();
DrawDefault("HasExploded");
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 26e615c1ebb07f141a540f956b424657
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@@ -0,0 +1,19 @@
using UnityEngine;
using UnityEditor;
[CanEditMultipleObjects]
[CustomEditor(typeof(D2D_Fixture))]
public class D2D_Fixture_Editor : D2D_Editor<D2D_Fixture>
{
protected override void OnInspector()
{
if (Any(t => D2D_Helper.GetComponentUpwards<D2D_DestructibleSprite>(t.transform) == null))
{
EditorGUILayout.HelpBox("A parent of this GameObject should have the D2D_DestructibleSprite component", MessageType.Error);
}
else
{
EditorGUILayout.HelpBox("This GameObject will get destroyed when the fixture point is removed.", MessageType.Info);
}
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 629bcc221d923574e85dda07e518b213
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@@ -0,0 +1,21 @@
using UnityEngine;
using UnityEditor;
[CanEditMultipleObjects]
[CustomEditor(typeof(D2D_PolygonColliders))]
public class D2D_PolygonColliders_Editor : D2D_Collider_Editor<D2D_PolygonColliders>
{
private static bool hideColliders;
protected override void OnInspector()
{
base.OnInspector();
BeginChangeCheck();
{
DrawDefault("CellSize");
DrawDefault("Tolerance");
}
EndChangeCheck();
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2b2b6e48f46b12348a8bed882d67e93c
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@@ -0,0 +1,12 @@
using UnityEngine;
using UnityEditor;
[CanEditMultipleObjects]
[CustomEditor(typeof(D2D_RuntimeSprite))]
public class D2D_RuntimeSprite_Editor : D2D_Editor<D2D_RuntimeSprite>
{
protected override void OnInspector()
{
EditorGUILayout.HelpBox("This component will clean up the runtime generated Sprite used to make this GameObject.", MessageType.Info);
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: dcefc71840b1c414ea79d9c96e4d8b62
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData: