void Awake() { group.addToggle(this); wrapper = this.GetComponent <UIWrapper>(); image = this.GetComponent <Image>(); }
static void FindExport(GameObject go, ref List <string> names, ref List <UIWrapper> wrappers, bool isRoot) { var expt = go.GetComponent <UILuaExporter>(); if (expt != null && !isRoot) { return; } if (go.name.StartsWith("_")) { UIWrapper wrapper = go.GetComponent <UIWrapper>(); if (wrapper == null) { wrapper = go.AddComponent <UIWrapper>(); } string exptName = go.name.Substring(1, go.name.Length - 1); names.Add(exptName); wrappers.Add(wrapper); } for (int i = 0; i < go.transform.childCount; ++i) { FindExport(go.transform.GetChild(i).gameObject, ref names, ref wrappers, false); } }
void Start() { UI = FindObjectOfType <UIWrapper>(); //IMPORTANT(Ioennir): This InitializeGameTurns call will be moved to the interface in the main menu, this is only for testing and show purpose. // This starts when the tower is being constructed, change it to when the tower has already been constructed. InitializeGameTurns(2, 40.0f); }
/* void Update() * { * print("还是执行了"); * UpdateSysInfo(); * }*/ public void ChangeWidth(GameObject go, SysInfoData msgData) { RectTransform rt = go.GetComponent <RectTransform>(); UIWrapper wrapper = go.GetComponent <UIWrapper>(); UIWrapper text = wrapper.GO("Text"); string str = wrapper.GO("Text").text; if (str.Contains("</color>")) { str = getTextStr(msgData.text); } int length = (int)text.textWidth; switch (msgData.type) { case SysInfoType.Text: case SysInfoType.Item: rt.sizeDelta = new Vector2(length + 80, 40); break; case SysInfoType.Money: case SysInfoType.Diamond: case SysInfoType.Exp: UIWrapper icon = wrapper.GO("Icon"); rt.sizeDelta = new Vector2(40 + 28 + 10 + length + 40, 40); //前间隔、图标宽度、图标和文本间隔、文本宽度、后间隔 icon.GetComponent <RectTransform>().anchoredPosition = new Vector3(40, 0, 0); text.GetComponent <RectTransform>().anchoredPosition = new Vector3(-40, 0, 0); break; default: return; } }
public void SetChildShow(bool show) { UIWrapper child = this[name]; if (child != null) { child.SetShow(show); } }
public void HideChild(string name) { UIWrapper child = this[name]; if (child != null) { child.Hide(); } }
public void ShowChild(string name) { UIWrapper child = this[name]; if (child != null) { child.Show(); } }
//public void SetChoosen(UIWrapper btn) //{ // btn.sprite = Util.LoadSprite("Qianghua/Dynamic/bqy_1"); //} //public void SetUnChoosen(UIWrapper btn) //{ // btn.sprite = Util.LoadSprite("Qianghua/Dynamic/bqy_2"); //} // Use this for initialization void Start() { for (int i = 0; i < this.transform.childCount; ++i) { UIWrapper btn = this[this.transform.GetChild(i).name]; btns.Add(btn); btn.BindButtonClick(OnButton); } current = this.transform.GetChild(0).gameObject.GetComponent <UIWrapper>(); }
public void SetUsingText(UIWrapper inputText) { editText = inputText; //if (!editText.text.Equals("1")) // bDefaultOne = false; for (int i = 0; i < btns.Count; ++i) { btns[i].BindButtonClick(OnButton); } }
// Use this for initialization void Start() { //这里记录下12个按键的UIWarpper for (int i = 0; i < 12; ++i) { UIWrapper grid = this["KeyBoard"]["grid"]; UIWrapper btn = grid[i]; btns.Add(btn); } }
public bool IsChildShow() { UIWrapper child = this[name]; if (child == null) { return(false); } return(child.IsShow()); }
static int FindFullScreenUI(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); UIManager obj = (UIManager)ToLua.CheckObject(L, 1, typeof(UIManager)); string arg0 = ToLua.CheckString(L, 2); UIWrapper o = obj.FindFullScreenUI(arg0); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int set_JoystickTouch(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); JoystickLogic obj = (JoystickLogic)o; UIWrapper arg0 = (UIWrapper)ToLua.CheckUnityObject(L, 2, typeof(UIWrapper)); obj.JoystickTouch = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index JoystickTouch on a nil value" : e.Message)); } }
static int get_JoystickTouch(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); JoystickLogic obj = (JoystickLogic)o; UIWrapper ret = obj.JoystickTouch; ToLua.Push(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index JoystickTouch on a nil value" : e.Message)); } }
public UIWrapper this[int index] { get { Transform t = this.transform.GetChild(index); if (t == null) { //TTLoger.LogError(string.Format("[错误] 节点<{0}>不存在子节点<{1}>", this.transform.name, name)); return(null); } UIWrapper wrapper = t.GetComponent <UIWrapper>(); if (wrapper == null) { wrapper = t.gameObject.AddComponent <UIWrapper>(); } return(wrapper); } }
//交换点击按钮和当前选中按钮的状态 public void Swap(GameObject go1, GameObject go2) { if (go1 == go2) { return; } UIWrapper uw1 = go1.GetComponent <UIWrapper>(); UIWrapper uw2 = go2.GetComponent <UIWrapper>(); //交换形状信息 RectTransform rt1 = go1.GetComponent <RectTransform>(); RectTransform rt2 = go2.GetComponent <RectTransform>(); Vector2 tempRect = Vector2.zero; tempRect = rt1.sizeDelta; rt1.sizeDelta = rt2.sizeDelta; rt2.sizeDelta = tempRect; Vector3 ap1 = rt1.anchoredPosition; Vector3 ap2 = rt2.anchoredPosition; float tempX = ap1.x; ap1.x = ap2.x; ap2.x = tempX; rt1.anchoredPosition = ap1; rt2.anchoredPosition = ap2; //交换图片 Sprite tempSprite = uw1.Sprite; uw1.Sprite = uw2.Sprite; uw2.Sprite = tempSprite; //交换文字颜色,位置 Color tempColor = uw1["text"].textColor; uw1["text"].textColor = uw2["text"].textColor; uw2["text"].textColor = tempColor; RectTransform rect1 = uw1["text"].gameObject.GetComponent <RectTransform>(); RectTransform rect2 = uw2["text"].gameObject.GetComponent <RectTransform>(); Vector2 tempPos = rect1.anchoredPosition; rect1.anchoredPosition = rect2.anchoredPosition; rect2.anchoredPosition = tempPos; }
public UIWrapper GO(String path) { //String[] arr = path.Split('.'); //UIWrapper obj = this; //for (int i = 0; i < arr.Length; i++) { // obj = obj[arr[i]]; //} Transform trans = GOT(path); if (trans != null) { GameObject obj = trans.gameObject; UIWrapper wrapper = obj.GetComponent <UIWrapper>(); if (wrapper == null) { wrapper = obj.gameObject.AddComponent <UIWrapper>(); } return(wrapper); } return(null); }
public void OnButton(GameObject go) { Swap(go, current.gameObject); current = go.GetComponent <UIWrapper>(); }
private IEnumerator DoCrackImpl(string message, float crackTime, float stretchTime, float keepTime, float fadeOutTime, LuaFunction callback) { if (mIsDoingCrack) { yield break; } mIsDoingCrack = true; UIWrapper text = this["_Text"]; UIWrapper line = this["_Line"]; // 文本初始化 text.text = message; text.alpha = 1; text.scale = new Vector3(1, 0, 1); // 线条初始化 line.fillAmount = 0; line.alpha = 1; // 裂开一条缝隙 float startTime = Time.realtimeSinceStartup; while (true) { float now = Time.realtimeSinceStartup; if (now >= startTime + crackTime) { line.fillAmount = 1.0f; break; } else { float percent = 0.08f + (now - startTime) / crackTime * (0.92f - 0.08f); line.fillAmount = percent; yield return(null); } } // 展开文字 startTime = Time.realtimeSinceStartup; while (true) { float now = Time.realtimeSinceStartup; if (now >= startTime + stretchTime) { text.scale = Vector3.one; break; } else { Vector3 scale = text.scale; scale.y = (now - startTime) / stretchTime; text.scale = scale; yield return(null); } } // 停留文字 startTime = Time.realtimeSinceStartup; while (true) { float now = Time.realtimeSinceStartup; if (now >= startTime + keepTime) { break; } yield return(null); } // 淡出文字 startTime = Time.realtimeSinceStartup; while (true) { float now = Time.realtimeSinceStartup; if (now >= startTime + fadeOutTime) { line.alpha = 0; text.alpha = 0; break; } float t = 1.0f - (now - startTime) / fadeOutTime; line.alpha = t; text.alpha = t; yield return(null); } mIsDoingCrack = false; if (callback != null) { callback.Call(); } }