public override void OnInspectorGUI() { D2dHelper.BaseRect = D2dHelper.Reserve(0.0f); D2dHelper.BaseRectSet = true; EditorGUI.BeginChangeCheck(); serializedObject.UpdateIfDirtyOrScript(); Target = (T)target; Targets = targets.Select(t => (T)t).ToArray(); Separator(); OnInspector(); Separator(); serializedObject.ApplyModifiedProperties(); if (EditorGUI.EndChangeCheck() == true) { GUI.changed = true; Repaint(); foreach (var t in Targets) { D2dHelper.SetDirty(t); } } D2dHelper.BaseRectSet = false; }
protected override void OnInspector() { showUnused = EditorGUI.Foldout(D2dHelper.Reserve(), showUnused, "Show Unused"); DrawFloat("Damage Min", ref Target.UseDamageMin, ref Target.DamageMin); DrawFloat("Damage Max", ref Target.UseDamageMax, ref Target.DamageMax); DrawFloat("Alpha Count Min", ref Target.UseAlphaCountMin, ref Target.AlphaCountMin); DrawFloat("Alpha Count Max", ref Target.UseAlphaCountMax, ref Target.AlphaCountMax); DrawFloat("Remaining Alpha Min", ref Target.UseRemainingAlphaMin, ref Target.RemainingAlphaMin); DrawFloat("Remaining Alpha Max", ref Target.UseRemainingAlphaMax, ref Target.RemainingAlphaMax); EditorGUILayout.Separator(); showEvents = EditorGUI.Foldout(D2dHelper.Reserve(), showEvents, "Show Events"); if (showEvents == true) { DrawDefault("OnRequirementMet"); } }
protected override void OnInspector() { DrawDefault("DebugCollisions"); Separator(); DrawDefault("UseFirstOnly"); DrawDefault("ImpactMask"); DrawDefault("ImpactThreshold"); BeginError(Any(t => t.ImpactDelay < 0.0f)); DrawDefault("ImpactDelay"); EndError(); Separator(); DrawDefault("DamageOnImpact"); if (Any(t => t.DamageOnImpact == true)) { BeginIndent(); DrawDefault("DamageDestructible"); DrawDefault("DamageScale"); EndIndent(); } Separator(); showEvents = EditorGUI.Foldout(D2dHelper.Reserve(), showEvents, "Events"); if (showEvents == true) { DrawDefault("OnImpact"); } }
private void DrawDamage() { BeginMixed(Any(t => t.Damage != Target.Damage)); { var newDamage = EditorGUI.FloatField(D2dHelper.Reserve(), "Damage", Target.Damage); if (newDamage != Target.Damage) { Each(t => { t.Damage = newDamage; D2dHelper.SetDirty(t); }); } } EndMixed(); }
private void DrawFloat(string title, ref bool use) { if (use == true || showUnused == true) { var rect = D2dHelper.Reserve(); var left = rect; left.xMax -= 18.0f; var right = rect; right.xMin = right.xMax - 16.0f; EditorGUI.PropertyField(left, serializedObject.FindProperty(title)); EditorGUI.BeginChangeCheck(); { use = EditorGUI.Toggle(right, "", use); } if (EditorGUI.EndChangeCheck() == true) { D2dHelper.SetDirty(Target); } } }
private void DrawFloat(string title, ref bool use, ref int value) { if (use == true || showUnused == true) { var rect = D2dHelper.Reserve(); var right = rect; right.xMin += EditorGUIUtility.labelWidth; var rect1 = right; rect1.xMax = rect1.xMin + 16.0f; var rect2 = right; rect2.xMin += 16.0f; EditorGUI.LabelField(rect, title); EditorGUI.BeginChangeCheck(); { use = EditorGUI.Toggle(rect1, "", use); value = EditorGUI.IntField(rect2, "", value); } if (EditorGUI.EndChangeCheck() == true) { D2dHelper.SetDirty(Target); } } }
private void DrawResetAlphaWith() { var rect = D2dHelper.Reserve(); var right = rect; right.xMin += EditorGUIUtility.labelWidth; var rect1 = right; rect1.xMax -= rect1.width / 2; var rect2 = right; rect2.xMin += rect2.width / 2; EditorGUI.LabelField(rect, "Replace Alpha With"); var replaceSprite = (Sprite)EditorGUI.ObjectField(rect1, "", default(Object), typeof(Sprite), true); if (replaceSprite != null) { Each(t => { t.ReplaceAlphaWith(replaceSprite); D2dHelper.SetDirty(t); }); } var replaceTexture2D = (Texture2D)EditorGUI.ObjectField(rect2, "", default(Object), typeof(Texture2D), true); if (replaceTexture2D != null) { Each(t => { t.ReplaceAlphaWith(replaceTexture2D); D2dHelper.SetDirty(t); }); } }
protected bool Button(string text) { var rect = D2dHelper.Reserve(); return(GUI.Button(rect, text)); }
protected override void OnInspector() { var rebuild = false; if (Any(t => t.GetComponent <PolygonCollider2D>() != null)) { EditorGUILayout.HelpBox("D2dDestructible isn't compatible with PolygonCollider2D, use D2dPolygonCollider instead.", MessageType.Warning); } if (Any(t => t.GetComponent <EdgeCollider2D>() != null)) { EditorGUILayout.HelpBox("D2dDestructible isn't compatible with EdgeCollider2D, use D2dEdgeCollider instead.", MessageType.Warning); } DrawDefault("healSnapshot", "If you want to be able to heal this destructible sprite, then set a snapshot of the healed state here."); if (Any(t => t.HealSnapshot != null && t.CanHeal == false)) { EditorGUILayout.HelpBox("This healSnapshot is incompatible with this destructible sprite state.", MessageType.Warning); } DrawDefault("overrideSharpness", "This allows you to manually control the sharpness of the alpha gradient:\nZero = AlphaSharpness\nPositive = OverrideSharpness\nNegative = AlphaSharpness * -OverrideSharpness"); DrawDefault("indestructible", "This keeps your destructible sprite active, but prevents it from taking visual damage."); Separator(); EditorGUILayout.BeginHorizontal(); if (Any(t => t.InvalidMaterial)) { if (GUILayout.Button("Change Material") == true) { Each(t => { if (t.InvalidMaterial == true) { t.ChangeMaterial(); } }); } } if (GUILayout.Button("Optimize") == true) { DirtyEach(t => t.Optimize()); } if (GUILayout.Button("Trim") == true) { DirtyEach(t => t.Trim()); } if (GUILayout.Button("Clear") == true) { DirtyEach(t => t.Clear()); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (Any(t => t.GetComponent <D2dCollider>() == null)) { if (GUILayout.Button("+ Polygon Collider") == true) { Each(t => t.gameObject.AddComponent <D2dPolygonCollider>()); } if (GUILayout.Button("+ Edge Collider") == true) { Each(t => t.gameObject.AddComponent <D2dEdgeCollider>()); } } if (Any(t => t.GetComponent <D2dSplitter>() == null) && GUILayout.Button("+ Splitter") == true) { Each(t => t.gameObject.AddComponent <D2dSplitter>()); } EditorGUILayout.EndHorizontal(); Separator(); if (Targets.Length == 1) { BeginDisabled(); EditorGUI.ObjectField(D2dHelper.Reserve(), "Alpha Tex", Target.AlphaTex, typeof(Texture2D), true); EditorGUILayout.IntField("Alpha Width", Target.AlphaWidth); EditorGUILayout.IntField("Alpha Height", Target.AlphaHeight); EditorGUILayout.FloatField("Alpha Sharpness", Target.AlphaSharpness); EditorGUILayout.IntField("Alpha Count", Target.AlphaCount); EditorGUILayout.IntField("Original Alpha Count", Target.OriginalAlphaCount); EditorGUI.ProgressBar(D2dHelper.Reserve(), Target.AlphaRatio, "Alpha Ratio"); EndDisabled(); } if (rebuild == true) { DirtyEach(t => t.RebuildAlphaTex()); } }
protected override void OnInspector() { DrawResetWith(); DrawResetAlphaWith(); Separator(); DrawDefault("Indestructible"); DrawDefault("RecordAlphaCount"); DrawDefault("AutoSharpen"); EditorGUILayout.Separator(); DrawDefault("AutoSplit"); if (Any(t => t.AutoSplit != D2dDestructible.SplitType.None)) { BeginIndent(); { if (Any(t => t.AutoSplit == D2dDestructible.SplitType.Local)) { DrawDefault("LocalSplitExpand"); } DrawDefault("MinSplitPixels"); DrawDefault("FeatherSplit"); } EndIndent(); } EditorGUILayout.Separator(); DrawDefault("MainTex"); DrawDefault("DensityTex"); DrawDefault("Sharpness"); DrawDefault("color"); DrawDamage(); EditorGUILayout.Separator(); BeginDisabled(true); { BeginMixed(Any(t => t.AlphaTex != Target.AlphaTex)); { EditorGUI.ObjectField(D2dHelper.Reserve(), "Alpha Tex", Target.AlphaTex, typeof(Texture2D), false); } EndMixed(); BeginMixed(Any(t => t.AlphaCount != Target.AlphaCount)); { EditorGUI.IntField(D2dHelper.Reserve(), "Alpha Count", Target.AlphaCount); } EndMixed(); if (Targets.Length == 1 && Target.RecordAlphaCount == true) { EditorGUI.IntField(D2dHelper.Reserve(), "Original Alpha Count", Target.OriginalAlphaCount); EditorGUI.ProgressBar(D2dHelper.Reserve(), Target.RemainingAlpha, "Remaining Alpha"); } } EndDisabled(); EditorGUILayout.Separator(); showEvents = EditorGUI.Foldout(D2dHelper.Reserve(), showEvents, "Show Events"); if (showEvents == true) { DrawDefault("OnStartSplit"); DrawDefault("OnEndSplit"); DrawDefault("OnDamageChanged"); DrawDefault("OnAlphaDataReplaced"); DrawDefault("OnAlphaDataModified"); DrawDefault("OnAlphaDataSubset"); } }