is there a way for me to change the size of Custom Style via scripting?
edited:
it's not that I want to create a new skin but to expand/add some more textures and names in the custom styles and I want this done by changing the size of the custom styles as indicated by the image link
If you want to create a new skin, the solution is as simple as this, code shown below (note that EsGUIskin is the name of the skin asset, you must create it before hand):
var myGUISkin : GUISkin;
function Start () {
myGUISkin = Resources.Load("EsGUIskin");
}
function OnGUI () {
GUI.skin = myGUISkin;
}
When I want to manipulate my custom styles with code, I usually just increase the size of the custom styles array in the inspector first. Then I access the newest GUIStyles in my code like you do in your question.
If for some reason you can’t manually increase the size first, you’d probably have to use a dynamic array to get the job done. You could convert customStyles to a dynamic array, add some styles to the array using Push(), then convert back to a builtin array.
Something like this:
var myCustomSkin : GUISkin;
var someStyle : GUIStyle;
var anotherStyle : GUIStyle;
function Start ()
{
var styleArray = new Array(myCustomSkin.customStyles);
styleArray.Push(someStyle);
styleArray.Push(anotherStyle);
myCustomSkin.customStyles = styleArray.ToBuiltin(GUIStyle);
}