コード例 #1
0
            public bool RenderObjectProperties(GUIContent label)
            {
                bool dataChanged = false;

                if (label == null)
                {
                    label = new GUIContent();
                }

                label.text += " (" + this + ")";

                _editorFoldout = EditorGUILayout.Foldout(_editorFoldout, label);

                if (_editorFoldout)
                {
                    int origIndent = EditorGUI.indentLevel;
                    EditorGUI.indentLevel++;

                    _pathPosition = SerializationEditorGUILayout.ObjectField(_pathPosition, new GUIContent("Path Position"), ref dataChanged);

                    EditorGUI.BeginChangeCheck();
                    _speed       = EditorGUILayout.FloatField("Speed", _speed);
                    dataChanged |= EditorGUI.EndChangeCheck();

                    EditorGUI.BeginChangeCheck();
                    _moveThrough = EditorGUILayout.Toggle("Move Through", _moveThrough);
                    dataChanged |= EditorGUI.EndChangeCheck();

                    _faceDirection = SerializationEditorGUILayout.ObjectField(_faceDirection, "Final Face Direction", ref dataChanged);

                    EditorGUI.indentLevel = origIndent;
                }

                return(dataChanged);
            }
コード例 #2
0
            public virtual bool RenderObjectProperties(GUIContent label)
            {
                bool dataChanged = false;

                _editableObject = SerializationEditorGUILayout.ObjectField(_editableObject, label, ref dataChanged);
                return(dataChanged);
            }
コード例 #3
0
                public override bool RenderObjectProperties(GUIContent label)
                {
                    EventSetSaveData evnt = GetEditableObject() as EventSetSaveData;

                    bool dataChanged = false;

                    //Want to render the save data block normally but
                    bool saveDataChanged = false;

                    evnt._saveDataProperty = SerializationEditorGUILayout.ObjectField(evnt._saveDataProperty, GUIContent.none, ref saveDataChanged);

                    //If the save data block or property has changed, update our saved property value node.
                    if (saveDataChanged)
                    {
                        evnt._value = evnt._saveDataProperty.CreateEditorValueInstance();
                        dataChanged = true;
                    }

                    if (evnt._value != null)
                    {
                        evnt._value = SerializationEditorGUILayout.ObjectField(evnt._value, new GUIContent("Value"), ref dataChanged);
                    }

                    return(dataChanged);
                }
コード例 #4
0
            public bool RenderProperty(GUIContent label)
            {
                bool dataChanged = false;

                if (label == null)
                {
                    label = new GUIContent();
                }

                label.text += " (" + this;

                if (_additionalLoadingObjects != null && _additionalLoadingObjects.Length > 0)
                {
                    label.text += " with " + GetAdditionalLoadingObjectsDescription();
                }

                label.text += ")";

                _editorFoldout = EditorGUILayout.Foldout(_editorFoldout, label);

                if (_editorFoldout)
                {
                    int origIndent = EditorGUI.indentLevel;
                    EditorGUI.indentLevel++;


                    _scene = SerializationEditorGUILayout.ObjectField(_scene, "Scene", ref dataChanged);
                    _additionalLoadingObjects = SerializationEditorGUILayout.ObjectField(_additionalLoadingObjects, "Additional Loading Objects", ref dataChanged);

                    EditorGUI.indentLevel = origIndent;
                }

                return(dataChanged);
            }
