private void ConnectParent() { // set parent if (Container.Parent == null) { // context from object hierarchy GameObjectContext goContext = null; if (transform.parent != null) { goContext = transform.parent.GetComponentInParent <GameObjectContext>(); } if (goContext != null) { Container.Parent = goContext.GetContainer(); } else { // scene's context if one exists SceneContext sceneContext; if (SceneContext.TryGetSceneContext(gameObject.scene.path, out sceneContext)) { Container.Parent = sceneContext.GetContainer(); } // fallback to project's context else { Container.Parent = ProjectContext.Instance.GetContainer(); } } } }
public static bool TryGetSceneContext(string scenePath, out SceneContext sceneContext) { return(s_sceneContexts.TryGetValue(scenePath, out sceneContext)); }