public void Open() { PushElement(); if (popupStack == null) { popupStack = base.FindStack(); if (popupStack == null) { Debug.LogError("Couldn't find Game Object Stack to push to!"); return; } } popupWindow = popupStack.GetComponentInChildren <PopupWindow>(); popupWindow.CompleteTitle(titleText, titleUseLoc, titleToUpper); popupWindow.SetCloseButtonActive(showCloseButton, showCloseButton ? onCloseButtonClicked : null); popupWindow.CompleteContent(contentText, contentUseLoc, contentToUpper); foreach (var data in btnData) { popupWindow.CompleteButton(data.btnText, data.btnUseLoc, data.btnToUpper, data.btnClick); } }
public void HandleCloseButtonClicked() { GameObjectStackElement element = GetComponentInParent <GameObjectStackElement>(); GameObjectStack stack = element.GetComponentInParent <GameObjectStack>(); if (stack.stack.Count > 0 && stack.stack[stack.stack.Count - 1] == element) { stack.PopTopElement(); if (onCloseClicked != null) { onCloseClicked.Invoke(); } } }
public void PushElement() { GameObjectStack stack = FindStack(); if (stack == null) { return; } if (popFirst) { stack.PopTopElement(); } stack.SpawnObject(prefab); }
GameObjectStack FindStack() { Transform stackSearchObj = transform; while (stackSearchObj != null) { GameObjectStack foundStack = stackSearchObj.GetComponent <GameObjectStack>(); if (foundStack != null && (string.IsNullOrEmpty(stackId) || stackId == foundStack.id)) { return(foundStack); } stackSearchObj = stackSearchObj.parent; } return(null); }
void FindStack() { Transform elementSearchObj = transform; Transform stackSearchObj = elementSearchObj.parent; while (stack == null && stackSearchObj != null) { GameObjectStack foundStack = stackSearchObj.GetComponent <GameObjectStack>(); if (foundStack != null && (string.IsNullOrEmpty(stackId) || stackId == foundStack.id)) { stack = foundStack; element = elementSearchObj.GetComponent <GameObjectStackElement>(); return; } elementSearchObj = stackSearchObj; stackSearchObj = elementSearchObj.parent; } }
public void PopTopElement() { GameObjectStack stack = FindStack(); if (stack == null) { return; } if (all) { while (stack.stack.Count > 0) { stack.PopTopElement(); } } else { stack.PopTopElement(); } }
protected GameObjectStack FindStack() { Transform stackSearchObj = transform; while (stackSearchObj != null) { GameObjectStack foundStack = stackSearchObj.GetComponent <GameObjectStack>(); if (foundStack != null && (string.IsNullOrEmpty(stackId) || stackId == foundStack.id)) { return(foundStack); } stackSearchObj = stackSearchObj.parent; } // not found, so look elsewhere int sceneCount = UnityEngine.SceneManagement.SceneManager.sceneCount; for (int i = 0; i < sceneCount; i++) { GameObject[] goList = UnityEngine.SceneManagement.SceneManager.GetSceneAt(i).GetRootGameObjects(); if (goList != null && goList.Length > 0) { for (int j = 0; j < goList.Length; j++) { GameObjectStack[] stacks = goList[j].GetComponentsInChildren <GameObjectStack>(); foreach (var stack in stacks) { if (stack.id == stackId) { return(stack); } } } } } return(null); }