예제 #1
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            MemberData      variable = PropertyDrawerUtility.GetActualObjectForSerializedProperty <MemberData>(property);
            FilterAttribute filter   = null;

            if (fieldInfo.IsDefined(typeof(ObjectTypeAttribute), true))
            {
                object pVariable       = PropertyDrawerUtility.GetParentObjectFromSerializedProperty <object>(property);
                var    fieldAttributes = fieldInfo.GetCustomAttributes(true);
                if (pVariable != null && ReflectionUtils.TryCorrectingAttribute(pVariable, ref fieldAttributes))
                {
                    filter = ReflectionUtils.GetAttribute <FilterAttribute>(fieldAttributes);
                }
                else
                {
                    return;
                }
            }
            else if (fieldInfo.GetCustomAttributes(typeof(FilterAttribute), false).Length > 0)
            {
                filter = (FilterAttribute)fieldInfo.GetCustomAttributes(typeof(FilterAttribute), false)[0];
            }
            if (fieldInfo.GetCustomAttributes(typeof(TooltipAttribute), false).Length > 0)
            {
                label.tooltip = ((TooltipAttribute)fieldInfo.GetCustomAttributes(typeof(TooltipAttribute), false)[0]).tooltip;
            }
            EditorReflectionUtility.RenderVariable(position, variable, label, property.serializedObject.targetObject, filter);
        }
예제 #2
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);
        }
예제 #3
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, property);
            position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
            var indent = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;
            var value =
                PropertyDrawerUtility.GetActualObjectForSerializedProperty <StatesEnum>(fieldInfo, property);

            if (value != null)
            {
                EditorGUI.BeginChangeCheck();
                var newSelectedIndex = EditorGUI.Popup(position, value.SelectedIndex, value.Values);
                if (EditorGUI.EndChangeCheck())
                {
                    value.SelectedIndex = newSelectedIndex;
                    PropertyDrawerUtility.SetActualObjectForSerializedProperty(fieldInfo, property, value);
                    property.serializedObject.ApplyModifiedProperties();
                }

                EditorGUI.indentLevel = indent;
                EditorGUI.EndProperty();
            }
        }
예제 #4
0
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            object variable = PropertyDrawerUtility.GetParentObjectFromSerializedProperty <object>(property);

            if (variable != null)
            {
                if (uNodeGUIUtility.IsHide(fieldInfo, variable))
                {
                    return(-EditorGUIUtility.standardVerticalSpacing);
                }
            }
            else
            {
                if (fieldInfo.IsDefined(typeof(HideAttribute), true))
                {
                    HideAttribute[] hide = fieldInfo.GetCustomAttributes(typeof(HideAttribute), true) as HideAttribute[];
                    foreach (HideAttribute ha in hide)
                    {
                        if (string.IsNullOrEmpty(ha.targetField))
                        {
                            return(-EditorGUIUtility.standardVerticalSpacing);
                        }
                    }
                }
            }
            System.Type type = fieldInfo.FieldType;
            if (fieldInfo.FieldType.IsArray)
            {
                type = fieldInfo.FieldType.GetElementType();
            }
            else if (fieldInfo.FieldType.IsGenericType)
            {
                System.Type[] gType = fieldInfo.FieldType.GetGenericArguments();
                if (gType.Length == 1)
                {
                    type = gType[0];
                }
            }
            if (type == typeof(MemberData))
            {
                if (fieldInfo.IsDefined(typeof(ObjectTypeAttribute), true))
                {
                    var fieldAttributes = fieldInfo.GetCustomAttributes(true);
                    if (variable != null && ReflectionUtils.TryCorrectingAttribute(variable, ref fieldAttributes))
                    {
                        var OTA = ReflectionUtils.GetAttribute <ObjectTypeAttribute>(fieldAttributes);
                        if (OTA != null && OTA.type != null)
                        {
                            return(EditorGUI.GetPropertyHeight(property, label, true));
                        }
                    }
                    return(-EditorGUIUtility.standardVerticalSpacing);
                }
            }
            return(EditorGUI.GetPropertyHeight(property, label, true));
        }
예제 #5
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        var name = property.FindPropertyRelative("dstItemUnit.itemName").stringValue;

        if (!string.IsNullOrWhiteSpace(name))
        {
            label = new GUIContent(name);
        }
        PropertyDrawerUtility.DrawDefaultGUI(position, property, label);
        return;
    }
