Esempio n. 1
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);
                }