public override void OnInspectorGUI() { UITextUnderline text = target as UITextUnderline; bool showLine = EditorGUILayout.Toggle("ShowLine", text.showLine); if (text.showLine != showLine) { text.showLine = showLine; } base.OnInspectorGUI(); }
static int set_text(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UITextUnderline obj = (UITextUnderline)o; string arg0 = ToLua.CheckString(L, 2); obj.text = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index text on a nil value" : e.Message)); } }
static int set_showLine(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UITextUnderline obj = (UITextUnderline)o; bool arg0 = LuaDLL.luaL_checkboolean(L, 2); obj.showLine = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index showLine on a nil value" : e.Message)); } }
static int get_text(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UITextUnderline obj = (UITextUnderline)o; string ret = obj.text; LuaDLL.lua_pushstring(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index text on a nil value" : e.Message)); } }
static int get_showLine(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UITextUnderline obj = (UITextUnderline)o; bool ret = obj.showLine; LuaDLL.lua_pushboolean(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index showLine on a nil value" : e.Message)); } }
private void CreateLine() { //克隆Text,获得相同的属性 Text underline = GameObject.Instantiate(m_LinkText) as Text; underline.name = "Underline_" + MathUtils.RandRange_Int(0, ushort.MaxValue); underline.color = m_LineColor; if (m_LineBold > 0) { underline.fontSize = m_LineBold; } underline.transform.SetParent(m_LinkText.transform, false); //移除UITextUnderline,防止新创建的text带有脚本 UITextUnderline underline_script = underline.GetComponent <UITextUnderline>(); if (underline_script != null) { GameObject.DestroyImmediate(underline_script); } //设置下划线坐标和位置 RectTransform rt = underline.rectTransform; rt.anchoredPosition3D = Vector3.zero; rt.offsetMax = Vector2.zero; rt.offsetMin = Vector2.zero; rt.anchorMax = Vector2.one; rt.anchorMin = Vector2.zero; (underline.transform as RectTransform).anchoredPosition += new Vector2(0, m_OffsetY); //构建下划线 underline.text = "_"; string str_line = ""; float perlineWidth = underline.preferredWidth; //单个下划线宽度 float width = m_LinkText.preferredWidth; //总长度 int lineCount = (int)Mathf.Round(width / perlineWidth); for (int i = 1; i < lineCount; i++) { str_line += "_"; } underline.text += str_line; }
void CreateLine() { if (_Clone || _UnderLine != null) { return; } //克隆Text,获得相同的属性 GameObject cloneObj = new GameObject("Underline"); cloneObj.AddComponent <RectTransform>(); _UnderLine = cloneObj.AddComponent <UITextUnderline>(); //_UnderLine = Instantiate( this ) as UITextUnderline; //_UnderLine.name = "Underline"; _UnderLine._Clone = true; _UnderLine.font = this.font; _UnderLine.fontSize = this.fontSize; _UnderLine.fontStyle = this.fontStyle; _UnderLine.lineSpacing = this.lineSpacing; _UnderLine.alignment = this.alignment; cloneObj.transform.SetParent(transform); RectTransform rt = cloneObj.GetComponent <RectTransform>(); //设置下划线坐标和位置 rt.localScale = Vector3.one; rt.anchoredPosition3D = Vector3.zero; rt.offsetMax = Vector2.zero; rt.offsetMin = Vector2.zero; rt.anchorMax = Vector2.one; rt.anchorMin = Vector2.zero; _UnderLine.SetBase("_"); _Width = _UnderLine.preferredWidth; //单个下划线宽度 if (!_ShowLine) { _UnderLine.gameObject.SetActive(false); } }