- Home /
Question by
Trild123787898 · Feb 03, 2020 at 01:59 PM ·
buttonscript.
problem when clicking on Button
I can’t understand why it doesn’t want to work, if I click on the Button, it should work the script inside FixedUpdate, but for some reason it doesn’t want to do it, if I press the key then everything works, I use event tigger (pointer down, up), what is the problem?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class TestScript : MonoBehaviour
{
public ConfigurableJoint confdet5;
private bool click;
void Start()
{
confdet5 = gameObject.GetComponent<ConfigurableJoint>();
}
public void TaskOn()
{
click = true;
}
public void TaskOn2()
{
click = false;
}
void FixedUpdate()
{
if (click == true)
{
confdet5.angularYMotion = ConfigurableJointMotion.Free;
}
if (click == false)
{
confdet5.angularYMotion = ConfigurableJointMotion.Locked;
}
}
}
Comment
what happens if you add debug.log to all those functions?
So when you add Print(); like this
if (click == true)
{
confdet5.angularY$$anonymous$$otion = ConfigurableJoint$$anonymous$$otion.Free;
print("clicked");
}
and click the button console displays "clicked"?
Your answer

Follow this Question
Related Questions
how can I disapear a button after push? 1 Answer
GUI Button scripting 0 Answers
Execution order of ui button click function and update 0 Answers
Button onClick based on image (sprite) on Button 1 Answer
Button press for Animations 1 Answer