- Home /
Question by
RobynAustin · Oct 28, 2017 at 06:26 PM ·
guibutton
TRIGGER EVENT NOT WORKING WITH ANIMATED UI!
Hey there!! I have been following a tutorial on Youtube on how to make a "holographic UI" appear on a distance trigger. I will link the tutorial here:
https://www.youtube.com/watch?v=GlRLhwvT6rY&t=927s
However this script does not seem to allow me to create the trigger event. Nothing happens, the animation just loops through.
public float minDistance = 2;
public bool show = false;
protected Animator[] children;
void Start () {
children = GetComponentsInChildren();
for (int a = 0; a < children.Length; a++)
{
children[a].SetBool("Show", true);
}
}
void Update () {
Vector3 delta = Camera.main.transform.position - transform.position;
if (delta.magnitude < minDistance)
{
if (show) return;
show = true;
for (int a = 0; a < children.Length; a++)
{
children[a].SetBool("Show",true);
}
}
else
{
if (!show) return;
show = false;
for (int a = 0; a < children.Length; a++)
{
children[a].SetBool("Show", false);
}
}
}
}
I am used the latest version of unity.
Whats wrong here? :(
Comment
Your answer
Follow this Question
Related Questions
Problem with UI in iOS / Android 1 Answer
GUI does not contain a definition for `skin' ? 1 Answer
GUI Button within if statement doesn't disappear even when the if statement is false 2 Answers
How to Disable GUI Button Immediately After Click 1 Answer
How to detect if a button is continuosly being PRESSED? 1 Answer