void Draw(Rect a) { GUI.skin = skin; GUI.skin.FontSize(fontSize); GUIContent c; if (tex == null) { c = new GUIContent(message); } else { c = new GUIContent(message, tex); } GUIF.Box(a, c); if (GUIF.Button(a.BottomCenter(.3f, .2f).MoveUp(.1f), "Ok")) { dismissed = true; slider.Slide(direction.Flip(), slidePower); } GUIF.InvisibleButton(ScreenF.all); }
public new void Draw(Component caller) { clicked = false; if (GUIF.SButton(area, content)) { clicked = true; Call(caller); } }
void OnGUI() { GUI.skin = skin; GUI.depth = depth; Color c = sets.color; c.a = time / sets.fadeTime; GUI.color = c; GUIStyle style = GUI.skin.label.FontSize(fontSize); Vector2 size = style.CalcSize(new GUIContent(message)); //Vector2 size = new Vector2(1, 1); //size.x += GUI.skin.box.padding.left + GUI.skin.box.padding.right + 2; //size.y += GUI.skin.box.padding.top + GUI.skin.box.padding.bottom + 2; //position -= size * .5f; //Debug.Log(size); /* * size.x /= Screen.width; * size.y /= Screen.height; * Rect area = new Rect(position.x, position.y, size.x, size.y); * area.x -= size.x *.5f; * area.y -= size.y *.5f; * msg.Draw(area); * //*/ //* Rect area = new Rect(position.x * Screen.width, position.y * Screen.height, size.x, size.y); area = area.Pad(4.0f); area = area.Move(-.5f, -.5f); if (outlined) { GUIF.Label(area, message, style); } else { GUI.Label(area, message, style); } //*/ }
public static bool ToggleButton(Rect area, string str, bool val, float padding, string sound) { bool ret = val; Color color = GUI.color; Color c = color; if (!val) { c = c.Half(); } GUI.color = c; if (GUIF.Button(area, str, padding, sound)) { ret = !ret; } GUI.color = color; return(ret); }
void OnGUI() { Rect brush = transform.ToScreenArea(area.width, area.height); brush.x += area.x * Screen.width; brush.y += area.y * Screen.height; GUIStyle style = GUI.skin.label.Aligned(TextAnchor.MiddleCenter).FontSize(fontSize); GUI.color = color; GUIStyle prevStyle = GUI.skin.label; GUI.skin.label = style; GUIF.Label(brush, label, outline); GUI.skin.label = prevStyle; }
void OnGUI() { if (skin != "") { GUI.skin = GUISkins.Get(skin); } GUI.depth = depth; Rect brush = area; //Debug.Log("dicks"); Bars.graphic = tex; Bars.Draw(brush, repeat, val, tint, back, padding); if (message != "") { GUI.color = messageTint; GUIF.Label(brush, message); } }
void OnGUI() { GUI.depth = -100000; GUI.skin = skin; GUI.skin.FontSize(fontSize); GUIContent content; if (tex == null) { content = new GUIContent(tickMessage, tex); } else { content = new GUIContent(tickMessage); } Color col = color; if (fading) { col.a = alpha; } GUI.color = col; Rect brush = area.Denormalized(); if (isBox) { GUIF.Box(brush, content, padding); } else { GUIF.Label(brush, content, padding); } }
public void OnSetSelectGUI() { #if !UNITY_WEBPLAYER GUIF.Button(new Rect(Screen.width * 0.01f, Screen.height * 0.01f, Screen.width * 0.4f, Screen.height * 0.075f), "Quit", () => { #if UNITY_EDITOR EditorApplication.isPlaying = false; #else Application.Quit(); #endif }); #endif Rect scrollArea = new Rect(Screen.width * 0.01f, Screen.height * 0.1f, Screen.width * 0.98f, Screen.height * 0.85f); float lineHeight = GUI.skin.button.LineSize() * 1.33f; Rect brush = new Rect(0.0f, 0.0f, scrollArea.width - 24, lineHeight); scrollPos = GUI.BeginScrollView(scrollArea, scrollPos, new Rect(0, 0, Screen.width * 0.9f - 24, lineHeight * 1.05f * soundSets.Count)); { brush.y = (int)(scrollPos.y / (brush.height * 1.05f)) * (brush.height * 1.05f); for (int i = (int)Mathf.Max(scrollPos.y / (brush.height * 1.05f), 0); scrollPos.y >= ((i - 1) * brush.height * 1.05f) - scrollArea.height && i < soundSets.Count; i++) { string set = soundSets[i]; GUIF.Button(brush, set, () => { if (!scrolling) { //currentSet = (Transform.Instantiate(Resources.Load<Transform>(set) as Transform) as Transform).GetComponent<SoundSetGO>(); Application.LoadLevel(set); menuState = MenuState.ListingPhrases; scrollPos = new Vector2(); scrollFling = 0; searchString = ""; previousSearchString = ""; } }); brush = brush.Move(0.0f, 1.05f); } } GUI.EndScrollView(); GUI.Label(new Rect(Screen.width * 0.05f, Screen.height * 0.95f, Screen.width * 0.9f, lineHeight), "Made by 005"); }
public void OnPhraseSelectGUI() { GUIF.Button(new Rect(Screen.width * 0.01f, Screen.height * 0.01f, Screen.width * 0.4f, Screen.height * 0.075f), "Back", () => { Application.LoadLevel("default"); menuState = MenuState.ListingSets; searchString = ""; scrollPos = new Vector2(); scrollFling = 0.0f; }); string str; switch (mode) { case PlayMode.AlwaysInstant: str = "Always Play"; break; case PlayMode.Override: str = "Override Playing"; break; case PlayMode.Queue: str = "Queue"; break; case PlayMode.Spam: str = "Spam"; break; default: str = "Error"; break; } GUIF.Button(new Rect(Screen.width * 0.59f, Screen.height * 0.01f, Screen.width * 0.4f, Screen.height * 0.075f), str, () => { NextMode(); }); Rect scrollArea = new Rect(Screen.width * 0.01f, Screen.height * 0.2f, Screen.width * 0.98f, Screen.height * 0.73f); float lineHeight = GUI.skin.button.LineSize() * 1.33f; Rect brush = new Rect(Screen.width * 0.01f, Screen.height * 0.1f, Screen.width * 0.93f, lineHeight); GUI.Label(brush.Left(0.2f), "Search"); searchString = GUI.TextField(brush.Right(0.8f), searchString); GUIF.Button(new Rect(Screen.width * 0.94f, Screen.height * 0.1f, Screen.width * 0.05f, lineHeight), "X", () => { searchString = ""; }); brush = brush.Move(0.0f, 1.0f); brush.width = Screen.width * 0.98f; switch (sortMode) { case SortMode.Alphabetic: str = "Alphabetic"; break; case SortMode.MostPlayed: str = "Most Played"; break; case SortMode.SearchRelevance: str = "Relevance"; break; default: str = "Error"; break; } GUIF.Button(brush, "Sort by: " + str, () => { NextSortMode(); scrollPos = new Vector2(); scrollFling = 0.0f; if (System.String.IsNullOrEmpty(SoundSet.Searchify(searchString))) { currentSet.Sort(); } else { searchResults.Sort((Phrase phrase1, Phrase phrase2) => { if (sortMode == SortMode.Alphabetic) { return(phrase1.name.ToUpper().CompareTo(phrase2.name.ToUpper())); } else if (sortMode == SortMode.MostPlayed) { return(phrase2.timesPlayed - phrase1.timesPlayed); } else if (sortMode == SortMode.SearchRelevance) { return(SoundSet.ComparePhrasesBySearchRelevance(phrase1.name.ToUpper(), phrase2.name.ToUpper(), SoundSet.Searchify(searchString))); } else { return(0); } }); } }); brush = new Rect(0.0f, 0.0f, scrollArea.width - 24, lineHeight); System.Func <Rect, string, System.Action, bool> buttonFunc; if (mode == PlayMode.Spam) { buttonFunc = GUIF.RepeatButton; } else { buttonFunc = GUIF.Button; } if (!System.String.IsNullOrEmpty(SoundSet.Searchify(searchString))) { scrollPos = GUI.BeginScrollView(scrollArea, scrollPos, new Rect(0, 0, Screen.width * 0.9f - 24, lineHeight * 1.05f * searchResults.Count)); { brush.y = (int)(scrollPos.y / (brush.height * 1.05f)) * (brush.height * 1.05f); for (int i = (int)Mathf.Max(scrollPos.y / (brush.height * 1.05f), 0); scrollPos.y >= ((i - 1) * brush.height * 1.05f) - scrollArea.height && i < searchResults.Count; i++) { Phrase phrase = searchResults[i]; str = phrase.name; if (phrase.clips.Count > 1) { str += " (" + phrase.clips.Count + ")"; } buttonFunc(brush, str, () => { if (!scrolling) { switch (mode) { case PlayMode.Queue: clipQueue.Enqueue(phrase.clips.Choose <AudioClip>()); break; case PlayMode.AlwaysInstant: case PlayMode.Spam: PlaySound(phrase.clips.Choose <AudioClip>()); break; case PlayMode.Override: if (currentSound != null) { currentSound.Stop(); } PlaySound(phrase.clips.Choose <AudioClip>()); break; } } }); brush = brush.Move(0.0f, 1.05f); } } GUI.EndScrollView(); } else { scrollPos = GUI.BeginScrollView(scrollArea, scrollPos, new Rect(0, 0, Screen.width * 0.9f - 24, lineHeight * 1.05f * currentSet.phrases.Count)); { brush.y = (int)(scrollPos.y / (brush.height * 1.05f)) * (brush.height * 1.05f); for (int i = (int)Mathf.Max(scrollPos.y / (brush.height * 1.05f), 0); scrollPos.y >= ((i - 1) * brush.height * 1.05f) - scrollArea.height && i < currentSet.phrases.Count; i++) { Phrase phrase = currentSet.phrases[i]; str = phrase.name; if (phrase.clips.Count > 1) { str += " (" + phrase.clips.Count + ")"; } buttonFunc(brush, str, () => { switch (mode) { case PlayMode.Queue: clipQueue.Enqueue(phrase.clips.Choose <AudioClip>()); break; case PlayMode.AlwaysInstant: case PlayMode.Spam: PlaySound(phrase.clips.Choose <AudioClip>()); break; case PlayMode.Override: if (currentSound != null) { currentSound.Stop(); } PlaySound(phrase.clips.Choose <AudioClip>()); break; } phrase.timesPlayed += 1; }); brush = brush.Move(0.0f, 1.05f); } } GUI.EndScrollView(); } buttonFunc(new Rect(scrollArea.x, Screen.height * 0.95f, scrollArea.width, lineHeight), "[Random]", () => { List <Phrase> set; if (System.String.IsNullOrEmpty(SoundSet.Searchify(searchString))) { set = currentSet.phrases; } else { set = searchResults; } if (set.Count > 0) { Phrase phrase = set.Choose <Phrase>(); switch (mode) { case PlayMode.Queue: clipQueue.Enqueue(phrase.clips.Choose <AudioClip>()); break; case PlayMode.AlwaysInstant: case PlayMode.Spam: PlaySound(phrase.clips.Choose <AudioClip>()); break; case PlayMode.Override: if (currentSound != null) { currentSound.Stop(); } PlaySound(phrase.clips.Choose <AudioClip>()); break; } phrase.timesPlayed += 1; } }); }
public new void Draw(Component caller) { GUIF.Box(area, content); }