コード例 #5
0
                public static object PropertyField(object obj, GUIContent label, ref bool dataChanged, GUIStyle style, params GUILayoutOption[] options)
                {
                    GameObjectRef gameObjectRef = (GameObjectRef)obj;

                    if (label == null)
                    {
                        label = new GUIContent();
                    }

                    label.text += " (" + gameObjectRef + ")";

                    bool editorCollapsed = !EditorGUILayout.Foldout(!gameObjectRef._editorCollapsed, label);

                    if (editorCollapsed != gameObjectRef._editorCollapsed)
                    {
                        gameObjectRef._editorCollapsed = editorCollapsed;
                        dataChanged = true;
                    }

                    if (!editorCollapsed)
                    {
                        int origIndent = EditorGUI.indentLevel;
                        EditorGUI.indentLevel++;

                        //Show drop down
                        GameObjectRef.eSourceType sourceType = SerializationEditorGUILayout.ObjectField(gameObjectRef.GetSourceType(), "Source Type", ref dataChanged);

                        if (sourceType != gameObjectRef.GetSourceType())
                        {
                            gameObjectRef = new GameObjectRef(sourceType);
                            dataChanged   = true;
                        }

                        switch (sourceType)
                        {
                        case GameObjectRef.eSourceType.Scene:
                        {
                            RenderSceneGameObjectField(ref gameObjectRef, ref dataChanged);
                        }
                        break;

                        case GameObjectRef.eSourceType.Prefab:
                        {
                            RenderPrefabGameObjectField(ref gameObjectRef, ref dataChanged);
                        }
                        break;

                        case GameObjectRef.eSourceType.Loaded:
                        {
                            RenderLoadedGameObjectField(ref gameObjectRef, ref dataChanged);
                        }
                        break;
                        }

                        EditorGUI.indentLevel = origIndent;
                    }

                    return(gameObjectRef);
                }
コード例 #6
0
                public override bool RenderObjectProperties(GUIContent label)
                {
                    bool dataChanged = RenderEventTime();

                    SerializationEditorGUILayout.ObjectField(GetEditableObject(), "Event Properties", ref dataChanged);

                    return(dataChanged);
                }
コード例 #7
0
            public bool RenderObjectProperties(GUIContent label)
            {
                bool dataChanged = false;

                if (label == null)
                {
                    label = new GUIContent();
                }

                label.text += " (" + this + ")";

                _editorFoldout = EditorGUILayout.Foldout(_editorFoldout, label);

                if (_editorFoldout)
                {
                    int origIndent = EditorGUI.indentLevel;
                    EditorGUI.indentLevel++;

                    eEditorType editorType = (eEditorType)EditorGUILayout.EnumPopup("Position Type", _editorType);

                    if (_editorType != editorType)
                    {
                        _editorType = editorType;
                        _pathNode   = new ComponentRef <PathNode>();
                        _path       = new ComponentRef <Path>();
                        _pathT      = 0.0f;
                        dataChanged = true;
                    }

                    switch (_editorType)
                    {
                    case eEditorType.Node:
                    {
                        _pathNode = SerializationEditorGUILayout.ObjectField(_pathNode, new GUIContent("Path Node"), ref dataChanged);
                    }
                    break;

                    case eEditorType.PathT:
                    {
                        _path = SerializationEditorGUILayout.ObjectField(_path, new GUIContent("Path"), ref dataChanged);

                        EditorGUI.BeginChangeCheck();
                        _pathT = EditorGUILayout.Slider(_pathT, 0.0f, 1.0f);
                        if (EditorGUI.EndChangeCheck())
                        {
                            dataChanged = true;
                        }
                    }
                    break;
                    }

                    EditorGUI.indentLevel = origIndent;
                }

                return(dataChanged);
            }
コード例 #8
0
            public bool RenderObjectProperties(GUIContent label)
            {
                bool dataChanged = false;

                _saveData = SerializationEditorGUILayout.ObjectField(_saveData, GUIContent.none, ref dataChanged);

                EditorGUI.BeginChangeCheck();
                _value       = EditorGUILayout.Toggle("Value", _value);
                dataChanged |= EditorGUI.EndChangeCheck();

                return(dataChanged);
            }
