using System; using System.Collections.Generic; using UIPanels; using UnityEngine; using UnityEngine.UI; using static System.Net.Mime.MediaTypeNames; public class ModelViewerInterface : MonoBehaviour { public static ModelViewerInterface _mainInstance; public Transform DynamicPanels; public TMPro.TMP_Text[] TooltipLabels; public ScrollRect ScenePresetToggle; public ScrollRect PosePresetToggle; public List TopbarPanels; public UIPanels.UIToolbarPanel TogglesContent; public UIPanels.UISaveLoadPanel SaveLoadPanel; public UIPanels.UICameraSettingsPanel CameraSettingsPanel; public Canvas MainCanvas; public RectTransform Tooltip; public TMPro.TextMeshProUGUI TooltipText; public static ModelViewerInterface GetInstance() { return _mainInstance; } public static T GetInstance() where T : ModelViewerInterface { return _mainInstance as T; } public static void SetTooltip(int index, string tooltip) { var tooltips = GetInstance().TooltipLabels; if(tooltips.Length > index) { tooltips[index].SetText(tooltip); } } public static void ToggleVisible(GameObject go) { ToggleVisible(go, false); } public static void ToggleVisible(GameObject go, bool force = false, bool forceValue = false) { if (force) { go.SetActive(forceValue); } else { go.SetActive(!go.activeSelf); } } public static void SetDropdownData(TMPro.TMP_Dropdown dd, List values, bool nullValue = false, bool sortValues = false) { dd.ClearOptions(); if (nullValue) dd.AddOptions(new List() { Strings.NoValueSelectedString }); if (values != null) { if (sortValues) { values = new List(values); values.Sort(); } dd.AddOptions(values); } } public static void DropdownPrevious(TMPro.TMP_Dropdown dropdown) { Error.Log(Color.red, "Remove this"); dropdown.value = dropdown.value - 1 < 0 ? dropdown.options.Count - 1 : dropdown.value - 1; } public static void DropdownNext(TMPro.TMP_Dropdown dropdown) { Error.Log(Color.red, "Remove this"); dropdown.value = dropdown.value + 1 >= dropdown.options.Count ? 0 : dropdown.value + 1; } }