public override void ReadFrom(object obj) { base.ReadFrom(obj); if (obj == null) { return; } UnityEngine.GUISkin o = (UnityEngine.GUISkin)obj; font = o.font.GetMappedInstanceID(); box = Read(box, o.box); label = Read(label, o.label); textField = Read(textField, o.textField); textArea = Read(textArea, o.textArea); button = Read(button, o.button); toggle = Read(toggle, o.toggle); window = Read(window, o.window); horizontalSlider = Read(horizontalSlider, o.horizontalSlider); horizontalSliderThumb = Read(horizontalSliderThumb, o.horizontalSliderThumb); verticalSlider = Read(verticalSlider, o.verticalSlider); verticalSliderThumb = Read(verticalSliderThumb, o.verticalSliderThumb); horizontalScrollbar = Read(horizontalScrollbar, o.horizontalScrollbar); horizontalScrollbarThumb = Read(horizontalScrollbarThumb, o.horizontalScrollbarThumb); horizontalScrollbarLeftButton = Read(horizontalScrollbarLeftButton, o.horizontalScrollbarLeftButton); horizontalScrollbarRightButton = Read(horizontalScrollbarRightButton, o.horizontalScrollbarRightButton); verticalScrollbar = Read(verticalScrollbar, o.verticalScrollbar); verticalScrollbarThumb = Read(verticalScrollbarThumb, o.verticalScrollbarThumb); verticalScrollbarUpButton = Read(verticalScrollbarUpButton, o.verticalScrollbarUpButton); verticalScrollbarDownButton = Read(verticalScrollbarDownButton, o.verticalScrollbarDownButton); scrollView = Read(scrollView, o.scrollView); customStyles = Read(customStyles, o.customStyles); }
protected override void GetDependencies(System.Collections.Generic.Dictionary <long, UnityEngine.Object> dependencies, object obj) { base.GetDependencies(dependencies, obj); if (obj == null) { return; } UnityEngine.GUISkin o = (UnityEngine.GUISkin)obj; AddDependency(o.font, dependencies); GetDependencies(box, o.box, dependencies); GetDependencies(label, o.label, dependencies); GetDependencies(textField, o.textField, dependencies); GetDependencies(textArea, o.textArea, dependencies); GetDependencies(button, o.button, dependencies); GetDependencies(toggle, o.toggle, dependencies); GetDependencies(window, o.window, dependencies); GetDependencies(horizontalSlider, o.horizontalSlider, dependencies); GetDependencies(horizontalSliderThumb, o.horizontalSliderThumb, dependencies); GetDependencies(verticalSlider, o.verticalSlider, dependencies); GetDependencies(verticalSliderThumb, o.verticalSliderThumb, dependencies); GetDependencies(horizontalScrollbar, o.horizontalScrollbar, dependencies); GetDependencies(horizontalScrollbarThumb, o.horizontalScrollbarThumb, dependencies); GetDependencies(horizontalScrollbarLeftButton, o.horizontalScrollbarLeftButton, dependencies); GetDependencies(horizontalScrollbarRightButton, o.horizontalScrollbarRightButton, dependencies); GetDependencies(verticalScrollbar, o.verticalScrollbar, dependencies); GetDependencies(verticalScrollbarThumb, o.verticalScrollbarThumb, dependencies); GetDependencies(verticalScrollbarUpButton, o.verticalScrollbarUpButton, dependencies); GetDependencies(verticalScrollbarDownButton, o.verticalScrollbarDownButton, dependencies); GetDependencies(scrollView, o.scrollView, dependencies); GetDependencies(customStyles, o.customStyles, dependencies); }
internal Vector2 MeasureString(string text) { UnityEngine.GUISkin skin = UnityEngine.GUISkin.CreateInstance <UnityEngine.GUISkin>(); UnityEngine.Vector2 size = skin.label.CalcSize(new UnityEngine.GUIContent(text)); return(new Vector2(size.x, size.y)); }
public override object WriteTo(object obj, System.Collections.Generic.Dictionary <long, UnityEngine.Object> objects) { obj = base.WriteTo(obj, objects); if (obj == null) { return(null); } UnityEngine.GUISkin o = (UnityEngine.GUISkin)obj; o.font = (UnityEngine.Font)objects.Get(font); o.box = Write(o.box, box, objects); o.label = Write(o.label, label, objects); o.textField = Write(o.textField, textField, objects); o.textArea = Write(o.textArea, textArea, objects); o.button = Write(o.button, button, objects); o.toggle = Write(o.toggle, toggle, objects); o.window = Write(o.window, window, objects); o.horizontalSlider = Write(o.horizontalSlider, horizontalSlider, objects); o.horizontalSliderThumb = Write(o.horizontalSliderThumb, horizontalSliderThumb, objects); o.verticalSlider = Write(o.verticalSlider, verticalSlider, objects); o.verticalSliderThumb = Write(o.verticalSliderThumb, verticalSliderThumb, objects); o.horizontalScrollbar = Write(o.horizontalScrollbar, horizontalScrollbar, objects); o.horizontalScrollbarThumb = Write(o.horizontalScrollbarThumb, horizontalScrollbarThumb, objects); o.horizontalScrollbarLeftButton = Write(o.horizontalScrollbarLeftButton, horizontalScrollbarLeftButton, objects); o.horizontalScrollbarRightButton = Write(o.horizontalScrollbarRightButton, horizontalScrollbarRightButton, objects); o.verticalScrollbar = Write(o.verticalScrollbar, verticalScrollbar, objects); o.verticalScrollbarThumb = Write(o.verticalScrollbarThumb, verticalScrollbarThumb, objects); o.verticalScrollbarUpButton = Write(o.verticalScrollbarUpButton, verticalScrollbarUpButton, objects); o.verticalScrollbarDownButton = Write(o.verticalScrollbarDownButton, verticalScrollbarDownButton, objects); o.scrollView = Write(o.scrollView, scrollView, objects); o.customStyles = Write(o.customStyles, customStyles, objects); return(o); }
static StackObject *Ctor_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *__ret = ILIntepreter.Minus(__esp, 0); var result_of_this_method = new UnityEngine.GUISkin(); return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
protected UnityEngine.GUISkin MakeSkin(UnityEngine.GUISkin template) { UnityEngine.GUISkin skin = UnityEngine.Object.Instantiate(template); // Creating a dynamic font as is done below results in Unity producing // incorrect character bounds and everything looks ugly. They even // "document" it in their source code, see // https://github.com/Unity-Technologies/UnityCsReference/blob/57f723ec72ca50427e5d17cad0ec123be2372f67/Modules/GraphViewEditor/Views/GraphView.cs#L262. // So here I am, sizing a pangram to get an idea of the shape of things and // nudging pixels by hand. It's the 90's, go for it! var pangram = new UnityEngine.GUIContent( "Portez ce vieux whisky au juge blond qui fume."); float button_height = skin.button.CalcHeight(pangram, width: 1000); float horizontal_slider_height = skin.horizontalSlider.CalcHeight(pangram, width: 1000); float horizontal_slider_thumb_height = skin.horizontalSliderThumb.CalcHeight(pangram, width: 1000); float label_height = skin.label.CalcHeight(pangram, width: 1000); float text_area_height = skin.textArea.CalcHeight(pangram, width: 1000); float text_field_height = skin.textField.CalcHeight(pangram, width: 1000); float toggle_height = skin.toggle.CalcHeight(pangram, width: 1000); skin.font = UnityEngine.Font.CreateDynamicFontFromOSFont( skin.font.fontNames, (int)(skin.font.fontSize * scale_)); skin.button.alignment = UnityEngine.TextAnchor.MiddleCenter; skin.button.contentOffset = new UnityEngine.Vector2(0, -button_height * scale_ / 10); skin.button.fixedHeight = button_height * scale_; skin.horizontalSlider.fixedHeight = 21 * scale_; skin.horizontalSliderThumb.fixedHeight = 21 * scale_; skin.horizontalSliderThumb.fixedWidth = 12 * scale_; skin.label.alignment = UnityEngine.TextAnchor.MiddleLeft; skin.label.contentOffset = new UnityEngine.Vector2(0, -label_height * scale_ / 20); skin.label.fixedHeight = label_height * scale_; skin.textArea.alignment = UnityEngine.TextAnchor.MiddleLeft; skin.textArea.contentOffset = new UnityEngine.Vector2(0, -text_area_height * scale_ / 20); skin.textArea.fixedHeight = text_area_height * scale_; skin.textField.alignment = UnityEngine.TextAnchor.MiddleLeft; skin.textField.contentOffset = new UnityEngine.Vector2(0, -text_area_height * scale_ / 20); skin.textField.fixedHeight = text_field_height * scale_; skin.toggle.fixedHeight = toggle_height * scale_; skin.toggle.contentOffset = new UnityEngine.Vector2(0, -toggle_height * (scale_ - 1) / 3); skin.toggle.alignment = UnityEngine.TextAnchor.UpperLeft; skin.toggle.margin = new UnityEngine.RectOffset( (int)(skin.toggle.margin.left * scale_), skin.toggle.margin.right, (int)(skin.toggle.margin.top * 1.7 * scale_), skin.toggle.margin.bottom); return(skin); }
static int _s_set_customStyles(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.GUISkin __cl_gen_to_be_invoked = (UnityEngine.GUISkin)translator.FastGetCSObj(L, 1); __cl_gen_to_be_invoked.customStyles = (UnityEngine.GUIStyle[])translator.GetObject(L, 2, typeof(UnityEngine.GUIStyle[])); } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } return(0); }
static int _g_get_settings(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.GUISkin __cl_gen_to_be_invoked = (UnityEngine.GUISkin)translator.FastGetCSObj(L, 1); translator.Push(L, __cl_gen_to_be_invoked.settings); } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } return(1); }
public void ApplySkin() { // create new skin instance var skinHover = UnityEngine.Object.Instantiate(m_skinHover); var skinSelected = UnityEngine.Object.Instantiate(m_skinSelected); var skinUnselected = UnityEngine.Object.Instantiate(m_skinUnselected); // name the skins skinHover.name = "Hover"; skinSelected.name = "Selected"; skinUnselected.name = "Unselected"; m_skinHover = skinHover; m_skinSelected = skinSelected; m_skinUnselected = skinUnselected; }
static StackObject *set_customStyles_2(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); UnityEngine.GUIStyle[] @value = (UnityEngine.GUIStyle[]) typeof(UnityEngine.GUIStyle[]).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); UnityEngine.GUISkin instance_of_this_method = (UnityEngine.GUISkin) typeof(UnityEngine.GUISkin).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.customStyles = value; return(__ret); }
static int __CreateInstance(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { if (LuaAPI.lua_gettop(L) == 1) { UnityEngine.GUISkin __cl_gen_ret = new UnityEngine.GUISkin(); translator.Push(L, __cl_gen_ret); return(1); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.GUISkin constructor!")); }
public static UnityEngine.GUIStyle unityStyle(Style style, Skin skin) { UnityEngine.GUISkin uskin = unitySkin(skin); switch (style) { case Style.Button: return(uskin.button); case Style.HorizontalSlider: return(uskin.horizontalSlider); case Style.HorizontalSliderThumb: return(uskin.horizontalSliderThumb); case Style.Label: return(uskin.label); case Style.Textbox: return(uskin.textField); case Style.TextArea: return(uskin.textArea); case Style.Toggle: return(uskin.toggle); case Style.VerticalSlider: return(uskin.verticalSlider); case Style.VerticalSliderThumb: return(uskin.verticalSliderThumb); case Style.Window: return(uskin.window); case Style.Default: return(null); } return(null); }
static int _m_GetEnumerator(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.GUISkin __cl_gen_to_be_invoked = (UnityEngine.GUISkin)translator.FastGetCSObj(L, 1); try { { System.Collections.IEnumerator __cl_gen_ret = __cl_gen_to_be_invoked.GetEnumerator( ); translator.Push(L, __cl_gen_ret); return(1); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } }
static int _m_FindStyle(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.GUISkin __cl_gen_to_be_invoked = (UnityEngine.GUISkin)translator.FastGetCSObj(L, 1); try { { string styleName = LuaAPI.lua_tostring(L, 2); UnityEngine.GUIStyle __cl_gen_ret = __cl_gen_to_be_invoked.FindStyle(styleName); translator.Push(L, __cl_gen_ret); return(1); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } }
/// <summary> /// This method is called by Unity each frame /// </summary> void OnGUI() { if (TrasparentGUIStyle == null) { UnityEngine.Texture2D emptyText = InternalResources.ReadResourceAsTexture2D("Transparent"); TrasparentGUIStyle = new UnityEngine.GUIStyle(); TrasparentGUIStyle.active.background = emptyText; TrasparentGUIStyle.hover.background = emptyText; TrasparentGUIStyle.normal.background = emptyText; TrasparentGUIStyle.onActive.background = emptyText; TrasparentGUIStyle.onFocused.background = emptyText; TrasparentGUIStyle.onHover.background = emptyText; TrasparentGUIStyle.onNormal.background = emptyText; } if (_tick > 100000) { _tick = 0; } if (_DefaultSkin == null) { _DefaultSkin = UnityEngine.GUI.skin; } if (_tick % 10 == 0) { UnityEngine.GUI.skin = _DefaultSkin; } ModLoader.Instance.__OnGui(); _tick++; if (_ResizeHandles.Count > 0) { UnityEngine.GUI.Box(new UnityEngine.Rect(0, 0, UnityEngine.Screen.width, UnityEngine.Screen.height), "", TrasparentGUIStyle); if ((UnityEngine.Event.current.type == UnityEngine.EventType.mouseUp && UnityEngine.Event.current.button == 0)) { GUI.IResizeable[] resizeables = new GUI.IResizeable[_ResizeHandles.Count]; _ResizeHandles.CopyTo(resizeables, 0); foreach (GUI.IResizeable resizeable in resizeables) { resizeable.ResizeEnd(UnityEngine.Event.current.mousePosition); } } } foreach (Mod M in ModLoader.Instance.Mods.Where(m => m.Enabled)) { try { if (!M._FirstGuiPassCalled) { M.OnCreateGUI(); M._FirstGuiPassCalled = true; } if (ManagerMenu.mainMenuActive && M.CanShowModWindow) { M.ModWindow.__Draw(); } M.OnGUI(); } catch (Exception ex) { ModLoader.Instance.ShowError(M, ex, "GUI"); M._Logger.LogException(ex); } } }
public virtual void AssignDefaults() { // create new skin instance var skinHover = UnityEngine.ScriptableObject.CreateInstance <UnityEngine.GUISkin>(); var skinSelected = UnityEngine.ScriptableObject.CreateInstance <UnityEngine.GUISkin>(); var skinUnselected = UnityEngine.ScriptableObject.CreateInstance <UnityEngine.GUISkin>(); skinHover.hideFlags = UnityEngine.HideFlags.HideAndDontSave; skinSelected.hideFlags = UnityEngine.HideFlags.HideAndDontSave; skinUnselected.hideFlags = UnityEngine.HideFlags.HideAndDontSave; // name the skins skinHover.name = "Hover"; skinSelected.name = "Selected"; skinUnselected.name = "Unselected"; var tempWwisePath = "Assets/Wwise/Editor/WwiseWindows/TreeViewControl/"; m_textureBlank = GetTexture(tempWwisePath + "blank.png"); m_textureGuide = GetTexture(tempWwisePath + "guide.png"); m_textureLastSiblingCollapsed = GetTexture(tempWwisePath + "last_sibling_collapsed.png"); m_textureLastSiblingExpanded = GetTexture(tempWwisePath + "last_sibling_expanded.png"); m_textureLastSiblingNoChild = GetTexture(tempWwisePath + "last_sibling_nochild.png"); m_textureMiddleSiblingCollapsed = GetTexture(tempWwisePath + "middle_sibling_collapsed.png"); m_textureMiddleSiblingExpanded = GetTexture(tempWwisePath + "middle_sibling_expanded.png"); m_textureMiddleSiblingNoChild = GetTexture(tempWwisePath + "middle_sibling_nochild.png"); m_textureNormalChecked = GetTexture(tempWwisePath + "normal_checked.png"); m_textureNormalUnchecked = GetTexture(tempWwisePath + "normal_unchecked.png"); m_textureSelectedBackground = GetTexture(tempWwisePath + "selected_background_color.png"); m_skinHover = skinHover; m_skinSelected = skinSelected; m_skinUnselected = skinUnselected; SetBackground(m_skinHover.button, null); SetBackground(m_skinHover.toggle, null); SetButtonFontSize(m_skinHover.button); SetButtonFontSize(m_skinHover.toggle); RemoveMargins(m_skinHover.button); RemoveMargins(m_skinHover.toggle); SetTextColor(m_skinHover.button, UnityEngine.Color.yellow); SetTextColor(m_skinHover.toggle, UnityEngine.Color.yellow); SetBackground(m_skinSelected.button, m_textureSelectedBackground); SetBackground(m_skinSelected.toggle, m_textureSelectedBackground); SetButtonFontSize(m_skinSelected.button); SetButtonFontSize(m_skinSelected.toggle); RemoveMargins(m_skinSelected.button); RemoveMargins(m_skinSelected.toggle); SetTextColor(m_skinSelected.button, UnityEngine.Color.yellow); SetTextColor(m_skinSelected.toggle, UnityEngine.Color.yellow); SetBackground(m_skinUnselected.button, null); SetBackground(m_skinUnselected.toggle, null); SetButtonFontSize(m_skinUnselected.button); SetButtonFontSize(m_skinUnselected.toggle); RemoveMargins(m_skinUnselected.button); RemoveMargins(m_skinUnselected.toggle); if (UnityEditor.EditorPrefs.GetInt("UserSkin") == 1) { // Dark theme var darkBgColor = new UnityEngine.Color(51.0f / 255.0f, 51.0f / 255.0f, 51.0f / 255.0f); SetTextColor(m_skinUnselected.button, UnityEngine.Color.white); SetTextColor(m_skinUnselected.toggle, UnityEngine.Color.white); SetBackgroundColor(m_skinUnselected.button, darkBgColor); SetBackgroundColor(m_skinUnselected.toggle, darkBgColor); } else { // Light theme var lightBgColor = new UnityEngine.Color(165.0f / 255.0f, 165.0f / 255.0f, 165.0f / 255.0f); SetTextColor(m_skinUnselected.button, UnityEngine.Color.black); SetTextColor(m_skinUnselected.toggle, UnityEngine.Color.black); SetBackgroundColor(m_skinUnselected.button, lightBgColor); SetBackgroundColor(m_skinUnselected.toggle, lightBgColor); } }
public static Form LoadForm(UnityEngine.GameObject gameObject, Type type, UnityEngine.GUISkin Skin) { throw new NotImplementedException(); }