From e7dfbec8e8634e767d78959941daf71a96e021cf Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 7 Apr 2021 19:10:30 +0800 Subject: =?UTF-8?q?*=E7=A7=BB=E5=8A=A8=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UnityEngine.UI/UI/Core/DefaultControls.cs | 581 --------------------- 1 file changed, 581 deletions(-) delete mode 100644 Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/DefaultControls.cs (limited to 'Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/DefaultControls.cs') diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/DefaultControls.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/DefaultControls.cs deleted file mode 100644 index a22ff9a..0000000 --- a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/DefaultControls.cs +++ /dev/null @@ -1,581 +0,0 @@ -using UnityEngine; -using System.Collections.Generic; - -namespace UnityEngine.UI -{ - public static class DefaultControls - { - public struct Resources - { - public Sprite standard; - public Sprite background; - public Sprite inputField; - public Sprite knob; - public Sprite checkmark; - public Sprite dropdown; - public Sprite mask; - } - - private const float kWidth = 160f; - private const float kThickHeight = 30f; - private const float kThinHeight = 20f; - private static Vector2 s_ThickElementSize = new Vector2(kWidth, kThickHeight); - private static Vector2 s_ThinElementSize = new Vector2(kWidth, kThinHeight); - private static Vector2 s_ImageElementSize = new Vector2(100f, 100f); - private static Color s_DefaultSelectableColor = new Color(1f, 1f, 1f, 1f); - private static Color s_PanelColor = new Color(1f, 1f, 1f, 0.392f); - private static Color s_TextColor = new Color(50f / 255f, 50f / 255f, 50f / 255f, 1f); - - // Helper methods at top - - private static GameObject CreateUIElementRoot(string name, Vector2 size) - { - GameObject child = new GameObject(name); - RectTransform rectTransform = child.AddComponent(); - rectTransform.sizeDelta = size; - return child; - } - - static GameObject CreateUIObject(string name, GameObject parent) - { - GameObject go = new GameObject(name); - go.AddComponent(); - SetParentAndAlign(go, parent); - return go; - } - - private static void SetDefaultTextValues(Text lbl) - { - // Set text values we want across UI elements in default controls. - // Don't set values which are the same as the default values for the Text component, - // since there's no point in that, and it's good to keep them as consistent as possible. - lbl.color = s_TextColor; - - // Reset() is not called when playing. We still want the default font to be assigned - lbl.AssignDefaultFont(); - } - - private static void SetDefaultColorTransitionValues(Selectable slider) - { - ColorBlock colors = slider.colors; - colors.highlightedColor = new Color(0.882f, 0.882f, 0.882f); - colors.pressedColor = new Color(0.698f, 0.698f, 0.698f); - colors.disabledColor = new Color(0.521f, 0.521f, 0.521f); - } - - private static void SetParentAndAlign(GameObject child, GameObject parent) - { - if (parent == null) - return; - - child.transform.SetParent(parent.transform, false); - SetLayerRecursively(child, parent.layer); - } - - private static void SetLayerRecursively(GameObject go, int layer) - { - go.layer = layer; - Transform t = go.transform; - for (int i = 0; i < t.childCount; i++) - SetLayerRecursively(t.GetChild(i).gameObject, layer); - } - - // Actual controls - - public static GameObject CreatePanel(Resources resources) - { - GameObject panelRoot = CreateUIElementRoot("Panel", s_ThickElementSize); - - // Set RectTransform to stretch - RectTransform rectTransform = panelRoot.GetComponent(); - rectTransform.anchorMin = Vector2.zero; - rectTransform.anchorMax = Vector2.one; - rectTransform.anchoredPosition = Vector2.zero; - rectTransform.sizeDelta = Vector2.zero; - - Image image = panelRoot.AddComponent(); - image.sprite = resources.background; - image.type = Image.Type.Sliced; - image.color = s_PanelColor; - - return panelRoot; - } - - public static GameObject CreateButton(Resources resources) - { - GameObject buttonRoot = CreateUIElementRoot("Button", s_ThickElementSize); - - GameObject childText = new GameObject("Text"); - childText.AddComponent(); - SetParentAndAlign(childText, buttonRoot); - - Image image = buttonRoot.AddComponent(); - image.sprite = resources.standard; - image.type = Image.Type.Sliced; - image.color = s_DefaultSelectableColor; - - Button bt = buttonRoot.AddComponent