Since individuals variables cannot be copied in the inspector (unless they happen to be strings or ints), I wrote a custom editor for GUISkin
. To use it, save the following as Assets/Editor/GUISkinExtensions.js. You should then get extra lines at the bottom of the inspector for a GUISkin that allow you to copy styles. I find this very useful when you want to make a variation of an existing styles - if it’s a custom style you can just CTRL-D to duplicate, but if it’s a builtin like label
, you need this script.
![alt text][1]
// See https://mcmap.net/q/38855/unity-copy-paste-guistyle-in-the-inspector
//
@CustomEditor(GUISkin)
class GUISkinExtensions extends Editor
{
static final var builtinGUISkinStyles : String[] = [
"box", "button", "toggle",
"label", "textField", "textArea",
"window",
"horizontalSlider", "horizontalSliderThumb",
"verticalSlider", "verticalSliderThumb",
"horizontalScrollbar", "horizontalScrollbarThumb",
"horizontalScrollbarLeftButton", "horizontalScrollbarRightButton",
"verticalScrollbar", "verticalScrollbarThumb",
"verticalScrollbarUpButton", "verticalScrollbarDownButton",
"scrollView"
];
var from = 0;
var to = 0;
function OnInspectorGUI()
{
var skin = target as GUISkin;
DrawDefaultInspector();
EditorGUILayout.Space();
var names = builtinGUISkinStyles;
var customNames = new String[skin.customStyles.Length];
for (var i=0; i<customNames.Length; ++i) {
customNames _= skin.customStyles*.name;*_
* }*
* names += customNames;*
* from = EditorGUILayout.Popup(“From:”,from,names);*
* to = EditorGUILayout.Popup(“To:”,to,names);*
* if (GUILayout.Button(“Copy”)) {*
* var fs = skin.GetStyle(names[from]);*
* var ts = skin.GetStyle(names[to]);*
* var newStyle = new GUIStyle(fs);*
* newStyle.name = ts.name;*
* var custom = to - builtinGUISkinStyles.Length;*
* if (custom >= 0) {*
* skin.customStyles[custom] = newStyle;*
* } else {*
* skin.GetType().InvokeMember(names[to], System.Reflection.BindingFlags.SetProperty, null, skin, [newStyle]);*
* }*
* }*
* }*
}
_*[1]: http://i.imgur.com/rxZqO.png*_
don't talk about things that you are not sure about. you don't have to answer all questions. you can write "i don't know any way but i think ...". answer those questions that you are sure about them and you have clear answers or good ideas about them.
– SteelworksIt seems to me that, @Socialminded is talking about variables in the inspector (which is what the question is asking about), whereas the other answers are talking about whole components, which is not the question.
– ShipboardWaz is correct. Possibly Ashkan_gc should refrain from talking about things he isn't sure about.
– Unlovely