Example #1
0
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            IVitals vitals    = (PropertyDrawerUtility.GetParent(property) as IVitals);
            bool    isAnArray = PropertyDrawerUtility.GetIndexOfDrawerObject(property) != -1;

            return((isAnArray && vitals != null) ? 194 : 172);
        }
Example #2
0
        public override void OnGUI(Rect r, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(r, label, property);

            SerializedProperty bitsForStat = property.FindPropertyRelative("bitsForStat");
            SerializedProperty startValue  = property.FindPropertyRelative("startValue");
            SerializedProperty maxValue    = property.FindPropertyRelative("maxValue");

            IVitals vitals = (PropertyDrawerUtility.GetParent(property) as IVitals);

            int  index     = PropertyDrawerUtility.GetIndexOfDrawerObject(property);
            bool isAnArray = index >= 0 && vitals != null;

            float margin       = 4;
            float padding      = 6;
            float width        = r.width + r.xMin + 5;
            float topbarHeight = 74;

            EditorGUI.indentLevel = 0;

            Rect outer = new Rect(0 + margin, r.yMin, width - margin * 2, r.height - margin - (isAnArray ? 24 : 2));

            GUI.Box(outer, GUIContent.none, "flow overlay box");
            GUI.Box(outer, GUIContent.none, "HelpBox");
            Color boxcolor = index == 0 ? new Color(.4f, .2f, .2f) : new Color(.3f, .3f, .3f);

            EditorGUI.DrawRect(new Rect(margin + 1, r.yMin + 1, width - margin * 2 - 2, topbarHeight), boxcolor);

            Rect inner = new Rect(outer.xMin + padding, outer.yMin, outer.width - padding * 2, outer.height);

            inner.yMin  += padding;
            inner.height = 16;

            string vitalnum = isAnArray ? "[" + index + "]" : "Name";

            EditorGUI.LabelField(inner, "Vital " + vitalnum + ((index == 0) ? " (Root)" : ""), (GUIStyle)"WhiteBoldLabel");

            Rect namerect = index > 0 ? new Rect(inner.xMin, inner.yMin, inner.width - 17, inner.height) : inner;

            EditorGUI.PropertyField(namerect, property.FindPropertyRelative("name"), new GUIContent(" "));

            if (index > 0 && vitals != null)
            {
                if (GUI.Button(new Rect(inner.xMin + inner.width - 16, inner.yMin, 16, 16), "X"))
                {
                    vitals.Vitals.RemoveAt(index);
                }
            }

            inner.yMin += 19;

            inner.height = 64;
            EditorGUI.PropertyField(inner, bitsForStat);
            inner.yMin += EditorGUI.GetPropertyHeight(bitsForStat) + padding;            // 64;

            inner.height          = 16;
            startValue.floatValue = EditorGUI.IntSlider(inner, "Start Value", (int)startValue.floatValue, 0, (1 << bitsForStat.intValue));

            inner.yMin         += 17;
            inner.height        = 16;
            maxValue.floatValue = EditorGUI.IntSlider(inner, "Max Value", (int)maxValue.floatValue, 0, (1 << bitsForStat.intValue));

            inner.yMin  += 17;
            inner.height = 16;
            EditorGUI.PropertyField(inner, property.FindPropertyRelative("absorption"));

            inner.yMin  += 17;
            inner.height = 16;
            EditorGUI.PropertyField(inner, property.FindPropertyRelative("regenDelay"));

            inner.yMin  += 17;
            inner.height = 16;
            EditorGUI.PropertyField(inner, property.FindPropertyRelative("regenRate"));

            // Add new vital button (only available if this belongs to a list)
            if (index > -1 && vitals != null)
            {
                inner.yMin  += 28;
                inner.height = 16;
                if (GUI.Button(new Rect(inner.xMin + 64, inner.yMin, inner.width - 128, 16), "Add New Vital"))
                {
                    vitals.Vitals.Insert(index + 1, new Vital());
                }
            }

            EditorGUI.EndProperty();
        }
