public override void OnInspectorGUI()
        {
            Use_RecoverAttribute atr = (Use_RecoverAttribute)target;

            EditorGUILayout.BeginVertical();

            toggle = EditorGUILayout.Foldout(toggle, "Recover when used");
            if (toggle)
            {
                EditorGUI.indentLevel++;

                for (int i = 0; i < atr.Recover.Length; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUI.BeginChangeCheck();
                    float val = EditorGUILayout.FloatField(((Stats.StatType)i).ToString(), atr.Recover[i]);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(atr, "Modify attribute");
                        atr.Recover[i] = Mathf.Max(0, val);

                        if (atr.Recover[i] != 0)
                        {
                            atr.enabled[i] = true;
                        }
                        else
                        {
                            atr.enabled[i] = false;
                        }
                        EditorUtility.SetDirty(target);
                    }
                    EditorGUI.BeginChangeCheck();
                    bool enabled = EditorGUILayout.Toggle(atr.enabled[i]);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(atr, "Modify attribute");
                        atr.enabled[i] = enabled;
                    }
                    EditorGUILayout.EndHorizontal();
                }
                EditorGUI.BeginChangeCheck();
                bool use = EditorGUILayout.Toggle("Consume?", atr.destoryOnUse);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(atr, "Modify attribute");
                    atr.destoryOnUse = use;
                    EditorUtility.SetDirty(target);
                }

                EditorGUILayout.Space();
            }
            EditorGUI.indentLevel--;
            EditorGUILayout.EndVertical();
        }
Example #2
0
        public void BuildRecoveryItemUI(GameObject container, Use_RecoverAttribute attr)
        {
            HorizontalLayoutGroup g = BuildLine(container, 20);

            CreateText(GetStyle("HeaderLabel"), g.gameObject, "On Use");

            for (int i = 0; i < attr.Recover.Length; i++)
            {
                if (attr.enabled[i])
                {
                    g = BuildLine(container, 15);
                    CreateText(GetStyle("HeaderLabel"), g.gameObject, i == 0 ? "HP" : "MP");
                    string plus = "+";
                    if (attr.Recover[i] < 0)
                    {
                        plus = "-";
                    }
                    CreateText(GetStyle("HeaderLabel"), g.gameObject, plus + attr.Recover[i].ToString());
                }
            }
        }