- Home /
Question by
dragon6238 · Feb 25, 2019 at 01:25 PM ·
scripting problemui
UI Button doesn't change interactable to false
I can't seem to turn off the interactable to false. Weirdly enough the button itself gets detected and if i try to deactivate it and activate it later, the console tells me the object is destroyed. I have this attached to one of the storyline scripts.
using UnityEngine;
using System.Collections;
using System;
public class Storyline2Actions
{
public static void HandleAction(int index, MonoBehaviour mb)
{
switch(index)
{
case 0:
TimeManager.SetTime(0);
string text = GameObject.FindObjectOfType<StoryHandler>().dialogs[1].textDialogContent.text;
GameObject.FindObjectOfType<StoryHandler>().dialogs[1].textDialogContent.text = text.Replace("INTERACTKEY",
SetupKeysDialog.GetKeyCode(SetupKeysDialog.INTERACT_KEY).ToString());
break;
case 1:
mb.StartCoroutine(TeleportToTutorialPoint());
mb.StartCoroutine(NextMessageOnceDrain());
break;
case 3:
mb.StartCoroutine(MoveDown());
break;
case 4:
mb.StartCoroutine(NextMessageOnceThere());
break;
}
}
private static IEnumerator NextMessageOnceDrain()
{
while (GameObject.Find("Tutorial Victim") != null)
{
yield return new WaitForSeconds(1);
}
StoryManager.storyline.storylineScript.SendMessage("ShowNextMessage");
}
static IEnumerator MoveDown()
{
characterManager.automated = true;
characterManager.direction = Vector3.down;
yield return new WaitForSeconds(1f);
characterManager.frozen = true;
characterManager.automated = false;
}
private static IEnumerator NextMessageOnceThere()
{
Vector3 location = new Vector3(0.8f , -1.5f, 0f);
while ((location - characterManager.trans.position).magnitude > 0.2f)
{
yield return new WaitForSeconds(Time.deltaTime);
}
StoryManager.storyline.storylineScript.SendMessage("ShowNextMessage");
}
static IEnumerator TeleportToTutorialPoint()
{
SceneFader.sceneClear = false;
GameObject.Find("ContinueButton").GetComponent<UnityEngine.UI.Button>().interactable = false;
yield return new WaitForSeconds(1f);
characterManager.trans.position = GameObject.Find("Tutorial point").transform.position;
yield return new WaitForSeconds(1f);
GameObject.Find("background_fader").GetComponent<SpriteRenderer>().color -= Color.black;
SceneFader.sceneClear = true;
characterManager.frozen = false;
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612192433im_/https://answers.unity.com/themes/thub/images/avi.jpg)