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代码分享的主要内容,如果未能解决你的问题,请参考以下文章