コード例 #9
0
                private static ComponentRef <T> ComponentField <T>(ComponentRef <T> componentRef, GUIContent label, ref bool dataChanged) where T : class
                {
                    if (label == null)
                    {
                        label = new GUIContent();
                    }

                    label.text += " (" + componentRef + ")";

                    bool editorCollapsed = !EditorGUILayout.Foldout(!componentRef._editorCollapsed, label);

                    if (editorCollapsed != componentRef._editorCollapsed)
                    {
                        componentRef._editorCollapsed = editorCollapsed;
                        dataChanged = true;
                    }

                    if (!editorCollapsed)
                    {
                        int origIndent = EditorGUI.indentLevel;
                        EditorGUI.indentLevel++;

                        //Show drop down for gameobject type.
                        GameObjectRef.eSourceType sourceType = SerializationEditorGUILayout.ObjectField(componentRef.GetGameObjectRef().GetSourceType(), "Source Type", ref dataChanged);

                        if (sourceType != componentRef.GetGameObjectRef().GetSourceType())
                        {
                            componentRef = new ComponentRef <T>(sourceType);
                            dataChanged  = true;
                        }

                        switch (sourceType)
                        {
                        case GameObjectRef.eSourceType.Scene:
                            RenderSceneObjectField(ref componentRef, ref dataChanged);
                            break;

                        case GameObjectRef.eSourceType.Prefab:
                            RenderPrefabObjectField(ref componentRef, ref dataChanged);
                            break;

                        case GameObjectRef.eSourceType.Loaded:
                            RenderLoadedObjectField(ref componentRef, ref dataChanged);
                            break;
                        }

                        EditorGUI.indentLevel = origIndent;
                    }


                    return(componentRef);
                }
コード例 #10
0
                private void RenderOutputNode(Node node)
                {
                    Type outputNodeType = SystemUtils.GetGenericImplementationType(typeof(OutputNode <,>), node.GetType(), 1);

                    if (outputNodeType != null)
                    {
                        object value      = node.GetType().GetMethod("GetValue").Invoke(node, new object[] { });
                        bool   guiEnabled = GUI.enabled;
                        GUI.enabled = false;
                        SerializationEditorGUILayout.ObjectField(value, new GUIContent(node._editorDescription + " (" + SystemUtils.GetTypeName(outputNodeType) + ")"));
                        GUI.enabled = guiEnabled;
                    }
                }
コード例 #11
0
            public bool RenderObjectProperties(GUIContent label)
            {
                bool dataChanged = false;

                if (label == null)
                {
                    label = new GUIContent();
                }

                label.text += " (" + this + ")";

                _editorFoldout = EditorGUILayout.Foldout(_editorFoldout, label);

                if (_editorFoldout)
                {
                    int origIndent = EditorGUI.indentLevel;
                    EditorGUI.indentLevel++;

                    _animator = SerializationEditorGUILayout.ObjectField(_animator, new GUIContent("Animator"), ref dataChanged);

                    IAnimator animator = _animator.GetComponent();

                    if (animator != null)
                    {
                        string[] animationNames = animator.GetAnimationNames();
                        int      currentIndex   = -1;

                        for (int i = 0; i < animationNames.Length; i++)
                        {
                            if (animationNames[i] == _animationId)
                            {
                                currentIndex = i;
                                break;
                            }
                        }

                        int index = EditorGUILayout.Popup("Animation", currentIndex == -1 ? 0 : currentIndex, animationNames);

                        if (currentIndex != index)
                        {
                            _animationId = animationNames[index];
                            dataChanged  = true;
                        }
                    }

                    EditorGUI.indentLevel = origIndent;
                }

                return(dataChanged);
            }
コード例 #12
0
            public bool RenderProperty(GUIContent label)
            {
                bool dataChanged = false;

                _animation = SerializationEditorGUILayout.ObjectField(_animation, new GUIContent("Animation"), ref dataChanged);
                _holdType  = SerializationEditorGUILayout.ObjectField(_holdType, "Play Mode", ref dataChanged);

                if (_holdType == eHoldType.Time)
                {
                    EditorGUI.BeginChangeCheck();
                    _holdTime    = EditorGUILayout.FloatField("Hold Time", _holdTime);
                    dataChanged |= EditorGUI.EndChangeCheck();
                }

                return(dataChanged);
            }