예제 #6
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            ControllerKeyMap target = PropertyDrawerUtility.GetActualObjectForSerializedProperty <ControllerKeyMap>(fieldInfo, property);

            // Outline box
            GUI.Box(position, GUIContent.none, "HelpBox");

            for (int i = 0; i < target.keyMaps.Length; i++)
            {
                Rect r = new Rect(position.xMin + padding, position.yMin + 16 * i + padding, position.width - padding * 2, 16);
                target.keyMaps[i] = (KeyCode)EditorGUI.EnumPopup(r, Enum.GetName(typeof(InputAxis), (InputAxis)i), target.keyMaps[i]);
            }
        }
예제 #7
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (fieldInfo.IsDefined(typeof(TooltipAttribute), true))
            {
                label.tooltip = ((TooltipAttribute)fieldInfo.GetCustomAttributes(typeof(TooltipAttribute), true)[0]).tooltip;
            }
            var value = PropertyDrawerUtility.GetActualObjectForSerializedProperty <FunctionModifier>(property);

            EditorGUI.BeginProperty(position, label, property);
            uNodeGUIUtility.EditValue(position, label, value, null, new uNodeUtility.EditValueSettings()
            {
                unityObject = property.serializedObject.targetObject,
            });
            VariableEditorUtility.DrawMultipurposeMember(position, property, label);
            EditorGUI.EndProperty();
        }
예제 #8
0
 public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
 {
     if (fieldInfo.IsDefined(typeof(ObjectTypeAttribute), true))
     {
         var    fieldAttributes = fieldInfo.GetCustomAttributes(true);
         object variable        = PropertyDrawerUtility.GetParentObjectFromSerializedProperty <object>(property);
         if (variable != null && ReflectionUtils.TryCorrectingAttribute(variable, ref fieldAttributes))
         {
             var OTA = ReflectionUtils.GetAttribute <ObjectTypeAttribute>(fieldAttributes);
             if (OTA != null && OTA.type != null)
             {
                 return(base.GetPropertyHeight(property, label));
             }
         }
         return(0);
     }
     return(base.GetPropertyHeight(property, label));
 }
예제 #9
0
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            property.serializedObject.Update();

            SerializedProperty vitalDefs = property.FindPropertyRelative("vitalDefs");
            Vitals             ivitals   = (PropertyDrawerUtility.GetParent(vitalDefs) as Vitals);
            int vitalsCount = ivitals.vitalDefs.Count;

            float h = 0;

            for (int i = 0; i < vitalsCount; ++i)
            {
                h += EditorGUI.GetPropertyHeight(vitalDefs.GetArrayElementAtIndex(i));
                h += ADD_BUTTON_HGHT + VitalDefinitionDrawer.PAD * 2 + 2;
            }

            return(h);
        }
예제 #10
0
        public override void OnGUI(Rect r, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(r, label, property);

            InputSelector par = (InputSelector)PropertyDrawerUtility.GetParent(property);

            // Initialize constantly to apply changes
            par.inputSelection.Initialize(par);
            //var _target = PropertyDrawerUtility.GetActualObjectForSerializedProperty<InputSelectorKeyCode>(fieldInfo, property);
            //Debug.Log(_target);
            //int id = PropertyDrawerUtility.GetIndexOfDrawerObject(property);
            //Debug.Log(par);


            index         = property.FindPropertyRelative("index");
            modKeys       = property.FindPropertyRelative("modKeys");
            castInputType = property.FindPropertyRelative("inputType");

            halfFieldWidth  = r.width * .5f;
            firstFieldLeft  = r.xMin;
            secondFieldLeft = r.xMin + halfFieldWidth;

            if (!isTouch)
            {
                int oldVal = modKeys.intValue;
                int newVal = (int)(ModKeys)EditorGUI.EnumMaskPopup(new Rect(r.xMin, r.yMin, halfFieldWidth, r.height), GUIContent.none, (ModKeys)modKeys.intValue);

                // if UnModded has just been selected - clamp to clear all other mods
                if (newVal - oldVal >= (int)ModKeys.UnModded)
                {
                    newVal = (int)ModKeys.UnModded;
                }

                // else if a mod has been selected, clear unmodded
                else if (newVal > (int)ModKeys.UnModded)
                {
                    newVal = newVal & ~((int)ModKeys.UnModded);
                }

                modKeys.intValue = newVal;
            }

            EditorGUI.EndProperty();
        }
        public void Toggle(bool open, SerializedProperty property)
        {
            AnimationGroup target = PropertyDrawerUtility.GetActualObjectForSerializedProperty <AnimationGroup>(fieldInfo, property);

            target.isOpen = open;

            foreach (UIAnimation.RectMoveAnimation item in target.moveAnimations)
            {
                item.rect.anchoredPosition = (open) ? item.open : item.close;
            }

            foreach (UIAnimation.RectScaleAnimation item in target.scaleAnimations)
            {
                item.rect.localScale = (open) ? item.open : item.close;
            }

            foreach (UIAnimation.RectRotateAnimation item in target.rotateAnimation)
            {
                Vector3 rot = (open) ? item.open : item.close;
                item.rect.rotation = Quaternion.Euler(rot);
            }

            foreach (UIAnimation.TextFadeAnimation item in target.textFadeAnimations)
            {
                item.text.color = (open) ? item.open : item.close;
            }

            foreach (UIAnimation.ImageFadeAnimation item in target.imageFadeAnimations)
            {
                item.image.color = (open) ? item.open : item.close;
            }

            foreach (UIAnimation.ImageFillAnimation item in target.imageFillAnimations)
            {
                item.image.fillAmount = (open) ? item.open : item.close;
            }

            foreach (UIAnimation.CanvasGroupFadeAnimation item in target.canvasGroupFadeAnimation)
            {
                item.cg.alpha          = (open) ? item.open : item.close;
                item.cg.interactable   = open;
                item.cg.blocksRaycasts = open;
            }
        }
