Question by
QuadJasper · Aug 24, 2018 at 12:45 AM ·
c#scripting problemanimatorboolean
Script Variable not transfering
Hi so I have tried making two scripts that have a variable going back and fourth between them. The purpose of these scripts is to make an animation variable change when a button is pushed. Thanks for your interest and have a great day! :D
Receiving Code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Fader : MonoBehaviour {
Animator animator;
public GameObject OptionsAndTransitionObject;
public void FixedUpdate()
{
OptionsTitleTransition optionsTitleTransition = OptionsAndTransitionObject.GetComponent<OptionsTitleTransition>();
animator = GetComponent<Animator>();
if (optionsTitleTransition.Transition)
{
animator.SetBool("switch", true);
}
}
}
Button Code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class OptionsTitleTransition : MonoBehaviour
{
public bool Transition;
void TaskOnClick()
{
Transition = true;
}
}
Comment
Your answer
Follow this Question
Related Questions
How Can i Get This bool to work? Just need someone willing to explain. 2 Answers
Delay while using GetButtonDown and Animator 0 Answers
Help please, movement and animator issue 0 Answers
PLEAASEE I NEED HELP!!! How to turn Mesh Renderer of cubes on and off by pushing buttons? 1 Answer
Movement and Jump with animator 0 Answers