コード例 #13
0
            public bool RenderObjectProperties(GUIContent label)
            {
                bool dataChanged = false;

                if (label == null)
                {
                    label = new GUIContent();
                }

                label.text += " (" + (typeof(T) == typeof(float) ? "float" : typeof(T).Name) + ")";

                _editorFoldout = EditorGUILayout.Foldout(_editorFoldout, label);
                if (_editorFoldout)
                {
                    int origIndent = EditorGUI.indentLevel;
                    EditorGUI.indentLevel++;

                    _sourceType = SerializationEditorGUILayout.ObjectField(_sourceType, new GUIContent("Input Type", "Static: Value will be constant.\nNode: Value read from other nodes output."), ref dataChanged);
                    if (dataChanged)
                    {
                        ClearStaticValue();
                        _sourceNodeId = -1;
                    }

                    switch (_sourceType)
                    {
                    case eSourceType.Static:
                    {
                        SerializationEditorGUILayout.RenderObjectMemebers(this, GetType(), ref dataChanged);
                    }
                    break;

                    case eSourceType.Node:
                    {
                        dataChanged |= DrawNodeNamePopUps();
                    }
                    break;
                    }

                    EditorGUI.indentLevel = origIndent;
                }

                return(dataChanged);
            }
コード例 #14
0
                public static object PropertyField(object obj, GUIContent label, ref bool dataChanged, GUIStyle style, params GUILayoutOption[] options)
                {
                    Condition currentConditional = (Condition)obj;
                    Condition conditional        = DrawAddConditionalDropDown("Condition", currentConditional);

                    if (conditional != currentConditional)
                    {
                        dataChanged = true;
                    }

                    int origIndent = EditorGUI.indentLevel;

                    EditorGUI.indentLevel++;

                    if (conditional != null)
                    {
                        conditional = DrawToggle(conditional, ref dataChanged);

                        bool editorCollapsed = !EditorGUILayout.Foldout(!conditional._editorCollapsed, "Properties");

                        if (editorCollapsed != conditional._editorCollapsed)
                        {
                            conditional._editorCollapsed = editorCollapsed;
                            dataChanged = true;
                        }

                        if (!editorCollapsed)
                        {
                            EditorGUI.indentLevel++;

                            conditional = (Condition)SerializationEditorGUILayout.RenderObjectMemebers(conditional, conditional.GetType(), ref dataChanged);

                            EditorGUI.indentLevel--;
                        }
                    }

                    EditorGUI.indentLevel = origIndent;

                    return(conditional);
                }
コード例 #15
0
                public static ComponentMethodRef <T> ComponentMethodRefField <T>(ComponentMethodRef <T> componentMethodRef, Type returnType, GUIContent label, ref bool dataChanged)
                {
                    if (label == null)
                    {
                        label = new GUIContent();
                    }

                    label.text += " (" + componentMethodRef + ")";

                    bool editorCollapsed = !EditorGUILayout.Foldout(!componentMethodRef._editorCollapsed, label);

                    if (editorCollapsed != componentMethodRef._editorCollapsed)
                    {
                        componentMethodRef._editorCollapsed = editorCollapsed;
                        dataChanged = true;
                    }

                    if (!editorCollapsed)
                    {
                        int origIndent = EditorGUI.indentLevel;
                        EditorGUI.indentLevel++;

                        bool componentChanged = false;
                        ComponentRef <Component> component = SerializationEditorGUILayout.ObjectField(componentMethodRef.GetComponentRef(), new GUIContent("Object"), ref componentChanged);

                        Component currentComponent = component.GetBaseComponent();

                        if (currentComponent != null)
                        {
                            string[] methodNames = GetMethods(currentComponent, returnType);

                            if (methodNames.Length > 0)
                            {
                                int currentIndex = 0;

                                for (int i = 0; i < methodNames.Length; i++)
                                {
                                    if (methodNames[i] == componentMethodRef.GetMethodName())
                                    {
                                        currentIndex = i;
                                        break;
                                    }
                                }

                                EditorGUI.BeginChangeCheck();

                                int newIndex = EditorGUILayout.Popup("Method", currentIndex, methodNames);

                                if (EditorGUI.EndChangeCheck() || componentChanged)
                                {
                                    componentMethodRef = new ComponentMethodRef <T>(component, methodNames[newIndex]);
                                    dataChanged        = true;
                                }
                            }
                            else if (componentChanged)
                            {
                                componentMethodRef = new ComponentMethodRef <T>(component, string.Empty);
                                dataChanged        = true;
                            }
                        }
                        else if (componentChanged)
                        {
                            componentMethodRef = new ComponentMethodRef <T>(component, string.Empty);
                            dataChanged        = true;
                        }

                        EditorGUI.indentLevel = origIndent;
                    }

                    return(componentMethodRef);
                }