예제 #12
0
        public override void OnGUI(Rect r, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(r, label, property);

            InputSelector par = (InputSelector)PropertyDrawerUtility.GetParent(property);

            // Initialize constantly to apply changes
            par.inputSelection.Initialize(par);

            index         = property.FindPropertyRelative("index");
            modKeys       = property.FindPropertyRelative("modKeys");
            castInputType = property.FindPropertyRelative("inputType");

            halfFieldWidth  = r.width * .5f;
            firstFieldLeft  = r.xMin;
            secondFieldLeft = r.xMin + halfFieldWidth;

            if (!isTouch)
            {
                int oldVal = modKeys.intValue;

#if UNITY_2017_3_OR_NEWER
                int newVal = (int)(ModKeys)EditorGUI.EnumFlagsField(new Rect(r.xMin, r.yMin, halfFieldWidth, r.height), GUIContent.none, (ModKeys)modKeys.intValue);
#else
                int newVal = (int)(ModKeys)EditorGUI.EnumMaskField(new Rect(r.xMin, r.yMin, halfFieldWidth, r.height), GUIContent.none, (ModKeys)modKeys.intValue);
#endif
                // if UnModded has just been selected - clamp to clear all other mods
                if (newVal - oldVal >= (int)ModKeys.UnModded)
                {
                    newVal = (int)ModKeys.UnModded;
                }

                // else if a mod has been selected, clear unmodded
                else if (newVal > (int)ModKeys.UnModded)
                {
                    newVal = newVal & ~((int)ModKeys.UnModded);
                }

                modKeys.intValue = newVal;
            }

            EditorGUI.EndProperty();
        }
        public override void OnGUI(Rect r, SerializedProperty property, GUIContent label)
        {
            InputSelector       inputSelector = PropertyDrawerUtility.GetParent(property) as InputSelector;
            InputSelectorUIZone _target       = inputSelector.inputSelection as InputSelectorUIZone;

            // Tell the base class that this is a touch/click item - so the modkeys are not needed.
            isTouch = true;

            base.OnGUI(r, property, label);

            SerializedProperty touchTypes   = property.FindPropertyRelative("touchType");
            SerializedProperty zoneSelector = property.FindPropertyRelative("zoneSelector");

            {
                if (_target != null)
                {
                    touchTypes.enumValueIndex = (int)(ClickTypes)EditorGUI.EnumPopup(new Rect(firstFieldLeft, r.yMin, halfFieldWidth, 16), GUIContent.none, (ClickTypes)touchTypes.enumValueIndex);
                    EditorGUI.PropertyField(new Rect(secondFieldLeft, r.yMin, halfFieldWidth, 16), zoneSelector);
                }
            }
        }
예제 #14
0
 void FindTargetField()
 {
     if (!string.IsNullOrEmpty(propertyPath))
     {
         object data = PropertyDrawerUtility.GetActualObjectFromPath <object>(propertyPath, targetObject);
         if (data is EventData)
         {
             if (data != null && actionIndex < (data as EventData).blocks.Count)
             {
                 targetField = (data as EventData).blocks[actionIndex].block;
             }
         }
         else
         {
             targetField = data;
         }
     }
     else if (GetTargetField != null)
     {
         targetField = GetTargetField(userObject);
     }
 }
