Exemplo n.º 1
0
        public override void OnInspectorGUI()
        {
            EditorGUI.BeginChangeCheck();
            {
                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);
                }
            }
        }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
        protected void DirtyEach(System.Action <T> update)
        {
            foreach (var t in Targets)
            {
                update(t);

                D2dHelper.SetDirty(t);
            }
        }
Exemplo n.º 4
0
        public virtual void OnSceneGUI()
        {
            Target = (T)target;

            OnScene();

            if (GUI.changed == true)
            {
                D2dHelper.SetDirty(target);
            }
        }
Exemplo n.º 5
0
        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();
        }
Exemplo n.º 6
0
        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);
                }
            }
        }
Exemplo n.º 7
0
        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);
                }
            }
        }
Exemplo n.º 8
0
        protected void DrawDefault(string propertyPath, bool autoApply = true)
        {
            EditorGUI.BeginChangeCheck();
            {
                EditorGUILayout.BeginVertical(D2dHelper.NoError);
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty(propertyPath), true);
                }
                EditorGUILayout.EndVertical();
            }
            if (EditorGUI.EndChangeCheck() == true)
            {
                if (autoApply == true)
                {
                    serializedObject.ApplyModifiedProperties();
                }

                for (var i = Targets.Length - 1; i >= 0; i--)
                {
                    D2dHelper.SetDirty(Targets[i]);
                }
            }
        }
Exemplo n.º 9
0
        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); });
            }
        }
Exemplo n.º 10
0
 private void MarkDirty()
 {
     Each(t => D2dHelper.SetDirty(t));
 }