Example #3
0
        public override void OnGUI(Rect r, SerializedProperty property, GUIContent label)
        {
            InputSelector _target = null;

            EditorGUI.BeginProperty(r, label, property);

            // Very roundabout way of getting this target if is part of a list.
            var _parent = PropertyDrawerUtility.GetParent(property);
            int index   = PropertyDrawerUtility.GetIndexOfDrawerObject(property);

            if (_parent != null && _parent is InputSelectors && index != -1)
            {
                _target = (_parent as InputSelectors).selectors [index];
            }

            // This is not part of a list...
            if (_target == null)
            {
                _target = PropertyDrawerUtility.GetActualObjectForSerializedProperty <InputSelector>(fieldInfo, property);
            }

            if (_target != null)
            {
                _target.UpdateToSelectedType();
            }

            // This will need to be an interface in order to be useable on more than just NSTCastDefinition
            //NSTCastDefinition nstCastDef = property.serializedObject.targetObject as NSTCastDefinition;
            SerializedProperty inputType = property.FindPropertyRelative("inputType");

            //SerializedProperty inputSelection = property.FindPropertyRelative("triggers");

            labelWidth     = EditorGUIUtility.labelWidth - 36;
            fieldWidth     = r.width - labelWidth;
            halfFieldWidth = fieldWidth * .5f;
            fieldAreaLeft  = r.xMin + labelWidth;

            int val = (int)(InputType)EditorGUI.EnumPopup(new Rect(r.xMin, r.yMin, labelWidth - 2, 16), GUIContent.none, (InputType)inputType.enumValueIndex);

            inputType.enumValueIndex = val;

            Rect      rightrect = new Rect(fieldAreaLeft, r.yMin, fieldWidth, r.height);
            InputType enumVal   = (InputType)val;

            // Only show the derived input class that we are actually using
            if (enumVal == InputType.Axis)
            {
                EditorGUI.PropertyField(rightrect, property.FindPropertyRelative("inputAxis"));
            }

            else if (enumVal == InputType.KeyCode)
            {
                EditorGUI.PropertyField(rightrect, property.FindPropertyRelative("inputKeyCode"));
            }

            else if (enumVal == InputType.Keys)
            {
                EditorGUI.PropertyField(rightrect, property.FindPropertyRelative("inputKeys"));
            }

            else if (enumVal == InputType.UIZone)
            {
                EditorGUI.PropertyField(rightrect, property.FindPropertyRelative("inputUIZone"));
            }

            else if (enumVal == InputType.TouchArea)
            {
                EditorGUI.PropertyField(rightrect, property.FindPropertyRelative("inputTouchArea"));
            }

            EditorGUI.EndProperty();
        }
Example #4
0
        public override void OnGUI(Rect r, SerializedProperty property, GUIContent label)
        {
            if (miniLabelRight == null)
            {
                miniLabelRight = new GUIStyle("Label")
                {
                    alignment = TextAnchor.UpperRight
                }
            }
            ;
            //EditorGUI.BeginProperty(r, label, property);

            EditorGUI.BeginChangeCheck();

            int  index     = PropertyDrawerUtility.GetIndexOfDrawerObject(property);
            bool isAnArray = index >= 0;

            r.xMin += 2;
            r.xMax -= 2;

            Rect outer = r;

            outer.xMin  = (outer.xMin - PAD) + INDENT;
            outer.xMax += PAD;

            if (property.isExpanded)
            {
                outer.height = FIXED_HGHT;                 // TOP_BAR + 2;
            }
            GUI.Box(outer, GUIContent.none, "HelpBox");
            var vitalcolor = index == 0 ? SolidTextures.red2D : SolidTextures.blue2D;

            outer.xMin  += 1; outer.yMin += 1;
            outer.width -= 1;
            outer.height = TOP_BAR;
            SolidTextures.DrawTexture(outer, vitalcolor);

            Rect inner = r;

            inner.yMin  += PAD;
            inner.height = HEIGHT;

            /// Using the ! of isExpanded, so that the default starting state is true rather than false.
            property.isExpanded = EditorGUI.Toggle(new Rect(inner)
            {
                xMin = 4, width = 64
            }, "", property.isExpanded, (GUIStyle)"Foldout");

            inner.xMin += INDENT;

            var vitalNameType = property.FindPropertyRelative("vitalName");

            Rect vitalnamerect = new Rect(inner)
            {
                yMin = inner.yMin - 1, xMax = (isAnArray && index != 0) ? (inner.xMax - 22) : inner.xMax
            };

            EditorGUI.PropertyField(vitalnamerect, vitalNameType, new GUIContent(index.ToString()));

            inner.yMin  += HEIGHT;
            inner.height = HEIGHT;
            EditorGUI.PropertyField(inner, property.FindPropertyRelative("startValue"));


            inner.yMin  += HEIGHT;
            inner.height = HEIGHT;
            DrawValueAndBitsNeeded(inner, property.FindPropertyRelative("_maxValue"));

            inner.yMin += 6;

            if (property.isExpanded)
            {
                inner.yMin  += HEIGHT;
                inner.height = HEIGHT;
                EditorGUI.PropertyField(inner, property.FindPropertyRelative("_fullValue"));


                inner.yMin  += HEIGHT;
                inner.height = HEIGHT;
                EditorGUI.PropertyField(inner, property.FindPropertyRelative("absorption"));

                inner.yMin  += HEIGHT;
                inner.height = HEIGHT;
                EditorGUI.PropertyField(inner, property.FindPropertyRelative("regenDelay"));

                inner.yMin  += HEIGHT;
                inner.height = HEIGHT;
                EditorGUI.PropertyField(inner, property.FindPropertyRelative("regenRate"));

                inner.yMin  += HEIGHT;
                inner.height = HEIGHT;
                //EditorGUI.PropertyField(inner, property.FindPropertyRelative("decayDelay"));
                DrawValueAndBitsNeeded(inner, property.FindPropertyRelative("decayDelay"), TickEngineSettings.netTickInterval);

                inner.yMin  += HEIGHT;
                inner.height = HEIGHT;
                EditorGUI.PropertyField(inner, property.FindPropertyRelative("decayRate"));
            }

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(property.serializedObject.targetObject, "Change Vitals");
                property.serializedObject.ApplyModifiedProperties();
                //AssetDatabase.SaveAssets();
            }
            //EditorGUI.EndProperty();
        }

        const int BITS_WIDTH = 64;