Posts

Showing posts with the label ui

UI in VR / XR

Remember to use the XR version of the Canvas UI -  it comes with the necessary components for it to interact with your VR controllers.  Also double check your Event System and delete the "StandaloneInputModule" if there is one already. According to the manual, it could disrupt the VR controllers from doing their thing.

slider UI event/functions

Here's a way to get sliders to control VFX graph values   using UnityEngine; using System.Collections; using UnityEngine.UI; // Required when Using UI elements. using UnityEngine.VFX; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; public class slider_ctrl : MonoBehaviour {     public Slider _mainSlider;     public VisualEffect _visualEffect;     public Volume _volume;     [SerializeField]     private float _whateverValue = 0;     public void Start()     {         //Adds a listener to the main slider and invokes a method when the value changes.         _mainSlider.onValueChanged.AddListener(delegate { ValueChangeCheck(); });     }     // Invoked when the value of the slider changes.     public void ValueChangeCheck()     { ...

button UI event/functions

Clicking Buttons and having things happen. So, you're able to drag objects and create UI events in the Inspector..but I think this type of scripting is perhaps a bit quicker/precise? Code was lifted from the official Unity page. Make 3 button UI objects and add this script to an empty gameobject/or anything.   using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class button_tut : MonoBehaviour {     public Button _firstButton, _secondButton, _thirdButton;     //public Camera _cam;     public GameObject _cube;     // Start is called before the first frame update     void Start()     {        //setup various listener function things on the "onclick", per button         _firstButton.onClick.AddListener(TaskOnClick);         _secondButton.onCli...