vfx and ui init

This commit is contained in:
ntr committed 2023-07-04 20:53:27 +10:00
1 parent 0daeae4b55
commit 24729cec2c
91 files changed
+213555 -22

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
using UnityEngine;
using UnityEngine.UIElements;
public class SimpleRuntimeUi : MonoBehaviour {
private Button _button;
private Toggle _toggle;
private int _clickCount;
//Add logic that interacts with the UI controls in the `OnEnable` methods
private void OnEnable() {
// The UXML is already instantiated by the UIDocument component
var uiDocument = GetComponent<UIDocument>();
_button = uiDocument.rootVisualElement.Q("button") as Button;
_toggle = uiDocument.rootVisualElement.Q("toggle") as Toggle;
_button.RegisterCallback<ClickEvent>(PrintClickMessage);
var _inputFields = uiDocument.rootVisualElement.Q("input-message");
_inputFields.RegisterCallback<ChangeEvent<string>>(InputMessage);
}
private void OnDisable() {
_button.UnregisterCallback<ClickEvent>(PrintClickMessage);
}
private void PrintClickMessage(ClickEvent evt) {
++_clickCount;
Debug.Log($"{"button"} was clicked!" +
(_toggle.value ? " Count: " + _clickCount : ""));
}
public static void InputMessage(ChangeEvent<string> evt) {
Debug.Log($"{evt.newValue} -> {evt.target}");
}
}