Beispiel #1
0
        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);
            }

            Draw("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);
            }

            Draw("overrideSharpness", "This allows you to manually control the sharpness of the alpha gradient:\nZero = AlphaSharpness\nPositive = OverrideSharpness\nNegative = AlphaSharpness * -OverrideSharpness");
            Draw("paintMultiplier", "This allows you to control how easily this object can be painted.\n\n1 = Default.\n2 = Twice as much damage.\n0.5 = Half as much damage.");
            Draw("pixels", "This allows you to control how the alphaTex pixels are handled.");
            Draw("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());
            }
        }