public void ColorUnsetAllExpand() { if (IsOpen) { return; } var listExpandPersonControls = GameObject.FindGameObjectsWithTag("ExpandPersonControl"); foreach (var exp in listExpandPersonControls) { if (exp.name == "PrefabExpandPanel") { continue; } ExpandControl scriptExp = exp.GetExpandControl(); scriptExp.SetColorText(UIEvents.ColorExpClose); string nameExp = scriptExp.GetName; scriptExp.ExpandPanelOn(true, p_isOpen: false); } SetColorText(UIEvents.ColorExpOpen); }
public void AddExpandPerson(string tittle, List <string> listText, List <string> listCommand, GameObject gobjObservable) { //Debug.Log("AddExpandPerson ....."); if (PrefabExpandPanel == null) { Debug.Log("########### PrefabExpandPanel is Empty"); return; } string newNameExpand = "ExpandPanel" + Helper.GetID(gobjObservable.name); var resultFind = GameObject.Find(newNameExpand); //if (resultFind != null) //{ var listExpandPersonControls = GameObject.FindGameObjectsWithTag("ExpandPersonControl"); //Debug.Log("listExpandPersonControls count = " + listExpandPersonControls.Length); foreach (var exp in listExpandPersonControls) { if (exp.name == "PrefabExpandPanel") { continue; } //Debug.Log("_EXP ME (" + newNameExpand + ")__________ expand find " + exp.name); ExpandControl scriptExp = exp.GetExpandControl(); string nameExp = scriptExp.GetName; //if(nameExp!= newNameExpand) scriptExp.SetColorText(ColorExpClose); //Debug.Log("ME " + newNameExpand + " FIND: " + nameExp); scriptExp.ExpandPanelOn(true, p_isOpen: false); } if (resultFind != null) { ExpandControl scriptExpand = resultFind.GetExpandControl(); scriptExpand.SetColorText(ColorExpOpen); scriptExpand.ExpandPanelOn(p_isOpen: true); return; } Vector3 pos = new Vector3(0, 0, 0); GameObject expandGO = (GameObject)Instantiate(PrefabExpandPanel, pos, Quaternion.identity); expandGO.name = newNameExpand; expandGO.transform.SetParent(contentListExpandPerson.transform); if (gobjObservable == null) { Debug.Log("########### gobjObservable is Empty : " + tittle); } if (expandGO == null) { Debug.Log("########### expandGO is Empty"); return; } if (expandGO.transform == null) { Debug.Log("########### expandGO.transform = null"); return; } ExpandControl scriptEvents = expandGO.GetComponent <ExpandControl>(); scriptEvents.SetGameObject(gobjObservable, tittle); scriptEvents.AddList(tittle, listText, listCommand, gobjObservable); //scriptEvents = resultFind.GetExpandControl(); scriptEvents.SetColorText(ColorExpOpen); scriptEvents.ExpandPanelOn(p_isOpen: true); var scrollbar = ListBoxExpandPerson.GetComponentInChildren <Scrollbar>(); if (scrollbar == null) { Debug.Log("########### ListBoxExpandPerson scrollbar = null"); return; } scrollbar.numberOfSteps = 10; }
public void CreateCommandLogButton(string p_text, Color color, Transform p_parent, GameObject gobjObservable = null, bool isValidExistCommand = false, ExpandControl expControl = null) { bool isPersonComm = false; if (gobjObservable != null) { isPersonComm = true; } //string nameBtn = "ButtonCommand" + p_text; string keyB = "ButtonCommand"; string textBtn = p_text.Replace(keyB, ""); string nameBtn = textBtn + keyB; GameObject findObjects; //GameObject[] findObjects = GameObject.FindGameObjectsWithTag("PrefabCommandButton"); if (isValidExistCommand) { findObjects = GameObject.Find(nameBtn); //Debug.Log("GameObject.Find(" + nameBtn + ") : " + findObjects); if (findObjects != null) { isValidExistCommand = false; } } else { isValidExistCommand = true; } //Debug.Log("CreateCommandLogButton " + p_text); //if (findObjects == null) if (isValidExistCommand) { //Debug.Log("CreateCommandLogButton 2. " + p_text); Vector3 pos = new Vector3(0, 0, 0); Button buttonCommand = (Button)Instantiate(prefabButtonCommand, pos, Quaternion.identity); Text compText = null; compText = buttonCommand.GetComponentInChildren <Text>(); if (compText == null) { Debug.Log("######### CreateCommandLogButton compText is Empty"); return; } compText.text = textBtn; buttonCommand.transform.SetParent(p_parent); buttonCommand.name = nameBtn; if (isPersonComm) { buttonCommand.tag = "CommandButtonPerson"; } else { buttonCommand.tag = "CommandButtonTool"; } if (isPersonComm) { buttonCommand.SetColor(ColorYelow); // "#CDA143"); } else { buttonCommand.SetColor(ColorGreen); } //Debug.Log("ADD: CreateCommandLogText : " + nameBtn + " parent: " + p_parent.name); string gobjID = ""; ModelNPC.GameDataNPC dataObs = null; if (gobjObservable != null && gobjObservable.IsNPC()) { dataObs = gobjObservable.GetDataNPC(); } if (gobjObservable != null) { gobjID = Helper.GetID(gobjObservable.name); } //ExpandControl expControl = null //ADD EVENT COMMAND buttonCommand.onClick.AddListener(delegate { var _gobjID = gobjID; if (isPersonComm) { //def color set //buttonCommand.SetColor(ColorExpClose); //if (gobjObservable == null) if (expControl == null) { buttonCommand.SetColor(ColorAlert);// "#EC4D56"); Debug.Log("buttonCommand.onClick isPersonComm expControl == null"); } if (expControl.IsAlert) { ListLogAdd = "PersonComm [" + textBtn + "] objObservable is Destroy & data empty"; buttonCommand.SetColor(ColorAlert);// "#EC4D56"); return; } //if (gobjObservable == null) //{ gobjObservable = expControl.SelectedObserver(); //} dataObs = (ModelNPC.GameDataNPC)expControl.DataObject; if (dataObs == null) { ListLogAdd = "PersonComm [" + textBtn + "] objObservable is Destroy & data empty"; } if (gobjObservable != null) { dataObs = gobjObservable.GetDataNPC(); } CommandExecutePerson(textBtn, gobjObservable, dataObs); } else { //Debug.Log("######### gobjObservable is NULL" + nameBtn); CommandExecute(textBtn); } }); } else { //CreateCommandLogText(p_text, Color.white); //Debug.Log("Already exist CreateCommandLogButton " + nameBtn); } }