예제 #15
0
        public override void OnGUI(Rect r, SerializedProperty property, GUIContent label)
        {
            MouseInputAxis _target = PropertyDrawerUtility.GetActualObjectForSerializedProperty <MouseInputAxis>(fieldInfo, property);

            Rect r2 = new Rect(r.xMin, r.yMin, r.width, r.height + 2);

            GUI.Box(r2, GUIContent.none, "HelpBox");

            r2 = new Rect(r.xMin - 4, r.yMin, 4, r.height + 2);
            Color color = (_target.axisId == 0) ? Color.red : (_target.axisId == 1) ? Color.green : Color.blue;

            EditorGUI.DrawRect(r2, color);

            float labelwidth = EditorGUIUtility.labelWidth;
            float fieldwidth = r.width - labelwidth - padding;

            r2 = new Rect(r.xMin + padding, r.yMin + padding, labelwidth, 16);
            string labeltext = (_target.axisId == 0) ? "X - Pitch" : (_target.axisId == 1) ? "Y - Yaw" : "Z - Roll";

            GUI.Label(r2, labeltext);

            r2 = new Rect(r.xMin + labelwidth, r.yMin + padding, fieldwidth - 40, 16);
            _target.mouseAxis = (MouseAxes)EditorGUI.EnumPopup(r2, GUIContent.none, _target.mouseAxis);


            r2 = new Rect(r.width - 18 + padding, r.yMin + padding, 30, 16);
            GUI.Label(r2, "Inv");

            r2             = new Rect(r.width - 32 + padding, r.yMin + padding, 50, 16);
            _target.invert = EditorGUI.Toggle(r2, _target.invert);


            r2 = new Rect(r.xMin + labelwidth, r.yMin + padding + 17, fieldwidth, 16);
            _target.sensitivity = EditorGUI.Slider(r2, GUIContent.none, _target.sensitivity, 0f, (_target.mouseAxis > MouseAxes.MouseY) ? 20f : 5f);

            r2 = new Rect(r.xMin + padding, r.yMin + padding + 17, labelwidth, 16);
            EditorGUI.LabelField(r2, "Sensitivity");
        }
예제 #16
0
        public override void OnGUI(Rect r, SerializedProperty property, GUIContent label)
        {
            InputSelectorUIZone inputSelector = PropertyDrawerUtility.GetParent(property) as InputSelectorUIZone;
            //int index = PropertyDrawerUtility.GetIndexOfDrawerObject(property);
            UIZoneSelector _target = inputSelector.zoneSelector;

            // Get the array of zoneNames
            List <string> zonesnamelist = UIZone.names;            // GetListOfZoneNames();

            // only resize the string array when it doesn't match the number of UIZones in scene
            if (zonesnamelist.Count != zonenames.Length)
            {
                zonenames = new string[zonesnamelist.Count];
            }

            for (int i = 0; i < zonesnamelist.Count; i++)
            {
                zonenames[i] = zonesnamelist[i];
            }

            if (zonesnamelist.Count == 0)
            {
                EditorUtils.CreateErrorIconF(r.xMin, r.yMin, "Add a UIZone component to a UI object to define a touch/mouse area. Any added zones will appear in a list here for you to select from.");

                EditorGUI.LabelField(r, "     No UIZones found in scene.", new GUIStyle("MiniLabel"));
            }
            else
            {
                if (_target != null)
                {
                    _target.ZoneId   = EditorGUI.Popup(r, _target.ZoneId, zonenames);
                    _target.ZoneName = UIZone.list[_target.ZoneId].itemName;
                }

                //selectedZoneName.stringValue = zonenames[selectedZoneId.intValue];
            }
        }
