diff options
Diffstat (limited to 'Runtime/Export/GUISkinBindings.txt')
-rw-r--r-- | Runtime/Export/GUISkinBindings.txt | 341 |
1 files changed, 341 insertions, 0 deletions
diff --git a/Runtime/Export/GUISkinBindings.txt b/Runtime/Export/GUISkinBindings.txt new file mode 100644 index 0000000..bc6fcca --- /dev/null +++ b/Runtime/Export/GUISkinBindings.txt @@ -0,0 +1,341 @@ +C++RAW + +#include "UnityPrefix.h" +#include "Runtime/Misc/InputEvent.h" +#include "Runtime/Scripting/ScriptingUtility.h" + +CSRAW +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Collections; +using System.Collections.Generic; + +namespace UnityEngine +{ + + + +// Which platform to emulate. +ENUM internal PlatformSelection + // The behaviour matches the platform the end user is running on. + Native = 0, + // The behaviour matches a Mac OS X machine. + Mac = 1, + // The behaviour matches a Windows machine. + Windows = 2, +END + +// General settings for how the GUI behaves +CSRAW [System.Serializable] +CLASS GUISettings + // Should double-clicking select words in text fields. + CSRAW public bool doubleClickSelectsWord { get { return m_DoubleClickSelectsWord; } set { m_DoubleClickSelectsWord = value; } } + CSRAW [SerializeField] + CSRAW bool m_DoubleClickSelectsWord = true; + + // Should triple-clicking select whole text in text fields. + CSRAW public bool tripleClickSelectsLine { get { return m_TripleClickSelectsLine; } set { m_TripleClickSelectsLine = value; } } + CSRAW [SerializeField] + CSRAW bool m_TripleClickSelectsLine = true; + + // The color of the cursor in text fields. + CSRAW public Color cursorColor { get { return m_CursorColor; } set { m_CursorColor = value; } } + CSRAW [SerializeField] + CSRAW Color m_CursorColor = Color.white; + + CUSTOM private static float Internal_GetCursorFlashSpeed () { + #if UNITY_OSX && !UNITY_64 + return 60.0f / GetCaretTime(); + #elif UNITY_WIN && !UNITY_WINRT + return 1000.0f / GetCaretBlinkTime(); + #elif UNITY_WII || UNITY_XENON || UNITY_PS3 || UNITY_IPHONE || UNITY_ANDROID || UNITY_PEPPER || UNITY_LINUX || UNITY_FLASH || UNITY_WEBGL || UNITY_WINRT || UNITY_OSX || UNITY_BB10 || UNITY_TIZEN + return 2.0f; + #else + #error "Unknown platform" + #endif + } + + // The speed of text field cursor flashes. + CSRAW public float cursorFlashSpeed { get { + if (m_CursorFlashSpeed >= 0) + return m_CursorFlashSpeed; + else { + return Internal_GetCursorFlashSpeed (); + } + } + set { m_CursorFlashSpeed = value; } } + CSRAW [SerializeField] + CSRAW float m_CursorFlashSpeed = -1; + + // The color of the selection rect in text fields. + CSRAW public Color selectionColor { get { return m_SelectionColor; } set { m_SelectionColor = value; } } + CSRAW [SerializeField] + CSRAW Color m_SelectionColor = new Color (.5f, .5f, 1f); + + // Which platform to match for keyboard focus rules. + // If keyboardFocus is Mac, only text entry labels will be able to revcieve the keyboard focus through tabbing. (GUI.TextField, GUI.TextArea, GUILayout.TextField, GUILayout.TextArea) + // If keyboardFocus is Windows, most controls can be tabbed through. If the end user presses the space bar, the focused control will recieve a mouse click. + // If keyboardFocus is Native, the focus rules will follow whatever platform the end user is running on. +// CSRAW public PlatformSelection keyboardFocus { get { return m_KeyboardFocus; } set { m_KeyboardFocus = value; } } +// CSRAW PlatformSelection m_KeyboardFocus = PlatformSelection.Native; +END + + + +// Defines how GUI looks and behaves. +CSRAW [System.Serializable] +CSRAW [ExecuteInEditMode] +CLASS GUISkin : ScriptableObject + CSRAW [SerializeField] + CSRAW Font m_Font; + + // *undocumented* + CSRAW public GUISkin() + { + m_CustomStyles = new GUIStyle[1]; + } + + CSRAW internal void OnEnable() + { + Apply (); + + foreach (var style in styles.Values) + style.CreateObjectReferences (); + } + + // The default font to use for all styles. + CSRAW public Font font { get { return m_Font; } set { m_Font = value; if (current == this) GUIStyle.SetDefaultFont(m_Font); Apply();} } + + CSRAW [SerializeField] //yes the attribute applies to all fields on the line below. + CSRAW GUIStyle m_box, m_button, m_toggle, m_label, m_textField, m_textArea, m_window; + + // Style used by default for GUI::ref::Box controls. + CSRAW public GUIStyle box { get { return m_box; } set { m_box = value; Apply (); } } + + // Style used by default for GUI::ref::Label controls. + CSRAW public GUIStyle label { get { return m_label; } set { m_label = value; Apply (); } } + + // Style used by default for GUI::ref::TextField controls. + CSRAW public GUIStyle textField { get { return m_textField; } set { m_textField = value; Apply (); } } + + // Style used by default for GUI::ref::TextArea controls. + CSRAW public GUIStyle textArea { get { return m_textArea; } set { m_textArea = value; Apply (); } } + + // Style used by default for GUI::ref::Button controls. + CSRAW public GUIStyle button { get { return m_button; } set { m_button = value; Apply (); } } + + // Style used by default for GUI::ref::Toggle controls. + CSRAW public GUIStyle toggle { get { return m_toggle; } set { m_toggle = value; Apply (); } } + + // Style used by default for Window controls (SA GUI::ref::Window). + CSRAW public GUIStyle window { get { return m_window; } set { m_window = value; Apply (); } } + + CSRAW + [SerializeField] + GUIStyle m_horizontalSlider; + [SerializeField] + GUIStyle m_horizontalSliderThumb; + [SerializeField] + GUIStyle m_verticalSlider; + [SerializeField] + GUIStyle m_verticalSliderThumb; + + // Style used by default for the background part of GUI::ref::HorizontalSlider controls. + CSRAW public GUIStyle horizontalSlider { get { return m_horizontalSlider; } set { m_horizontalSlider = value; Apply (); } } + + // Style used by default for the thumb that is dragged in GUI::ref::HorizontalSlider controls. + CSRAW public GUIStyle horizontalSliderThumb { get { return m_horizontalSliderThumb; } set { m_horizontalSliderThumb = value; Apply (); } } + + // Style used by default for the background part of GUI::ref::VerticalSlider controls. + CSRAW public GUIStyle verticalSlider { get { return m_verticalSlider; } set { m_verticalSlider = value; Apply (); } } + + // Style used by default for the thumb that is dragged in GUI::ref::VerticalSlider controls. + CSRAW public GUIStyle verticalSliderThumb { get { return m_verticalSliderThumb; } set { m_verticalSliderThumb = value; Apply (); } } + + CSRAW + [SerializeField] + GUIStyle m_horizontalScrollbar; + [SerializeField] + GUIStyle m_horizontalScrollbarThumb; + [SerializeField] + GUIStyle m_horizontalScrollbarLeftButton; + [SerializeField] + GUIStyle m_horizontalScrollbarRightButton; + + // Style used by default for the background part of GUI::ref::HorizontalScrollbar controls. + CSRAW public GUIStyle horizontalScrollbar { get { return m_horizontalScrollbar; } set { m_horizontalScrollbar = value; Apply (); } } + // Style used by default for the thumb that is dragged in GUI::ref::HorizontalScrollbar controls. + CSRAW public GUIStyle horizontalScrollbarThumb { get { return m_horizontalScrollbarThumb; } set { m_horizontalScrollbarThumb = value; Apply (); } } + // Style used by default for the left button on GUI::ref::HorizontalScrollbar controls. + CSRAW public GUIStyle horizontalScrollbarLeftButton { get { return m_horizontalScrollbarLeftButton; } set { m_horizontalScrollbarLeftButton = value; Apply (); } } + // Style used by default for the right button on GUI::ref::HorizontalScrollbar controls. + CSRAW public GUIStyle horizontalScrollbarRightButton { get { return m_horizontalScrollbarRightButton; } set { m_horizontalScrollbarRightButton = value; Apply (); } } + + CSRAW + [SerializeField] + GUIStyle m_verticalScrollbar; + [SerializeField] + GUIStyle m_verticalScrollbarThumb; + [SerializeField] + GUIStyle m_verticalScrollbarUpButton; + [SerializeField] + GUIStyle m_verticalScrollbarDownButton; + + // Style used by default for the background part of GUI::ref::VerticalScrollbar controls. + CSRAW public GUIStyle verticalScrollbar { get { return m_verticalScrollbar; } set { m_verticalScrollbar = value; Apply (); } } + // Style used by default for the thumb that is dragged in GUI::ref::VerticalScrollbar controls. + CSRAW public GUIStyle verticalScrollbarThumb { get { return m_verticalScrollbarThumb; } set { m_verticalScrollbarThumb = value; Apply (); } } + // Style used by default for the up button on GUI::ref::VerticalScrollbar controls. + CSRAW public GUIStyle verticalScrollbarUpButton { get { return m_verticalScrollbarUpButton; } set { m_verticalScrollbarUpButton = value; Apply (); } } + // Style used by default for the down button on GUI::ref::VerticalScrollbar controls. + CSRAW public GUIStyle verticalScrollbarDownButton { get { return m_verticalScrollbarDownButton; } set { m_verticalScrollbarDownButton = value; Apply (); } } + + // Background style for scroll views. + CSRAW [SerializeField] + CSRAW GUIStyle m_ScrollView; + + // Style used by default for the background of ScrollView controls (see GUI::ref::BeginScrollView). + CSRAW public GUIStyle scrollView { get { return m_ScrollView; } set { m_ScrollView = value; Apply (); } } + + CSRAW [SerializeField] + CSRAW internal GUIStyle[] m_CustomStyles; + + // Array of GUI styles for specific needs. + CSRAW public GUIStyle[] customStyles { get { return m_CustomStyles; } set { m_CustomStyles = value; Apply(); } } + + + CSRAW [SerializeField] + CSRAW private GUISettings m_Settings = new GUISettings (); + + // Generic settings for how controls should behave with this skin. + CSRAW public GUISettings settings { get { return m_Settings; } } + + CSRAW internal static GUIStyle ms_Error; + CSRAW internal static GUIStyle error { get { if(ms_Error == null) ms_Error = new GUIStyle(); return ms_Error; } } + + CSRAW private Dictionary<string, GUIStyle> styles = null; + + CSRAW internal void Apply () + { + if (m_CustomStyles == null) + Debug.Log("custom styles is null"); + + BuildStyleCache (); + } + + + CSRAW private void BuildStyleCache () { + + if (m_box == null) m_box = new GUIStyle(); + if (m_button == null) m_button = new GUIStyle(); + if (m_toggle == null) m_toggle = new GUIStyle(); + if (m_label == null) m_label = new GUIStyle(); + if (m_window == null) m_window = new GUIStyle(); + if (m_textField == null) m_textField = new GUIStyle(); + if (m_textArea == null) m_textArea = new GUIStyle(); + if (m_horizontalSlider == null) m_horizontalSlider = new GUIStyle(); + if (m_horizontalSliderThumb == null) m_horizontalSliderThumb = new GUIStyle(); + if (m_verticalSlider == null) m_verticalSlider = new GUIStyle(); + if (m_verticalSliderThumb == null) m_verticalSliderThumb = new GUIStyle(); + if (m_horizontalScrollbar == null) m_horizontalScrollbar = new GUIStyle(); + if (m_horizontalScrollbarThumb == null) m_horizontalScrollbarThumb = new GUIStyle(); + if (m_horizontalScrollbarLeftButton == null) m_horizontalScrollbarLeftButton = new GUIStyle(); + if (m_horizontalScrollbarRightButton == null) m_horizontalScrollbarRightButton = new GUIStyle(); + if (m_verticalScrollbar == null) m_verticalScrollbar = new GUIStyle(); + if (m_verticalScrollbarThumb == null) m_verticalScrollbarThumb = new GUIStyle(); + if (m_verticalScrollbarUpButton == null) m_verticalScrollbarUpButton = new GUIStyle(); + if (m_verticalScrollbarDownButton == null) m_verticalScrollbarDownButton = new GUIStyle(); + if (m_ScrollView == null) m_ScrollView = new GUIStyle(); + + styles = new Dictionary<string, GUIStyle>( +#if !UNITY_FLASH + System.StringComparer.OrdinalIgnoreCase +#endif + ); + + styles["box"] = m_box; m_box.name = "box"; + styles["button"] = m_button; m_button.name = "button"; + styles["toggle"] = m_toggle; m_toggle.name = "toggle"; + styles["label"] = m_label; m_label.name = "label"; + styles["window"] = m_window; m_window.name = "window"; + styles["textfield"] = m_textField; m_textField.name = "textfield"; + styles["textarea"] = m_textArea; m_textArea.name = "textarea"; + + styles["horizontalslider"] = m_horizontalSlider; m_horizontalSlider.name = "horizontalslider"; + styles["horizontalsliderthumb"] = m_horizontalSliderThumb; m_horizontalSliderThumb.name = "horizontalsliderthumb"; + styles["verticalslider"] = m_verticalSlider; m_verticalSlider.name = "verticalslider"; + styles["verticalsliderthumb"] = m_verticalSliderThumb; m_verticalSliderThumb.name = "verticalsliderthumb"; + + styles["horizontalscrollbar"] = m_horizontalScrollbar; m_horizontalScrollbar.name = "horizontalscrollbar"; + styles["horizontalscrollbarthumb"] = m_horizontalScrollbarThumb; m_horizontalScrollbarThumb.name = "horizontalscrollbarthumb"; + styles["horizontalscrollbarleftbutton"] = m_horizontalScrollbarLeftButton; m_horizontalScrollbarLeftButton.name = "horizontalscrollbarleftbutton"; + styles["horizontalscrollbarrightbutton"] = m_horizontalScrollbarRightButton; m_horizontalScrollbarRightButton.name = "horizontalscrollbarrightbutton"; + styles["verticalscrollbar"] = m_verticalScrollbar; m_verticalScrollbar.name = "verticalscrollbar"; + styles["verticalscrollbarthumb"] = m_verticalScrollbarThumb; m_verticalScrollbarThumb.name = "verticalscrollbarthumb"; + styles["verticalscrollbarupbutton"] = m_verticalScrollbarUpButton; m_verticalScrollbarUpButton.name = "verticalscrollbarupbutton"; + styles["verticalscrollbardownbutton"] = m_verticalScrollbarDownButton; m_verticalScrollbarDownButton.name = "verticalscrollbardownbutton"; + styles["scrollview"] = m_ScrollView; m_ScrollView.name = "scrollview"; + + if (m_CustomStyles != null) + { + for (int i=0;i<m_CustomStyles.Length;i++) + { + if (m_CustomStyles[i] == null) + continue; + styles[m_CustomStyles[i].name] = m_CustomStyles[i]; + } + } + error.stretchHeight = true; + error.normal.textColor = Color.red; + } + + // Get a named [[GUIStyle]]. + CSRAW public GUIStyle GetStyle (string styleName) { + GUIStyle s = FindStyle (styleName); + if (s != null) + return s; + Debug.LogWarning ("Unable to find style '" + styleName + "' in skin '" + name + "' " + Event.current.type); + return error; + } + + // Try to search for a [[GUIStyle]]. This functions returns NULL and does not give an error. + CSRAW public GUIStyle FindStyle (string styleName) { + if (this == null) { + Debug.LogError ("GUISkin is NULL"); + return null; + } + if (styles == null) + BuildStyleCache (); + + GUIStyle style; + if (styles.TryGetValue(styleName, out style)) + return style; + + return null; + } + + CSRAW + internal delegate void SkinChangedDelegate(); + internal static SkinChangedDelegate m_SkinChanged; + + // Make this the current skin used by the GUI + static internal GUISkin current; + CSRAW internal void MakeCurrent () { + current = this; + GUIStyle.SetDefaultFont (font); + if (m_SkinChanged != null) + m_SkinChanged(); + } + + //*undocumented* Documented separately + CSRAW public IEnumerator GetEnumerator () + { + if (styles == null) + BuildStyleCache (); + return (IEnumerator)styles.Values.GetEnumerator (); + } +END + + +} |