34 lines
887 B
C#
34 lines
887 B
C#
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.UIElements;
|
||
|
|
||
|
namespace BITKit.UX
|
||
|
{
|
||
|
public class UXPhotoMode : MonoBehaviour
|
||
|
{
|
||
|
[SerializeField] private UIDocument document;
|
||
|
[UXBindPath("photo-mode-toggle")]
|
||
|
private Toggle _photoModeToggle;
|
||
|
|
||
|
private VisualElement[] _visualElements=Array.Empty<VisualElement>();
|
||
|
private void Start()
|
||
|
{
|
||
|
UXUtils.Inject(this);
|
||
|
_photoModeToggle.RegisterValueChangedCallback(OnValueChanged);
|
||
|
OnValueChanged(ChangeEvent<bool>.GetPooled(false,_photoModeToggle.value));
|
||
|
_visualElements = document.rootVisualElement.Query<VisualElement>(className:"photo-mode").ToList().ToArray();
|
||
|
}
|
||
|
|
||
|
private void OnValueChanged(ChangeEvent<bool> evt)
|
||
|
{
|
||
|
foreach (var x in _visualElements)
|
||
|
{
|
||
|
x.style.visibility=!evt.newValue?Visibility.Visible:Visibility.Hidden;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|