Question by
Sylphynford · Feb 12, 2017 at 05:42 PM ·
guistringintswitch
Output string to GUI using int switch case
Hi, I'm currently trying to convert int values to string values that can be used in Unity's GUI canvas. However, my code still only shows the int value on the GUI when "plane" value is changed.
public static int plane;
const string isTop = "Top";
const string isCenter = "Center";
const string isBottom = "Bottom";
public virtual string WhatPlane()
{
switch (plane)
{
case 0:
return isTop;
case 1:
return isCenter;
case 2:
return isBottom;
default:
break;
}
return null;
}
Comment
where are you setting the text on the GUI?
in your code, you could easily replace it with an array and use plane
as an index