private static void DoIterate(GameObject gameObject, ChildHandler childHandler, bool recursive) { foreach (Transform child in gameObject.transform) { childHandler(child.gameObject); if (recursive) DoIterate(child.gameObject, childHandler, true); } }
public void Invoke(BSNavItem sender) { ActiveChild = sender; if (IsTabs) { TabRender?.Render(); } ChildHandler?.Invoke(sender); }
/// <summary> /// Recursively iterates the object tree /// </summary> /// <param name="gameObject">Game object to iterate</param> /// <param name="childHandler">A handler function on node</param> /// <param name="recursive">Do it on recursively on children?</param> /// <remarks>NOTE: Recursive!!!</remarks> private static void DoIterate(GameObject gameObject, ChildHandler childHandler, bool recursive) { foreach (Transform child in gameObject.transform) { childHandler(child.gameObject); if (recursive) { DoIterate(child.gameObject, childHandler, true); } } }
public void Interact(InteractController controller) { ChildHandler childHandler = controller.GetComponentInChildren <ChildHandler>(); if (childHandler.isEquipped) { Task task = TaskManager.instance.TaskExists(GameManager.TaskType.BABYSTEAL); if (task) { Debug.Log("Kid has been napped"); childHandler.Destroy(); task.Accomplish(); } } }
public void Interact(InteractController controller) { ChildHandler childHandler = controller.GetComponentInChildren <ChildHandler>(); ChildHandler currentHandler = GetComponentInParent <ChildHandler>(); playerController = controller.GetComponent <PlayerController>(); if (currentHandler && currentHandler.isEquipped && currentHandler != childHandler) { currentHandler.Remove(); } if (childHandler.isEquipped) { childHandler.Remove(); return; } childHandler.Equip(this); }
public void Interact(InteractController controller) { ChildHandler childHandler = controller.GetComponentInChildren <ChildHandler>(); if (childHandler.isEquipped) { Task task = TaskManager.instance.TaskExists(GameManager.TaskType.BABYSTEAL); if (task) { feedbackText = Instantiate(feedbackTextPrefab, feedbackContainer.transform); feedbackText.GetComponent <Text>().text = "Kid has been napped"; Destroy(feedbackText, 5.0f); childHandler.Destroy(); task.Accomplish(); } else { feedbackText = Instantiate(feedbackTextPrefab, feedbackContainer.transform); feedbackText.GetComponent <Text>().text = "Not now man! Now is not the time for that!"; Destroy(feedbackText, 5.0f); } } }
/// <summary> /// Iterates all children of a game object /// </summary> /// <param name="gameObject">A root game object</param> /// <param name="childHandler">A function to execute on each child</param> /// <param name="recursive">Do it on recursively on children?</param> public static void IterateChildren(GameObject gameObject, ChildHandler childHandler, bool recursive) { DoIterate(gameObject, childHandler, recursive); }