예제 #17
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            object variable = PropertyDrawerUtility.GetParentObjectFromSerializedProperty <object>(property);

            if (variable != null)
            {
                if (uNodeGUIUtility.IsHide(fieldInfo, variable))
                {
                    return;
                }
            }
            else
            {
                if (fieldInfo.IsDefined(typeof(HideAttribute), true))
                {
                    HideAttribute[] hide = fieldInfo.GetCustomAttributes(typeof(HideAttribute), true) as HideAttribute[];
                    foreach (HideAttribute ha in hide)
                    {
                        if (string.IsNullOrEmpty(ha.targetField))
                        {
                            return;
                        }
                    }
                }
            }
            if (fieldInfo.IsDefined(typeof(TooltipAttribute), true))
            {
                label.tooltip = ((TooltipAttribute)fieldInfo.GetCustomAttributes(typeof(TooltipAttribute), true)[0]).tooltip;
            }
            System.Type type = fieldInfo.FieldType;
            if (fieldInfo.FieldType.IsArray)
            {
                type = fieldInfo.FieldType.GetElementType();
            }
            else if (fieldInfo.FieldType.IsGenericType)
            {
                System.Type[] gType = fieldInfo.FieldType.GetGenericArguments();
                if (gType.Length == 1)
                {
                    type = gType[0];
                }
            }
            if (type == typeof(MemberData))
            {
                MemberData      obj    = PropertyDrawerUtility.GetActualObjectForSerializedProperty <MemberData>(property);
                FilterAttribute filter = null;
                if (fieldInfo.GetCustomAttributes(typeof(FilterAttribute), false).Length > 0)
                {
                    filter = (FilterAttribute)fieldInfo.GetCustomAttributes(typeof(FilterAttribute), false)[0];
                }
                else if (fieldInfo.IsDefined(typeof(ObjectTypeAttribute), true))
                {
                    var    fieldAttributes = fieldInfo.GetCustomAttributes(true);
                    object pVariable       = PropertyDrawerUtility.GetParentObjectFromSerializedProperty <object>(property);
                    if (pVariable != null && ReflectionUtils.TryCorrectingAttribute(pVariable, ref fieldAttributes))
                    {
                        filter = ReflectionUtils.GetAttribute <FilterAttribute>(fieldAttributes);
                    }
                    else
                    {
                        return;
                    }
                }
                EditorReflectionUtility.RenderVariable(position, obj, label, property.serializedObject.targetObject, filter);
            }
            else
            {
                EditorGUI.PropertyField(position, property, label, true);
            }
        }
예제 #18
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();
        }
예제 #19
0
 public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
 {
     return(PropertyDrawerUtility.GetDefaultPropertyHeight(property, label));
 }
        /// <summary>
        /// Everything belows are helpers
        /// </summary>
        public void CopyValues(bool toOpen, SerializedProperty property)
        {
            AnimationGroup target = PropertyDrawerUtility.GetActualObjectForSerializedProperty <AnimationGroup>(fieldInfo, property);

            foreach (UIAnimation.RectMoveAnimation item in target.moveAnimations)
            {
                if (toOpen)
                {
                    item.open = item.rect.anchoredPosition;
                }
                else
                {
                    item.close = item.rect.anchoredPosition;
                }
            }

            foreach (UIAnimation.RectRotateAnimation item in target.rotateAnimation)
            {
                Vector3 rot = item.rect.rotation.eulerAngles;

                if (toOpen)
                {
                    item.open = rot;
                }
                else
                {
                    item.close = rot;
                }
            }

            foreach (UIAnimation.RectScaleAnimation item in target.scaleAnimations)
            {
                if (toOpen)
                {
                    item.open = item.rect.localScale;
                }
                else
                {
                    item.close = item.rect.localScale;
                }
            }

            foreach (UIAnimation.TextFadeAnimation item in target.textFadeAnimations)
            {
                if (toOpen)
                {
                    item.open = item.text.color;
                }
                else
                {
                    item.close = item.text.color;
                }
            }

            foreach (UIAnimation.ImageFadeAnimation item in target.imageFadeAnimations)
            {
                if (toOpen)
                {
                    item.open = item.image.color;
                }
                else
                {
                    item.close = item.image.color;
                }
            }

            foreach (UIAnimation.ImageFillAnimation item in target.imageFillAnimations)
            {
                if (toOpen)
                {
                    item.open = item.image.fillAmount;
                }
                else
                {
                    item.close = item.image.fillAmount;
                }
            }

            foreach (UIAnimation.CanvasGroupFadeAnimation item in target.canvasGroupFadeAnimation)
            {
                if (toOpen)
                {
                    item.open = item.cg.alpha;
                }
                else
                {
                    item.close = item.cg.alpha;
                }
            }
        }