コード例 #16
0
            //TO DO! Make reorder able.

            #region SerializedObjectEditor
            public static object PropertyField(object obj, GUIContent label, ref bool dataChanged, GUIStyle style, params GUILayoutOption[] options)
            {
                IList list     = (IList)obj;
                Type  listType = SystemUtils.GetGenericImplementationType(typeof(List <>), obj.GetType());

                label.text += " (" + SystemUtils.GetTypeName(listType) + ")";

                bool editorFoldout = EditorGUILayout.Foldout(true, label);

                if (editorFoldout)
                {
                    int origIndent = EditorGUI.indentLevel;
                    EditorGUI.indentLevel++;

                    int origLength = list != null ? list.Count : 0;

                    int length = EditorGUILayout.IntField("Length", origLength);
                    length = Math.Max(length, 0);

                    if (length < origLength)
                    {
                        while (origLength > length)
                        {
                            list.RemoveAt(list.Count - 1);
                            origLength--;
                        }

                        dataChanged = true;
                    }
                    else if (length > origLength)
                    {
                        while (origLength < length)
                        {
                            object listItem = null;

                            if (!listType.IsInterface && !listType.IsAbstract)
                            {
                                listItem = Activator.CreateInstance(listType, true);
                            }

                            list.Add(listItem);
                            origLength++;
                        }

                        dataChanged = true;
                    }

                    if (!dataChanged && list != null)
                    {
                        for (int i = 0; i < list.Count; i++)
                        {
                            bool   elementChanged = false;
                            object elementObj     = list[i];
                            Type   elementType    = elementObj != null?elementObj.GetType() : listType;

                            elementObj = SerializationEditorGUILayout.ObjectField(elementObj, elementType, new GUIContent("Element " + i), ref elementChanged, style, options);
                            if (elementChanged)
                            {
                                list[i]     = elementObj;
                                dataChanged = true;
                            }
                        }
                    }

                    EditorGUI.indentLevel = origIndent;
                }

                return(obj);
            }
コード例 #17
0
                public static object PropertyField(object obj, GUIContent label, ref bool dataChanged, GUIStyle style, params GUILayoutOption[] options)
                {
                    Condition currentConditional = (Condition)obj;
                    Condition conditional        = ConditionEditor.DrawAddConditionalDropDown("Condition", currentConditional);

                    if (conditional != currentConditional)
                    {
                        dataChanged = true;
                    }

                    int origIndent = EditorGUI.indentLevel;

                    EditorGUI.indentLevel++;

                    if (conditional != null)
                    {
                        conditional = ConditionEditor.DrawToggle(conditional, ref dataChanged);

                        bool editorCollapsed = !EditorGUILayout.Foldout(!conditional._editorCollapsed, "Properties");

                        if (editorCollapsed != conditional._editorCollapsed)
                        {
                            conditional._editorCollapsed = editorCollapsed;
                            dataChanged = true;
                        }

                        if (!editorCollapsed)
                        {
                            EditorGUI.indentLevel++;

                            ConditionSaveDataEnum saveDataEnum = conditional as ConditionSaveDataEnum;

                            if (saveDataEnum != null)
                            {
                                //Save data type (only show enum properties)
                                saveDataEnum._saveData = SerializationEditorGUILayout.ObjectField(saveDataEnum._saveData, GUIContent.none, ref dataChanged);

                                //Possible values
                                Type enumType = saveDataEnum.GetEnumType();

                                if (enumType != null)
                                {
                                    Enum enm = (Enum)Enum.ToObject(enumType, saveDataEnum._value);
                                    EditorGUI.BeginChangeCheck();
                                    saveDataEnum._enumValue = EditorGUILayout.EnumPopup("Value", enm);
                                    if (EditorGUI.EndChangeCheck())
                                    {
                                        saveDataEnum._value = Convert.ToInt32(saveDataEnum._enumValue);
                                        dataChanged         = true;
                                    }
                                }
                                else
                                {
                                    saveDataEnum._enumValue = null;
                                    saveDataEnum._value     = -1;
                                }
                            }
                            else
                            {
                                conditional = (Condition)SerializationEditorGUILayout.RenderObjectMemebers(conditional, conditional.GetType(), ref dataChanged);
                            }

                            EditorGUI.indentLevel--;
                        }
                    }

                    EditorGUI.indentLevel = origIndent;

                    return(conditional);
                }
