private bool TryRender <T>(object content, UnityButton <T> func) where T : class { var contentAsT = content as T; if (contentAsT == null) { return(false); } var oldColor = GUI.color; GUI.color = Color; var res = func( contentAsT, GuiStyle, WidthAndHeight ); GUI.color = oldColor; if (res) { OnClick(); } return(true); }
private bool TryRender <T>(object content, UnityButton <T> func) where T : class { var contentAsT = content as T; if (contentAsT == null) { return(false); } var oldColor = GUI.color; GUI.color = Color; if (func( contentAsT, GuiStyle, GuiLayoutOptions ) == false) { GUI.color = oldColor; return(true); } GUI.color = oldColor; OnClick(); return(true); }
private bool TryRender <T>(object content, UnityButton <T> func) where T : class { var contentAsT = content as T; if (contentAsT == null) { return(false); } var isChecked = func( IsChecked, contentAsT, Style, GuiLayoutOptions ); if (isChecked == IsChecked) { return(true); } IsChecked = isChecked; if (Checked != null && isChecked) { Checked(this); } else if (Unchecked != null && isChecked == false) { Unchecked(this); } if (Changed != null) { Changed(this); } return(true); }
public UnityButton Clone(string name, Vector3 posOffset) { UnityButton newBut = new UnityButton(); newBut.rootObj = (GameObject)MonoBehaviour.Instantiate(rootObj); newBut.rootObj.name = name;//=="" ? srcObj.name+"(Clone)" : name; newBut.Init(); newBut.rootT.SetParent(rootT.parent); newBut.rootT.localPosition = rootT.localPosition + posOffset; newBut.rootT.localScale = new Vector3(1, 1, 1); return newBut; }