예제 #21
0
        public override void OnGUI(Rect r, SerializedProperty property, GUIContent label)
        {
            property.serializedObject.Update();

            SerializedProperty vitalDefs = property.FindPropertyRelative("vitalDefs");
            Vitals             ivitals   = (PropertyDrawerUtility.GetParent(vitalDefs) as Vitals);

            int vitalsCount = vitalDefs.arraySize;

            int addIndex = -1;

            //int delIndex = -1;
            for (int i = 0; i < vitalsCount; ++i)
            {
                var element = vitalDefs.GetArrayElementAtIndex(i);
                r.height = EditorGUI.GetPropertyHeight(element);

                EditorGUI.PropertyField(new Rect(r), element, false);

                if (i > 0)
                {
                    const int XWIDTH = 18;
                    Rect      xr     = r;
                    xr.xMin   = xr.xMax - XWIDTH - VitalDefinitionDrawer.PAD;
                    xr.yMin  += VitalDefinitionDrawer.PAD;
                    xr.height = ADD_BUTTON_HGHT;
                    xr.width  = XWIDTH;
                    if (GUI.Button(xr, "X"))
                    {
                        Undo.RecordObject(vitalDefs.serializedObject.targetObject, "Delete Vital");
                        ivitals.VitalDefs.Remove(ivitals.VitalDefs[i]);
                        EditorUtility.SetDirty(vitalDefs.serializedObject.targetObject);
                        AssetDatabase.Refresh();
                        break;
                    }
                }

                r.yMin += r.height + VitalDefinitionDrawer.PAD + 2;

                r.height = ADD_BUTTON_HGHT;

                const int ADDMARGIN = 80;
                Rect      addrect   = new Rect(r)
                {
                    xMin = r.xMin + 4 + ADDMARGIN, xMax = r.xMax - ADDMARGIN
                };
                if (GUI.Button(addrect, "Add Vital", (GUIStyle)"MiniToolbarButton"))
                {
                    addIndex = i + 1;
                }

                r.yMin += r.height + VitalDefinitionDrawer.PAD;
            }

            if (addIndex != -1)
            {
                Undo.RecordObject(vitalDefs.serializedObject.targetObject, "Add Vital");
                vitalDefs.InsertArrayElementAtIndex(addIndex);
                EditorUtility.SetDirty(vitalDefs.serializedObject.targetObject);
                property.serializedObject.ApplyModifiedProperties();
                AssetDatabase.Refresh();
            }
        }
예제 #22
0
        public override void OnGUI(Rect r, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(r, label, property);
            var par = PropertyDrawerUtility.GetParent(property);

            GameObject parGO;

            // the parent may be an NST or a TransformElement
            if (par is NSTElementComponent)
            {
                parGO = (par as NSTElementComponent).gameObject;
            }
            else
            {
                parGO = (par as NetworkSyncTransform).gameObject;
            }

            TransformElement te = PropertyDrawerUtility.GetActualObjectForSerializedProperty <TransformElement>(fieldInfo, property);

            name             = property.FindPropertyRelative("name");
            isRoot           = property.FindPropertyRelative("isRoot");
            elementType      = property.FindPropertyRelative("elementType");
            keyRate          = property.FindPropertyRelative("keyRate");
            sendCullMask     = property.FindPropertyRelative("sendCullMask");
            gameobject       = property.FindPropertyRelative("gameobject");
            extrapolation    = property.FindPropertyRelative("extrapolation");
            maxExtrapolates  = property.FindPropertyRelative("maxExtrapolates");
            teleportOverride = property.FindPropertyRelative("teleportOverride");

            isPos = (ElementType)elementType.intValue == ElementType.Position;
            string typeLabel = (isPos) ? "Position" : "Rotation";

            margin    = 4;
            realwidth = r.width + 16 - 4;
            colwidths = realwidth / 4f;

            colwidths = Mathf.Max(colwidths, 65);             // limit the smallest size so things like sliders aren't shrunk too small to draw.

            currentLine = r.yMin + margin * 2;

            Color headerblockcolor = (isPos ? positionHeaderBarColor : rotationHeaderBarColor);

            //GUI.Box(new Rect(margin, r.yMin + 2, realwidth, r.height - margin), GUIContent.none,  "ProjectBrowserTextureIconDropShadow");
            //GUI.Box(new Rect(margin, r.yMin + 2, realwidth, r.height - margin), GUIContent.none,  "HelpBox"); //"ProjectBrowserTextureIconDropShadow");

            if (!isRoot.boolValue)
            {
                EditorGUI.DrawRect(new Rect(margin + 3, r.yMin + 2 + 2, realwidth - 6, LINEHEIGHT + 8), headerblockcolor);
            }

            savedIndentLevel = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;
            if (!isRoot.boolValue)
            {
                string headerLabel = typeLabel + " Element";

                EditorGUI.LabelField(new Rect(r.xMin, currentLine, colwidths * 4, LINEHEIGHT), new GUIContent(headerLabel), "WhiteBoldLabel");

                NSTElementComponentEditor.MakeAllNamesUnique(parGO, te);

                EditorGUI.PropertyField(new Rect(r.xMin, currentLine, r.width - 4, LINEHEIGHT), name, new GUIContent(" "));

                currentLine += LINEHEIGHT + 8;
            }

            else
            {
                EditorGUI.LabelField(new Rect(r.xMin, currentLine, r.width, LINEHEIGHT), new GUIContent("Root Rotation Updates"), "BoldLabel");
                currentLine += LINEHEIGHT + 4;
            }
            EditorGUI.indentLevel = 0;

            // Section for Send Culling enum flags

            left                  = 13;
            realwidth            -= 16;
            sendCullMask.intValue = System.Convert.ToInt32(EditorGUI.EnumMaskPopup(new Rect(left, currentLine, realwidth, LINEHEIGHT), new GUIContent("Send On Events:"), (SendCullMask)sendCullMask.intValue));
            currentLine          += LINEHEIGHT + 4;

            if (!isRoot.boolValue)
            {
                EditorGUI.PropertyField(new Rect(left, currentLine, realwidth, LINEHEIGHT), gameobject, new GUIContent("GameObject:"));
                currentLine += LINEHEIGHT + 4;
            }

            if (((SendCullMask)sendCullMask.intValue).EveryTick() == false)
            {
                EditorGUI.PropertyField(new Rect(left, currentLine, realwidth, LINEHEIGHT), keyRate, new GUIContent("Key Every:"));
                currentLine += LINEHEIGHT + 2;
            }

            if (keyRate.intValue == 0 && sendCullMask.intValue == 0)
            {
                noUpdates = true;
                EditorGUI.HelpBox(new Rect(left, currentLine, realwidth, 48), typeLabel + " Element Disabled. Select one ore more Send On Events, and/or set Key Every to a number greater than 0.", MessageType.Warning);
                currentLine += 50;

                return;
            }
            else
            {
                noUpdates = false;

                EditorGUI.PropertyField(new Rect(left, currentLine, realwidth, LINEHEIGHT), extrapolation, new GUIContent("Extrapolation:"));
                currentLine += LINEHEIGHT + 2;

                EditorGUI.PropertyField(new Rect(left, currentLine, realwidth, LINEHEIGHT), maxExtrapolates, new GUIContent("Max Extrapolations:"));
                currentLine += LINEHEIGHT + 2;

                EditorGUI.PropertyField(new Rect(left, currentLine, realwidth, LINEHEIGHT), teleportOverride, new GUIContent("Teleport Override:"));
                currentLine += LINEHEIGHT + 2;
            }
        }