コード例 #18
0
                public static object PropertyField(object obj, GUIContent label, ref bool dataChanged, GUIStyle style, params GUILayoutOption[] options)
                {
                    MaterialRef materialRef = (MaterialRef)obj;

                    if (label == null)
                    {
                        label = new GUIContent();
                    }

                    label.text += " (" + materialRef + ")";

                    bool editorCollapsed = !EditorGUILayout.Foldout(!materialRef._editorCollapsed, label);

                    if (editorCollapsed != materialRef._editorCollapsed)
                    {
                        materialRef._editorCollapsed = editorCollapsed;
                        dataChanged = true;
                    }

                    if (!editorCollapsed)
                    {
                        int origIndent = EditorGUI.indentLevel;
                        EditorGUI.indentLevel++;

                        eEdtiorType editorType = materialRef.GetMaterialIndex() == -1 ? eEdtiorType.Shared : eEdtiorType.Instanced;


                        //Draw type dropdown
                        {
                            EditorGUI.BeginChangeCheck();
                            editorType = (eEdtiorType)EditorGUILayout.EnumPopup("Material Type", editorType);

                            if (EditorGUI.EndChangeCheck())
                            {
                                dataChanged = true;
                                materialRef = new MaterialRef(editorType == eEdtiorType.Shared ? -1 : 0);
                            }
                        }

                        //Draw renderer field
                        if (editorType == eEdtiorType.Instanced)
                        {
                            bool renderChanged = false;
                            ComponentRef <Renderer> rendererComponentRef = SerializationEditorGUILayout.ObjectField(materialRef.GetRenderer(), new GUIContent("Renderer"), ref renderChanged);

                            if (renderChanged)
                            {
                                dataChanged = true;
                                materialRef = new MaterialRef(rendererComponentRef, 0);
                            }

                            //Show drop down for materials
                            Renderer renderer = rendererComponentRef.GetComponent();

                            if (renderer != null)
                            {
                                string[] materialNames = new string[renderer.sharedMaterials.Length];

                                for (int i = 0; i < materialNames.Length; i++)
                                {
                                    materialNames[i] = renderer.sharedMaterials[i].name;
                                }

                                EditorGUI.BeginChangeCheck();
                                int materialIndex = EditorGUILayout.Popup("Material", materialRef.GetMaterialIndex(), materialNames);
                                if (EditorGUI.EndChangeCheck())
                                {
                                    dataChanged = true;
                                    materialRef = new MaterialRef(rendererComponentRef, materialIndex);
                                }
                            }
                        }
                        else
                        {
                            bool assetChanged            = false;
                            AssetRef <Material> assetRef = SerializationEditorGUILayout.ObjectField(materialRef.GetAsset(), new GUIContent("Material"), ref assetChanged);

                            if (assetChanged)
                            {
                                dataChanged = true;
                                materialRef = new MaterialRef(assetRef);
                            }
                        }

                        EditorGUI.indentLevel = origIndent;
                    }


                    return(materialRef);
                }
