Heyy, im trying to code a UI dropdown which will allow player to switch his turning controls from snap to continuous and vice versa.
I want to achieve this by simply turning off these components in the locomotion but Im not sure how to reference them, I tried, but SetActive didn’t seem to work. Would kindly appreciate any info
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.XR.Interaction.Toolkit;
public class UI_Turning : MonoBehaviour
{
public TMPro.TMP_Dropdown dropdown;
// TRYING TO REFERENCE LOCOMOTION COMPONENTS
public GameObject locomotion;
public ActionBasedSnapTurnProvider snapTurn;
public ActionBasedContinuousTurnProvider continuousTurn;
void Start()
{
snapTurn = locomotion.GetComponent<ActionBasedSnapTurnProvider>();
continuousTurn = locomotion.GetComponent<ActionBasedContinuousTurnProvider>();
}
public void TurningOptions()
{
// TRYING TO DISABLE / ENABLE COMPONENTS IN LOCOMOTION
if (dropdown.value == 0)
{
Debug.Log("Continuous turning options");
locomotion.GetComponent<ActionBasedSnapTurnProvider>().enabled = false;
locomotion.GetComponent<ActionBasedContinuousTurnProvider>().enabled = true;
}
if (dropdown.value == 1)
{
Debug.Log("Snap turning options");
locomotion.GetComponent<ActionBasedSnapTurnProvider>().enabled = true;
locomotion.GetComponent<ActionBasedContinuousTurnProvider>().enabled = false;
}
}
}