예제 #23
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();
        }
예제 #24
0
 private PatternParameter PropToParam(SerializedProperty prop)
 {
     return(PropertyDrawerUtility.GetActualObject <PatternParameter>(fieldInfo, prop));
 }
예제 #25
0
 /// <summary>
 ///
 /// </summary>
 public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
 {
     PropertyDrawerUtility.Separator(pos);
 }
예제 #26
0
        public override void OnGUI(Rect r, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(r, label, property);

            property.serializedObject.ApplyModifiedProperties();
            property.serializedObject.Update();

            var par = PropertyDrawerUtility.GetParent(property);

            GameObject parGO;

            // the parent may be an NST or a TransformElement
            if (par is NSTElementComponent)
            {
                parGO = (par as NSTElementComponent).gameObject;
            }
            else
            {
                parGO = (par as NetworkSyncTransform).gameObject;
            }

            TransformElement te = PropertyDrawerUtility.GetActualObjectForSerializedProperty <TransformElement>(fieldInfo, property);

            name             = property.FindPropertyRelative("name");
            isRoot           = property.FindPropertyRelative("isRoot");
            keyRate          = property.FindPropertyRelative("keyRate");
            sendCullMask     = property.FindPropertyRelative("sendCullMask");
            gameobject       = property.FindPropertyRelative("gameobject");
            extrapolation    = property.FindPropertyRelative("extrapolation");
            maxExtrapolates  = property.FindPropertyRelative("maxExtrapolates");
            teleportOverride = property.FindPropertyRelative("teleportOverride");

            isPos = (te is IPositionElement);
            isRot = (te is IRotationElement);

            string typeLabel = (isPos) ? "Position" :  (isRot) ? "Rotation" : "Scale";

            margin    = 4;
            realwidth = r.width + 16 - 4;
            colwidths = realwidth / 4f;

            colwidths = Mathf.Max(colwidths, 65);             // limit the smallest size so things like sliders aren't shrunk too small to draw.

            currentLine = r.yMin + margin * 2;

            Color headerblockcolor = (isPos ? positionHeaderBarColor : isRot ? rotationHeaderBarColor : scaleHeaderBarColor);

            if (!isRoot.boolValue)
            {
                EditorGUI.DrawRect(new Rect(margin + 3, r.yMin + 2 + 2, realwidth - 6, LINEHEIGHT + 8), headerblockcolor);
            }

            savedIndentLevel = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;
            if (!isRoot.boolValue)
            {
                string headerLabel = typeLabel + " Element";

                EditorGUI.LabelField(new Rect(r.xMin, currentLine, colwidths * 4, LINEHEIGHT), new GUIContent(headerLabel), "WhiteBoldLabel");

                NSTElementComponentEditor.MakeAllNamesUnique(parGO, te);

                EditorGUI.PropertyField(new Rect(r.xMin, currentLine, r.width - 4, LINEHEIGHT), name, new GUIContent(" "));

                currentLine += LINEHEIGHT + 8;
            }
            // The only element that will be found on the root (the actual NST component) is rotation
            else
            {
                EditorGUI.LabelField(new Rect(r.xMin, currentLine, r.width, LINEHEIGHT), new GUIContent("Root Rotation Updates"), "BoldLabel");
                currentLine += LINEHEIGHT + 4;
            }
            EditorGUI.indentLevel = 0;

            // Section for Send Culling enum flags

            left                  = 13;
            realwidth            -= 16;
            sendCullMask.intValue = System.Convert.ToInt32(EditorGUI.EnumMaskField(new Rect(left, currentLine, realwidth, LINEHEIGHT), new GUIContent("Send On Events:"), (SendCullMask)sendCullMask.intValue));
            currentLine          += LINEHEIGHT + 4;

            if (!isRoot.boolValue)
            {
                EditorGUI.PropertyField(new Rect(left, currentLine, realwidth, LINEHEIGHT), gameobject, new GUIContent("GameObject:"));
                currentLine += LINEHEIGHT + 4;
            }

            if (((SendCullMask)sendCullMask.intValue).EveryTick() == false)
            {
                EditorGUI.PropertyField(new Rect(left, currentLine, realwidth, LINEHEIGHT), keyRate, new GUIContent("Key Every:"));
                currentLine += LINEHEIGHT + 2;
            }

            if (keyRate.intValue == 0 && sendCullMask.intValue == 0)
            {
                //noUpdates = true;
                EditorGUI.HelpBox(new Rect(left, currentLine, realwidth, 48), "Element Disabled. Select one or more 'Send On Events' event to trigger on, and/or set Key Every to a number greater than 0.", MessageType.Warning);
                currentLine += 50;

                property.serializedObject.ApplyModifiedProperties();
                return;
            }
            else
            {
                //noUpdates = false;

                EditorGUI.PropertyField(new Rect(left, currentLine, realwidth, LINEHEIGHT), extrapolation, new GUIContent("Extrapolation:"));
                currentLine += LINEHEIGHT + 2;

                EditorGUI.PropertyField(new Rect(left, currentLine, realwidth, LINEHEIGHT), maxExtrapolates, new GUIContent("Max Extrapolations:"));
                currentLine += LINEHEIGHT + 2;

                EditorGUI.PropertyField(new Rect(left, currentLine, realwidth, LINEHEIGHT), teleportOverride, new GUIContent("Teleport Override:"));
                currentLine += LINEHEIGHT + 2;
            }
            property.serializedObject.ApplyModifiedProperties();
            property.serializedObject.Update();

            SerializedProperty crusher = property.FindPropertyRelative("crusher");
            float ch = EditorGUI.GetPropertyHeight(crusher);

            EditorGUI.PropertyField(new Rect(r.xMin, currentLine - 2, r.width, ch), crusher);
            currentLine += ch;

            property.serializedObject.ApplyModifiedProperties();


            SerializedProperty drawerHeight = property.FindPropertyRelative("drawerHeight");

            // revert to original indent level.
            EditorGUI.indentLevel = savedIndentLevel;

            // Record the height of this instance of drawer
            drawerHeight.floatValue = currentLine - r.yMin;

            EditorGUI.EndProperty();
        }
예제 #27
0
 /// <summary>
 ///
 /// </summary>
 public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
 {
     prop.floatValue = PropertyDrawerUtility.ClampedFloatField(pos, FloatAttribute.Label, prop.floatValue, FloatAttribute.Min, FloatAttribute.Max);
 }
예제 #28
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;