コード例 #19
0
                public override bool RenderObjectProperties(GUIContent label)
                {
                    EditorGUI.BeginChangeCheck();
                    GetEditableObject()._editorDescription = EditorGUILayout.DelayedTextField("Editor Description", GetEditableObject()._editorDescription);

                    bool dataChanged = EditorGUI.EndChangeCheck();

                    //Render Inputs
                    bool renderedFirstInput = false;
                    {
                        foreach (NodeEditorField input in _inputNodeFields)
                        {
                            if (!renderedFirstInput)
                            {
                                EditorGUILayout.Separator();
                                EditorGUILayout.LabelField("Inputs", EditorStyles.boldLabel);
                                EditorGUILayout.Separator();
                                renderedFirstInput = true;
                            }

                            string           fieldName       = StringUtils.FromCamelCase(input._name);
                            TooltipAttribute fieldToolTipAtt = SystemUtils.GetAttribute <TooltipAttribute>(input._fieldInfo);
                            GUIContent       labelContent    = fieldToolTipAtt != null ? new GUIContent(fieldName, fieldToolTipAtt.tooltip) : new GUIContent(fieldName);

                            bool   fieldChanged    = false;
                            object nodeFieldObject = input.GetValue();
                            nodeFieldObject = SerializationEditorGUILayout.ObjectField(nodeFieldObject, labelContent, ref fieldChanged);
                            if (fieldChanged)
                            {
                                dataChanged = true;
                                input.SetValue(nodeFieldObject);
                            }
                        }
                    }

                    //Render other properties
                    bool renderedFirstProperty = false;

                    {
                        SerializedObjectMemberInfo[] serializedFields = SerializedObjectMemberInfo.GetSerializedFields(GetEditableObject().GetType());
                        foreach (SerializedObjectMemberInfo serializedField in serializedFields)
                        {
                            if (!serializedField.HideInEditor() && !SystemUtils.IsSubclassOfRawGeneric(typeof(NodeInputFieldBase <>), serializedField.GetFieldType()))
                            {
                                if (!renderedFirstProperty)
                                {
                                    EditorGUILayout.Separator();
                                    EditorGUILayout.LabelField("Properties", EditorStyles.boldLabel);
                                    EditorGUILayout.Separator();
                                    renderedFirstProperty = true;
                                }

                                string           fieldName       = StringUtils.FromCamelCase(serializedField.GetID());
                                TooltipAttribute fieldToolTipAtt = SystemUtils.GetAttribute <TooltipAttribute>(serializedField);
                                GUIContent       labelContent    = fieldToolTipAtt != null ? new GUIContent(fieldName, fieldToolTipAtt.tooltip) : new GUIContent(fieldName);

                                bool   fieldChanged    = false;
                                object nodeFieldObject = serializedField.GetValue(GetEditableObject());
                                nodeFieldObject = SerializationEditorGUILayout.ObjectField(nodeFieldObject, labelContent, ref fieldChanged);
                                if (fieldChanged)
                                {
                                    dataChanged = true;
                                    serializedField.SetValue(GetEditableObject(), nodeFieldObject);
                                }
                            }
                        }
                    }

                    return(dataChanged);
                }
