- Home /
System.Type does not support slicing
// These are the values for the MODULES grids //Head grid var Head12 = Texture2D;
var Head22 = Texture2D;
var Head11 = Texture2D;
var Head21 = Texture2D;
var HeadGridIcons = Array[Head12,Head22,Head11,Head21];
function OnGUI()
{ if (DisplayCharacter)
{
// This is the MODULES panel
GUI.skin = MenuSkin;
GUI.BeginGroup(new Rect(Screen.width*0.1,Screen.height*0.1,Screen.width*0.2,Screen.height*0.8));
GUI.Box(Rect(0,0,Screen.width*0.2,Screen.height*0.8),"");
// Head grid
GUI.Label (Rect (Screen.width*0.088,Screen.height*0.05,Screen.width*0.05,Screen.height*0.1), "Head");
selGridInt = GUI.SelectionGrid (Rect (Screen.width*0.065, Screen.height*0.085, Screen.width*0.07, Screen.width*0.07), selGridInt, HeadGridIcons, 2);
^This is my script. I'm trying to make a grid that accepts 2D textures which can be assigned otherwise. Could someone please show me the way?
BTW, i removed some elements of the script unrelated to the problem. The above were what caused my script to mess up.
Answer by robertbu · Aug 24, 2014 at 03:19 PM
Change line 7 to:
var HeadGridIcons : Texture2D[] = [Head12,Head22,Head11,Head21];
Do not use the Array class. It is slow, untyped.
ok, that fixed the slicing problem
but now i get a new error: Cannot convert 'System.Type[]' to 'UnityEngine.Texture2D[]'
On lines 1, 3, and 5, the '=' should be a ':' Example:
var Head22 : Texture2D;
Your answer
Follow this Question
Related Questions
GUI only showing texture of the newest addition in the array. Help? 1 Answer
Attempting to change SetTexture("_DetailAlbedoMap", randomTexture) In children? 0 Answers
Switching Texture of menu Item locked/unlocked IOS 1 Answer
Deleting an Element from an Array. 1 Answer
Add scripts from Resources? 0 Answers