예제 #1
0
 public void SetSceneGameObject(GameObject gameObject)
 {
     if (gameObject != null && gameObject.scene.IsValid())
     {
         _editorGameObject = gameObject;
         _scene.SetScene(gameObject.scene);
         _objectName    = gameObject.name;
         _sceneObjectID = SceneIndexer.GetIdentifier(gameObject);
     }
     else
     {
         ClearGameObject();
     }
 }
예제 #2
0
            public void SetLoadedGameObject(GameObjectLoader loader, GameObject gameObject)
            {
                if (loader != null)
                {
                    _scene.SetScene(loader.gameObject.scene);
                    _sceneObjectID          = SceneIndexer.GetIdentifier(loader.gameObject);
                    _editorLoaderGameObject = loader;

                    if (gameObject != null && GameObjectUtils.IsChildOf(gameObject.transform, loader.transform))
                    {
                        _objectName       = GameObjectUtils.GetChildFullName(gameObject, loader.gameObject);
                        _editorGameObject = gameObject;
                    }
                    else
                    {
                        _objectName       = null;
                        _editorGameObject = null;
                    }
                }
                else
                {
                    ClearGameObject();
                }
            }
예제 #3
0
            public GameObjectRef(eSourceType sourceType, GameObject gameObject)
            {
                _sourceType      = sourceType;
                _sourceObject    = null;
                _editorCollapsed = false;
                _prefab          = new AssetRef <GameObject>();
                _scene           = new SceneRef();
                _gameObject      = gameObject;

                switch (sourceType)
                {
                case eSourceType.Prefab:
                {
                    GameObject prefabAsset = (GameObject)PrefabUtility.GetPrefabParent(gameObject);

                    if (prefabAsset != null)
                    {
                        gameObject = prefabAsset;
                    }

                    //Then find its root
                    GameObject prefabRoot = PrefabUtility.FindPrefabRoot(gameObject);

                    if (prefabRoot != null)
                    {
                        _objectName = GameObjectUtils.GetChildFullName(gameObject, prefabRoot);
                        _prefab     = new AssetRef <GameObject>(prefabRoot);
                    }
                    else
                    {
                        _objectName = string.Empty;
                    }

                    _sceneObjectID = -1;
                }
                break;

                case eSourceType.Loaded:
                {
                    GameObjectLoader loader = gameObject.GetComponentInParent <GameObjectLoader>();

                    if (loader != null)
                    {
                        _scene         = new SceneRef(loader.gameObject.scene);
                        _sceneObjectID = SceneIndexer.GetIdentifier(loader.gameObject);

                        if (gameObject != null && GameObjectUtils.IsChildOf(gameObject.transform, loader.transform))
                        {
                            _objectName = GameObjectUtils.GetChildFullName(gameObject, loader.gameObject);
                        }
                        else
                        {
                            _objectName = null;
                        }
                    }
                    else
                    {
                        _objectName    = null;
                        _sceneObjectID = -1;
                    }
                }
                break;

                default:
                case eSourceType.Scene:
                {
                    if (gameObject != null && gameObject.scene.IsValid())
                    {
                        _scene         = new SceneRef(gameObject.scene);
                        _objectName    = gameObject.name;
                        _sceneObjectID = SceneIndexer.GetIdentifier(gameObject);
                    }
                    else
                    {
                        _objectName    = string.Empty;
                        _sceneObjectID = -1;
                    }
                }
                break;
                }
            }