コード例 #20
0
                public override bool RenderObjectProperties(GUIContent label)
                {
                    bool dataChanged = false;

                    ConditionalState conditionalState = (ConditionalState)GetEditableObject();
                    Color            orig             = GUI.backgroundColor;

                    dataChanged |= RenderStateDescriptionField();
                    dataChanged |= RenderStateColorField();

                    EditorGUILayout.Separator();

                    #region Render Brances
                    EditorGUILayout.LabelField("State Exit Conditions:", EditorStyles.boldLabel);
                    EditorGUILayout.Separator();

                    if (conditionalState._branches != null)
                    {
                        for (int i = 0; i < conditionalState._branches.Length; i++)
                        {
                            GUI.backgroundColor = _titleLabelColor;
                            EditorGUILayout.LabelField(GetConditionLabel(conditionalState._branches[i], i == 0), EditorUtils.TextTitleStyle, GUILayout.Height(24.0f));
                            GUI.backgroundColor = orig;

                            //Draw condition properties
                            SerializationEditorGUILayout.ObjectField(conditionalState._branches[i], string.Empty, ref dataChanged);

                            if (DrawEditConditionsButtons(i))
                            {
                                dataChanged = true;
                                break;
                            }
                        }
                    }

                    dataChanged |= DrawAddConditionButton();
                    #endregion

                    EditorGUILayout.Separator();
                    EditorGUILayout.Separator();

                    #region Render Background Logic Threads
                    EditorGUILayout.LabelField("Background Logic:", EditorStyles.boldLabel);
                    EditorGUILayout.Separator();

                    if (conditionalState._backgroundLogic != null)
                    {
                        for (int i = 0; i < conditionalState._backgroundLogic.Length; i++)
                        {
                            ConditionalStateBackgroundLogic backgroundLogic = conditionalState._backgroundLogic[i];

                            GUI.backgroundColor = _titleLabelColor;
                            EditorGUILayout.LabelField(backgroundLogic.GetDescription(), EditorUtils.TextTitleStyle, GUILayout.Height(24.0f));
                            GUI.backgroundColor = orig;

                            //Draw backgroundLogic properties
                            {
                                int origIndent = EditorGUI.indentLevel;
                                EditorGUI.indentLevel++;

                                backgroundLogic = SerializationEditorGUILayout.ObjectField(backgroundLogic, "", ref dataChanged);

                                EditorGUI.indentLevel = origIndent;
                            }

                            if (DrawEditBackgroundLogicButtons(i))
                            {
                                dataChanged = true;
                                break;
                            }
                        }
                    }

                    dataChanged |= DrawAddBackgroundLogicButton();
                    #endregion

                    return(dataChanged);
                }
コード例 #21
0
            public bool RenderObjectProperties(GUIContent label)
            {
                bool dataChanged = false;

                _gameObject     = SerializationEditorGUILayout.ObjectField(_gameObject, "Game Object", ref dataChanged);
                _transformFlags = SerializationEditorGUILayout.ObjectField(_transformFlags, "Transform Flags", ref dataChanged);
                _moveType       = SerializationEditorGUILayout.ObjectField(_moveType, "Move Type", ref dataChanged);
                _easeType       = SerializationEditorGUILayout.ObjectField(_easeType, "Ease Type", ref dataChanged);

                EditorGUI.BeginChangeCheck();
                _duration    = EditorGUILayout.FloatField("Duration", _duration);
                dataChanged |= EditorGUI.EndChangeCheck();

                bool targetChanged = false;

                _targetType = SerializationEditorGUILayout.ObjectField(_targetType, "Target Type", ref targetChanged);
                if (targetChanged)
                {
                    dataChanged = true;

                    _targetTransform = new GameObjectRef();
                    _targetPosition  = Vector3.zero;
                    _targetRotation  = Quaternion.identity;
                    _targetScale     = Vector3.one;
                }

                switch (_targetType)
                {
                case eTargetType.Transform:
                {
                    _targetTransform = SerializationEditorGUILayout.ObjectField(_targetTransform, new GUIContent("Target Type"), ref dataChanged);
                }
                break;

                case eTargetType.LocalDelta:
                case eTargetType.LocalTarget:
                case eTargetType.WorldDelta:
                case eTargetType.WorldTarget:
                {
                    if ((_transformFlags & eTransformFlag.Translate) != 0)
                    {
                        EditorGUI.BeginChangeCheck();
                        _targetPosition = EditorGUILayout.Vector3Field("Translation", _targetPosition);
                        dataChanged    |= EditorGUI.EndChangeCheck();
                    }
                    if ((_transformFlags & eTransformFlag.Rotate) != 0)
                    {
                        EditorGUI.BeginChangeCheck();
                        _targetRotation.eulerAngles = EditorGUILayout.Vector3Field("Rotation", _targetRotation.eulerAngles);
                        dataChanged |= EditorGUI.EndChangeCheck();
                    }
                    if ((_transformFlags & eTransformFlag.Scale) != 0)
                    {
                        EditorGUI.BeginChangeCheck();
                        _targetScale = EditorGUILayout.Vector3Field("Scale", _targetScale);
                        dataChanged |= EditorGUI.EndChangeCheck();
                    }
                }
                break;
                }


                return(dataChanged);
            }