private void AddBMenu() { #if UNITY_EDITOR BMenu objectPrefab = Resources.Load <BMenu>(BConsts.PATH_BMenu); if (objectPrefab) { BMenu spawnedObject = Instantiate(objectPrefab); if (spawnedObject) { spawnedObject.UIElementName = newBMenuName; spawnedObject.Revalidate(); // Set this object as parent spawnedObject.transform.parent = transform; spawnedObject.transform.localPosition = Vector3.zero; // Set spawned object as selected Selection.SetActiveObjectWithContext(spawnedObject, Selection.activeContext); Revalidate(); } else { Debug.LogError("Couldn't spawn object!"); } } else { Debug.LogError("The 'BMenu' prefab was not found in the Resources folder!"); } #endif }
public void SetStartHighlightedBMenu(BMenu bMenu) { if (IS_NOT_NULL(bMenu)) { startHighlightedBMenu = bMenu; } }
public void UpdateCurrentBMenu(BMenu newBBMenu) { if ((IS_NOT_NULL(newBBMenu)) && (IS_VALUE_CONTAINED(childrenBMenus, newBBMenu))) { highlightedBMenuReference = newBBMenu; highlightedBMenuReference.OnBecameActive(); // Deactivate all other BMenu foreach (BMenu bMenu in childrenBMenus) { // Prevent deactivating BMenus from nested BFrames if (bMenu.ParentBFrame == this) { if (bMenu == highlightedBMenuReference) { bMenu.OnBecameActive(); } else { bMenu.OnBecameInactive(); } } } } }
protected override void OnValidate() { base.OnValidate(); if (CanValidate() == false) { return; } // Update GameObject name if (overrideGameOjbectName == true) { gameObject.name = objectNamePrefix + uIElementName + UINameExtension; } // Find BFrame and BMenu in parents //parentBFrame = null; parentBFrame = GetComponentInParent <BFrame>(); //BFrame newParentFrame = GetComponentInParent<BFrame>(); //if (newParentFrame != this) //{ // parentBFrame = GetComponentInParent<BFrame>(); //} parentBMenu = GetComponentInParent <BMenu>(); //parentBMenu = null; //BMenu newparentMenu = GetComponentInParent<BMenu>(); //if (newparentMenu != this) //{ // parentBMenu = GetComponentInParent<BMenu>(); //} // Revalidate children UI Elements (only direct children. Revalidation will be propagated if they have revalidateAllDirectChildren set to true) if (revalidateAllDirectChildren) { for (int i = 0; i < transform.childCount; i++) { if ((transform) && (transform.GetChild(i)) && (transform.GetChild(i).GetComponent <BUIElement>())) { if (propagateUINameToChildren) { transform.GetChild(i).GetComponent <BUIElement>().UIElementName = UIElementName; } transform.GetChild(i).GetComponent <BUIElement>().Revalidate(); } } } }
protected override void InitializeComponents() { base.InitializeComponents(); // Get all children BMenu childrenBMenus = GetComponentsInChildren <BMenu>(); // Check Start Highlight BMenu highlightedBMenuReference = startHighlightedBMenu; if (highlightedBMenuReference == null) { LogConsoleError("No BMenu selected as highlight!"); } }
protected override void OnValidate() { objectNamePrefix = "F_"; base.OnValidate(); if (CanValidate() == false) { return; } // Get all children BMenu childrenBMenus = GetComponentsInChildren <BMenu>(); childrenBMenusList = new List <BFrameChildBMenu>(); foreach (BMenu bMenu in childrenBMenus) { if (bMenu.ParentBFrame == this) { childrenBMenusList.Add(new BFrameChildBMenu(bMenu, this)); } } // Check Start Highlight BMenu highlightedBMenuReference = null; if (startHighlightedBMenu) { showNoStartBMenuHighlight = false; highlightedBMenuReference = startHighlightedBMenu; } else // Try to get the first BMenu child { if ((childrenBMenus.Length > 0) && (childrenBMenus[0])) { startHighlightedBMenu = childrenBMenus[0]; showNoStartBMenuHighlight = false; highlightedBMenuReference = startHighlightedBMenu; } else { LogConsoleError(infoNoStartBMenuHighlight); showNoStartBMenuHighlight = true; } } }
public BFrameChildBMenu(BMenu bMenu, BFrame bFrame) { childBMenu = bMenu; bFrameReference = bFrame; }
public BBMenuChildBButton(BButton bButton, BMenu bMenu) { childBButton = bButton; bMenuReference = bMenu; }