/// <summary> /// will set the current Parent aswell as adding this object to the parents children. /// Returns the hirachy child index as list starting from the parent object /// </summary> protected virtual Stack <int> setParent() { Stack <int> result = new Stack <int>(); result.Push(transform.GetSiblingIndex()); Transform current = transform.parent; parent = null; if (current != null) { do { ///this will not work for scene root objects in standalone build!!! ///scenes must be setup with only one root element only!! int currentSiblingIndex = current.GetSiblingIndex(); ///add current non saved object sibling index to parent stack trace result.Push(currentSiblingIndex); this.parent = current.GetComponent <BaseSaveableGameObject>(); current = current.parent; } while (current != null && parent == null); } if (parent != null) { ///if the parent is not null, the sibling index of the parent is removed from the stack ///as its not needed to find its own child //Debug.Log("Transform has parent so the last index is deleted"); result.Pop(); parent.addChildren(this, result); } return(result); }
public static void removeObjectFromSavedList(ISaveableGameObject gameObject) { SaveableScene currentScene = GetCurrentGame().CurrentScene; currentScene.AllInGameObjects.Remove(gameObject); }
public static void addObjectToCurrentScene(ISaveableGameObject gameObject) { SaveableScene currentScene = GetCurrentGame().CurrentScene; currentScene.AllInGameObjects.Add(gameObject); }
/// <summary> /// will add the children to the dictionary /// </summary> /// <param name="child">element to add</param> /// <param name="childpath">children path of gameObjects names to real parent</param> public void addChildren(ISaveableGameObject child, Stack <int> childpath) { childrenWithPath.add(child, childpath); }