Exemplo n.º 1
0
            public void SetPrefabGameObject(GameObject gameObject)
            {
                GameObject prefabRoot = PrefabUtility.FindPrefabRoot(gameObject);

                UnityEngine.Object prefabObj = PrefabUtility.GetPrefabParent(gameObject);
                if (prefabObj == null)
                {
                    prefabObj = PrefabUtility.GetPrefabObject(prefabRoot);
                }

                if (prefabRoot != null && prefabObj != null)
                {
                    _objectName       = GameObjectUtils.GetChildFullName(gameObject, prefabRoot);
                    _editorGameObject = gameObject;

                    string prefabPath = AssetDatabase.GetAssetPath(prefabObj);
                    _prefab.SetAsset(prefabPath);
                }
                else
                {
                    ClearGameObject();
                }
            }
Exemplo n.º 2
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++;

                    eType type = (eType)EditorGUILayout.EnumPopup("Link Type", _editorLinkType);

                    //If link type changed, clear info
                    if (_editorLinkType != type)
                    {
                        _editorLinkType = type;
                        _file.ClearAsset();
                        _stateId         = -1;
                        _timelineState   = null;
                        _editorStateName = null;
                        dataChanged      = true;
                    }

                    switch (_editorLinkType)
                    {
                    case eType.Internal:
                    {
                        dataChanged |= DrawStateNamePopUps();
                    }
                    break;

                    case eType.External:
                    {
                        TextAsset asset = EditorGUILayout.ObjectField("File", _file._editorAsset, typeof(TextAsset), false) as TextAsset;

                        //If asset changed update GUIDS
                        if (_file._editorAsset != asset)
                        {
                            _file._editorAsset = asset;

                            _file.ClearAsset();
                            _stateId         = -1;
                            _timelineState   = null;
                            _editorStateName = null;

                            if (asset != null)
                            {
                                _file.SetAsset(asset);
                            }

                            dataChanged = true;
                        }

                        if (_file._editorAsset != null)
                        {
                            dataChanged |= DrawStateNamePopUps();
                        }
                    }
                    break;
                    }

                    EditorGUI.indentLevel = origIndent;
                }

                return(dataChanged);
            }