/// <summary> /// Constructs a ISampleAppUIElement with selected and unselected states /// param rect[] takes an array of SampleAppUIRect dimentions for drawing of all options /// param path[] takes an array of path names to load appropriate assets from Resources /// param selected specifies whether the element is in selected or unselected state /// </param> public SampleAppUICheckButton(SampleAppUIRect rect, bool selected, string[] path) { this.mRect = rect; mSelected = selected; mStyle = new GUIStyle(); mStyle.normal.background = Resources.Load(path[0]) as Texture2D; mStyle.active.background = Resources.Load(path[1]) as Texture2D; mStyle.onNormal.background = Resources.Load(path[1]) as Texture2D; }
/// <summary> /// Initializes a new instance for label /// <param name='index'> specifies relative position of the UI in the parent layout /// <param name='title'> specifies title for the UI /// <param name='style> specifies a specific GUIStyle for the UI public SampleAppUILabel(float index, string title, GUIStyle style) { mStyle = style; mTitle = title; mWidth = mStyle.normal.background.width; mHeight = mStyle.normal.background.height; SampleAppUIRect rect = new SampleAppUIRect(0, index / 800.0f, 1, Height / 800.0f); this.mRect = rect; }
/// <summary> /// Constructs a ISampleAppUIElement with selected and unselected states /// param index is a relative position of this UI in the parent layout /// param title is title for the UI /// param selected specifies whether the element is in selected or unselected state /// param style is to define a specific GUIStyle for the UI /// </param> public SampleAppUICheckButton(float index, string title, bool selected, GUIStyle style) { mTitle = title; mStyle = style; mSelected = selected; mWidth = style.normal.background.width; mHeight = style.normal.background.height; SampleAppUIRect rect = new SampleAppUIRect(0, index / 800.0f, 1, Height / 800.0f); this.mRect = rect; }
/// <summary> /// Constructs a ISampleAppUIElement with series of options to choose from; /// Only one option is selected at a time. param index specifies the relative position of UI element in the parent layout /// param selectedIs specifies which option is currently selected /// param title[,] specifies a series of title for each of the options /// param styles[,] specifies GUIStyles for all options /// </param> public SampleAppUIRadioButton(float index, int selectedId, string[] title, GUIStyle[] styles) { mIndex = index; this.mRect = new SampleAppUIRect[title.Length]; mStyle = styles; titleList = new string[title.Length]; for (int i = 0; i < title.Length; i++) { float height = mStyle[i].normal.background.height; mRect[i] = new SampleAppUIRect(0, mIndex / 800.0f, 1, height / 800.0f); mIndex += height + 2; titleList[i] = title[i]; } mOptionsTapped = new bool[title.Length]; mOptionsSelected = new bool[title.Length]; mOptionsSelected[selectedId] = true; }
/// <summary> /// Constructs a ISampleAppUIElement with series of options to choose from; /// Only one option is selected at a time. param index specifies the relative position of UI element in the parent layout /// param selectedIs specifies which option is currently selected /// param title[,] specifies a series of title for each of the options /// param styles[,] specifies GUIStyles for all options /// </param> public SampleAppUIRadioButton(float index, int selectedId, string[] title, GUIStyle[] styles) { mIndex = index; this.mRect = new SampleAppUIRect[title.Length]; mStyle = styles; titleList = new string[title.Length]; for(int i = 0; i < title.Length; i++) { float height = mStyle[i].normal.background.height; mRect[i] = new SampleAppUIRect(0, mIndex / 800.0f, 1, height / 800.0f); mIndex += height + 2; titleList[i] = title[i]; } mOptionsTapped = new bool[title.Length]; mOptionsSelected = new bool[title.Length]; mOptionsSelected[selectedId] = true; }
/// <summary> /// Constructs a ISampleAppUIElement with series of options to choose from; /// Only one option is selected at a time. param index specifies which option is set to true /// param rect[] takes an array of SampleAppUIRect dimentions for drawing of all options /// param path[,] takes an array of path names to load appropriate assets from Resources /// </param> public SampleAppUIRadioButton(SampleAppUIRect[] rect, int index, string[,] path) { if(index > rect.Length) { return; } this.mRect = rect; mStyle = new GUIStyle[rect.Length]; for(int i = 0; i < mStyle.Length; i++) { mStyle[i] = new GUIStyle(); mStyle[i].normal.background = Resources.Load(path[i,0]) as Texture2D; mStyle[i].active.background = Resources.Load(path[i,1]) as Texture2D; mStyle[i].onNormal.background = Resources.Load(path[i,1]) as Texture2D; } mOptionsTapped = new bool[rect.Length]; mOptionsSelected = new bool[rect.Length]; mOptionsSelected[index] = true; }
/// <summary> /// Initializes a new instance for label /// <param name='rect'> specifies label size /// <param name='path'> specifies path for assets to load from Resources public SampleAppUILabel(SampleAppUIRect rect, string path) { this.mRect = rect; mStyle = new GUIStyle(); mStyle.normal.background = Resources.Load(path) as Texture2D; }