Unity_Guilayout_box默认样式如何恢复_加GuiStyle代码分享

Posted avi9111

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Unity_Guilayout_box默认样式如何恢复_加GuiStyle代码分享相关的知识,希望对你有一定的参考价值。

对于大团队来说,gui.skin不能随便乱动

可以试试下面方法:

unity Guistyle 复制默认GUI box样式

void OnGUI(){

GUIStyle mystyle = CloneGUIStyle(GUI.skin.box);

mystyle.normal.background = mybackgroundimage;
}

 

GUIStyle CloneGUIStyle(GUIStyle source)
{
    GUIStyle clone = new GUIStyle();


 clone.normal = source.normal;
 clone.hover = source.hover;
 clone.active = source.active;
 clone.onNormal = source.onNormal;
 clone.onHover = source.onHover;
 clone.onActive = source.onActive;
 clone.focused = source.focused;
 clone.onFocused = source.onFocused;
 clone.border = source.border;
 clone.margin = source.margin;
 clone.padding = source.padding;
 clone.overflow = source.overflow;
 clone.font = source.font;
 clone.imagePosition = source.imagePosition;
 clone.alignment = source.alignment;
 clone.wordWrap = source.wordWrap;
 clone.clipping = source.clipping;
 clone.contentOffset = source.contentOffset;
 clone.fixedWidth = source.fixedWidth;
 //clone.fontSize = source.fontSize;
 //clone.fontStyle = source.fontStyle;
 clone.fixedHeight = source.fixedHeight;
 clone.stretchWidth = source.stretchWidth;
 clone.stretchHeight = source.stretchHeight;
 //clone.lineHeight = source.lineHeight;
 return clone;

}

 

以上是关于Unity_Guilayout_box默认样式如何恢复_加GuiStyle代码分享的主要内容,如果未能解决你的问题,请参考以下文章

CSS 如何恢复到默认样式?

CSS 如何恢复到默认样式?

如何修改layui的默认样式

如何根据默认的 DataGrid 样式创建样式?

如何删除默认的 Storybook Canvas 样式?

React Antd 中如何修改覆盖默认样式及样式引用