I’m using GUITextures for my buttons in an iOS app. They seem to function well (when tapped they do something) however I don’t want them enabled or visible until the user taps the appropriate button to make them appear.
As of now I have a “color” button which when tapped makes a color picker appear for the user to select the desired color they would like to change on a given gameObject. The problem is in Start() I make the gameObject.active = false and each component.enabled = false which makes the GUITexture not visible however it still functions when the it’s area is tapped.
Should I just instantiate the empty gameObject with the GUITexture component to avoid this? I would think there is a way for the gameObject to just be disables/not active however it is not working for me…
Here’s the GUI script I’m using to detect touch and call to other scripts’ functions…
var color : GUITexture; //empty gameObject with GUITexture component
var cp : GameObject; //ColorPicker gameObject with GUITexture and script components
function Start() {
cp.gameObject.active = false;
cp.GetComponent(colorPickerTest).enabled = false;
cp.GetComponent(GUITexture).enabled = false;
}
function Update () {
var fingerCount = 0;
for (var touch : Touch in Input.touches) {
if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled)
fingerCount++;
}
if (fingerCount > 0) {
print ("User has " + fingerCount + " finger(s) touching the screen");
}
if (Input.touchCount>0)
{
for (var touch : Touch in Input.touches)
{
if(touch.phase == TouchPhase.Began && color.HitTest(touch.position))
{
cp.gameObject.active = true;
cp.GetComponent(colorPickerTest).enabled = true;
cp.GetComponent(GUITexture).enabled = true;
Debug.Log("TouchedColorBtn");
}
if(touch.phase == TouchPhase.Began && cs.GetComponent(GUITexture).HitTest(touch.position))
{
cs.GetComponent(ColorSwitch).colorPick();
Debug.Log("TouchColorPicker");
}
}
}
}