public GameUIManager() { UIMain uiMain = LKernel.GetG<UIMain>(); //This mess gets the height and width of the window for centering UI entities. uint uheight, uwidth, colorDepth; int height, width; RenderWindow window = LKernel.GetG<RenderWindow>(); window.GetMetrics(out uwidth, out uheight, out colorDepth); width = (int)uwidth; height = (int)uheight; inGameUI = uiMain.GetGUI("ingame gui"); itembox = inGameUI.GetControl<PictureBox>("itembox"); //itembox.Top = (height / 2); //itembox.Bottom = (height / 2); //itembox.Left = (width / 2); //itembox.Right = (width / 2); itemimage = inGameUI.GetControl<PictureBox>("itemimage"); //itemimage.Top = (height / 2); //itemimage.Bottom = (height / 2); //itemimage.Left = (width / 2); //itemimage.Right = (width / 2); }
public Form_lireVariable(GUI parent, String nomVariable) { InitializeComponent(); this.leChoixEstFait = false; this.parent = parent; }
public InvoiceControl( Invoice invoice, House house, GUI gui ) { this.invoice = invoice; this.gui = gui; this.house = house; InitializeComponent(); }
public static void Main(string[] args) { Application.Init (); GUI gui = new GUI (); gui.Show (); Application.Run (); }
// Use this for initialization void Awake() { Instantiate(BackgroundPrefab, new Vector3(0, 0, 0), transform.rotation); Instantiate(ClockwiseCog, new Vector3(1.28f, 0.218f, 0), transform.rotation); Instantiate(ClockwiseCog, new Vector3(-0.925f, -0.073f, 0), transform.rotation); Instantiate(CounterclockwiseCog, new Vector3(0.871f, 0.315f, 0), transform.rotation); Instantiate(CounterclockwiseCog, new Vector3(-0.819f, 0.344f, 0), transform.rotation); Instantiate(SmallPlatformPrefab, middlePlatformPosition, transform.rotation); Instantiate(SmallPlatformPrefab, leftPlatformPosition, transform.rotation); Instantiate(SmallPlatformPrefab, rightPlatformPosition, transform.rotation); Instantiate(LargePlatformPrefab, basePlatformPosition, transform.rotation); Instantiate(DeadlyFloorPrefab, deadlyFloorPosition, transform.rotation); Instantiate(WallPrefab, leftFloorPosition, transform.rotation); Instantiate(WallPrefab, rightFloorPosition, transform.rotation); gui = ((Transform)Instantiate(GuiPrefab, transform.position, transform.rotation)).GetComponent<GUI>(); var playerOne = (Transform)Instantiate(NinjaPrefab, playerOneSpawningPoints[playerOneSpawningIndex], transform.rotation); var playerTwo = (Transform)Instantiate(GuyPrefab, playerTwoSpawningPoints[playerTwoSpawningIndex], transform.rotation); playerOneController = playerOne.GetComponent<PlayerController>(); playerTwoController = playerTwo.GetComponent<PlayerController>(); playerOneMeta = InitMeta(playerOne, "Ninja", PlayerID.P1); playerTwoMeta = InitMeta(playerTwo, "Thug", PlayerID.P2); }
// Use this for initialization void Start() { Debug.Log("start scored"); SharedBehaviour.current.score = 115; menu = GameObject.FindGameObjectWithTag("menuRoot").GetComponent<GUI>(); menu.state = "highscores"; }
public static void EnableControls(GUI gui) { foreach (Control c in gui.Controls) { c.Enabled = true; } }
public RaceResultUIHandler() { winnerGui = LKernel.Get<UIMain>().GetGUI("winner gui"); winnerLabel = winnerGui.GetControl<Label>("winner label"); LapCounter.OnFirstFinish += new RaceFinishEvent(OnFirstFinish); winnerGui.Visible = false; }
public static void preliminarySetup(GUI gui) { PanelControls.setupFlag = true; PlayerResources.gameState = new GameState(); //create brand new game //populate button list gui.buttonList = ButtonControls.populateButtons(gui); //set status bar gui.turnStatus.Text = "Turn: Player " + PlayerResources.gameState.currentPlayer; PlayerResources.gameState.currentPlayer = 1; //place players in corners InitialSetups.placePlayersInCorners(gui); ButtonControls.setCursorsForNextTurn(gui); PanelControls.setupFlag = false; //declare end of setup LoadSave.loadFlag = false; //declare end of game load GamePlayerFunctions.availableAction = true; //update player credits //give all players an initial income of 2000 credits PlayerResources.gameState.initialIncome(2000); gui.creditsBox.Text = "" + PlayerResources.gameState.selectCurrentPlayer().goldCount; gui.infoBox.Text = " Welcome. " + PlayerResources.gameState.player1.getName() + "'s \n turn."; }
public static Rect DrawResizeableWindow(Rect drawRect, int id, GUI.WindowFunction func) { Rect dragArea = new Rect(drawRect.x - 8, drawRect.y - 8, drawRect.width, drawRect.height); int gid = EditorGUIUtility.GetControlID(FocusType.Native); Event e = Event.current; switch (e.GetTypeForControl(gid)) { case EventType.MouseDown: { if (drawRect.Contains(e.mousePosition)) // inside this control { EditorGUIUtility.hotControl = gid; Resizing = true; e.Use(); Debug.Log("USED"); } } break; case EventType.MouseUp: { Resizing = false; e.Use(); } break; } return drawRect; //func.Invoke(id); }
// Constructor for Game public Game() { board = new Board(); fileMonitor = new FileMonitor(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); gui = new ChessForms.GUI(start, pauseUnpause, reset, saveGame, loadGame); // Load last game bool ok = SaveManager.loadCurrent(ref board); if (ok) { // Set GUI and other stuff gui.putString("Loading last game"); updateOnLoad(); } else { reset(); } gui.updateBoard(board); Application.Run(gui); }
// Use this for initialization void Start() { hsTable = GameObject.FindGameObjectWithTag("highScoreText").GetComponent<GUIText>(); hsTable.text = ""; userInput = GameObject.FindGameObjectWithTag("userInput"); //.GetComponent<GUIText>() menu = GameObject.FindGameObjectWithTag("menuRoot").GetComponent<GUI>() as GUI; userPrompt = GameObject.FindGameObjectWithTag("userPrompt"); //.GetComponent<GUIText>(); // off at first userPrompt.SetActive(false); userInput.SetActive(false); // get the data var data = PlayerPrefs.GetString("HighScores"); if(!string.IsNullOrEmpty(data)) { var b = new BinaryFormatter(); // create a new memory stream with the data var m = new MemoryStream(Convert.FromBase64String(data)); highScores = (List<ScoreEntry>)b.Deserialize(m); }else { highScores.Add(new ScoreEntry{name = "SomePlayer",score = 10}); } // sort the values we pulled from the player prefs highScores = highScores.OrderByDescending(o=>o.score).ToList(); Debug.Log("scores in start: "+ highScores.Count()); }
public void DrawGUI(GUI gui) { DisplayedInfo.DisplayedString = "Life: " + (int)Life; gui.Draw(DisplayedInfo); LifeBar.Scale = new Vector2(LifeBar.Scale.X, Life / MaxLife); gui.Draw(LifeBar); }
public void Add(string name, GUI.WindowFunction f) { Tab t = new Tab (); t.name = name; t.f = f; Add (t); }
public PauseUIHandler() { pauseGui = LKernel.GetG<UIMain>().GetGUI("pause gui"); // hook up to the pause event LKernel.GetG<Pauser>().PauseEvent += new PauseEvent(DoOnPause); }
public LoadingUIHandler() { LevelManager.OnLevelPostLoad += OnLevelPostLoad; LevelManager.OnLevelPreUnload += OnLevelPreUnload; loadingGui = LKernel.GetG<UIMain>().GetGUI("loading screen gui"); }
static void Main(string[] args) { // initialize window and view win = new RenderWindow(new VideoMode(1000, 700), "Hadoken!!!"); view = new View(); resetView(); gui = new GUI(win, view); // exit Program, when window is being closed //win.Closed += new EventHandler(closeWindow); win.Closed += (sender, e) => { (sender as Window).Close(); }; // initialize GameState handleNewGameState(); // initialize GameTime GameTime gameTime = new GameTime(); gameTime.Start(); // debug Text Text debugText = new Text("debug Text", new Font("Fonts/calibri.ttf")); while (running && win.IsOpen()) { KeyboardInputManager.update(); currentGameState = state.update(); // gather draw-stuff win.Clear(new Color(100, 149, 237)); //cornflowerblue ftw!!! 1337 state.draw(win, view); state.drawGUI(gui); // first the state must be drawn, before I can change the currentState if (currentGameState != prevGameState) { handleNewGameState(); } // do the actual drawing win.SetView(view); win.Display(); // check for window-events. e.g. window closed win.DispatchEvents(); // update GameTime gameTime.Update(); float deltaTime = (float)gameTime.EllapsedTime.TotalSeconds; // idleLoop for fixed FrameRate float deltaPlusIdleTime = deltaTime; while (deltaPlusIdleTime < (1F / fixedFps)) { gameTime.Update(); deltaPlusIdleTime += (float)gameTime.EllapsedTime.TotalSeconds; } Console.WriteLine("real fps: " + (int)(1F / deltaPlusIdleTime) + ", theo fps: " + (int)(1F / deltaTime)); } }
public MainMenuManager() { LevelManager.OnLevelLoad += new LevelEvent(OnLevelLoad); LevelManager.OnLevelPreUnload += new LevelEvent(OnLevelPreUnload); UIMain uiMain = LKernel.GetG<UIMain>(); MenuBackgroundGui = uiMain.GetGUI("menu background gui"); GameTypeGui = uiMain.GetGUI("menu game type gui"); LevelSelectGui = uiMain.GetGUI("menu level select gui"); NetworkHostGui = uiMain.GetGUI("menu host info gui"); NetworkClientGui = uiMain.GetGUI("menu client info gui"); LobbyGui = uiMain.GetGUI("menu lobby gui"); CharacterSelectGui = uiMain.GetGUI("menu character select gui"); OptionsGui = uiMain.GetGUI("menu options gui"); // the checkers bit in the corner PictureBox checkersPicture = MenuBackgroundGui.GetControl<PictureBox>("checkers picture"); checkersPicture.Bitmap = new Bitmap("media/gui/checkers.png"); // set up events and stuff GameTypeGui.GetControl<Button>("game type single player button").MouseClick += (o, e) => Invoke(OnGameType_SelectSinglePlayer, o, e); GameTypeGui.GetControl<Button>("game type networked host button").MouseClick += (o, e) => Invoke(OnGameType_SelectNetworkedHost, o, e); GameTypeGui.GetControl<Button>("game type networked client button").MouseClick += (o, e) => Invoke(OnGameType_SelectNetworkedClient, o, e); GameTypeGui.GetControl<Button>("game type options button").MouseClick += (o, e) => Invoke(OnGameType_SelectOptions, o, e); GameTypeGui.GetControl<Button>("quit button").MouseClick += (o, e) => Launch.Quit = true; NetworkHostPortTextBox = NetworkHostGui.GetControl<TextBox>("host info port text box"); NetworkHostPasswordTextBox = NetworkHostGui.GetControl<TextBox>("host info password text box"); NetworkHostGui.GetControl<Button>("host info next button").MouseClick += (o, e) => Invoke(OnHostInfo_SelectNext, o, e); NetworkHostGui.GetControl<Button>("host info back button").MouseClick += (o, e) => Invoke(OnHostInfo_SelectBack, o, e); NetworkClientIPTextBox = NetworkClientGui.GetControl<TextBox>("client info IP text box"); NetworkClientPortTextBox = NetworkClientGui.GetControl<TextBox>("client info port text box"); NetworkClientPasswordTextBox = NetworkClientGui.GetControl<TextBox>("client info password text box"); NetworkClientGui.GetControl<Button>("client info next button").MouseClick += (o, e) => Invoke(OnClientInfo_SelectNext, o, e); NetworkClientGui.GetControl<Button>("client info back button").MouseClick += (o, e) => Invoke(OnClientInfo_SelectBack, o, e); LobbyLabel = LobbyGui.GetControl<Label>("lobby label"); LobbyGui.GetControl<Button>("lobby next button").MouseClick += (o, e) => Invoke(OnLobby_SelectNext, o, e); LobbyGui.GetControl<Button>("lobby back button").MouseClick += (o, e) => Invoke(OnLobby_SelectBack, o, e); LevelSelectGui.GetControl<Button>("level select flat button").MouseClick += (o, e) => Invoke(OnLevelSelect, o, e, "flat"); LevelSelectGui.GetControl<Button>("level select testlevel button").MouseClick += (o, e) => Invoke(OnLevelSelect, o, e, "testlevel"); LevelSelectGui.GetControl<Button>("level select SAA button").MouseClick += (o, e) => Invoke(OnLevelSelect, o, e, "SweetAppleAcres"); LevelSelectGui.GetControl<Button>("level select WTW button").MouseClick += (o, e) => Invoke(OnLevelSelect, o, e, "WhitetailWoods"); LevelSelectGui.GetControl<Button>("level select TestAI button").MouseClick += (o, e) => Invoke(OnLevelSelect, o, e, "TestAI"); LevelSelectGui.GetControl<Button>("level select roulette button").MouseClick += (o, e) => Invoke(OnLevelSelect, o, e, "roulette"); LevelSelectGui.GetControl<Button>("level select back button").MouseClick += (o, e) => Invoke(OnLevelSelect_SelectBack, o, e); CharacterSelectGui.GetControl<Button>("character select TS button").MouseClick += (o, e) => Invoke(OnCharacterSelect, o, e, "Twilight Sparkle"); CharacterSelectGui.GetControl<Button>("character select RD button").MouseClick += (o, e) => Invoke(OnCharacterSelect, o, e, "Rainbow Dash"); CharacterSelectGui.GetControl<Button>("character select AJ button").MouseClick += (o, e) => Invoke(OnCharacterSelect, o, e, "Applejack"); CharacterSelectGui.GetControl<Button>("character select PP button").MouseClick += (o, e) => Invoke(OnCharacterSelect, o, e, "Pinkie Pie"); CharacterSelectGui.GetControl<Button>("character select FS button").MouseClick += (o, e) => Invoke(OnCharacterSelect, o, e, "Fluttershy"); CharacterSelectGui.GetControl<Button>("character select rarity button").MouseClick += (o, e) => Invoke(OnCharacterSelect, o, e, "Rarity"); CharacterSelectGui.GetControl<Button>("character select back button").MouseClick += (o, e) => Invoke(OnCharacterSelect_SelectBack, o, e); OptionsGui.GetControl<Button>("options ok button").MouseClick += (o, e) => Invoke(OnOptions_SelectOK, o, e); }
public Algorithme2(GUI gui, BackgroundWorker backgroundWorker) { this.ligneCourante = 0; this.listeDInstructions = new List<Instruction>(); this.listeDeVariables = new List<Variable>(); this.GUI = gui; this.backgroundWorker = backgroundWorker; }
void Draw(Vector2 w, GUI.WindowFunction f) { w /= 2; Vector2 s = new Vector2(Screen.width, Screen.height) / 2; Vector2 p1 = s - w; Vector2 p2 = s + w; gui.Window(100, Rect.MinMaxRect(p1.x, p1.y, p2.x, p2.y), f, "PopUp"); }
void Start() { gui = GetComponent<GUI>(); audio.clip = chime; audio.volume = 0; audio.loop = true; audio.Play(); }
public LapCounterUIHandler() { lapCountGUI = LKernel.Get<UIMain>().GetGUI("lap count gui"); lapCountLabel = lapCountGUI.GetControl<Label>("lap count label"); LapCounter.OnLap += new LapCounterEvent(OnLap); LevelManager.OnLevelPostLoad += new LevelEvent(OnPostLoad); }
public VerticalScrollbar(int id, float width, float height, float maxvalue) : base(id) { maxValue = maxvalue; fontHeight = (float)Scale.vSizeScale(Client.window.Qfont.fontData.maxGlyphHeight); SetBounds(null, null, width, height); AddAppearence(); gui = Singleton<GUI>.INSTANCE; }
public rectangle(int index,int width, int height,byte owner,GUI.EditSolution editSolution) { this.index = index; this.originalWidth = width; this.originalHeight = height; this.owner = owner; this.editSolution = editSolution; InitializeComponent(); }
// ============================================ // PUBLIC Constructors // ============================================ public ProtocolManager(GUI.Window window) { // Initialize Components this.notebookViewer = window.NotebookViewer; this.networkViewer = this.notebookViewer.NetworkViewer; // Add Events Handler CmdManager.AddProtocolEvent += new SetProtocolEventHandler(OnAddProtocolEvent); CmdManager.DelProtocolEvent += new SetProtocolEventHandler(OnDelProtocolEvent); }
public static void menuSetup(GUI gui) { gui.menuPanel.Visible = true; gui.statusStrip.Visible = false; gui.gamePanel.Visible = false; gui.gamePanel.SendToBack(); gui.menuPanel.BringToFront(); gui.statusStrip.SendToBack(); gui.sidePanel.SendToBack(); }
public CountdownUIHandler() { // set up our label countGui = LKernel.GetG<UIMain>().GetGUI("countdown gui"); countLabel = countGui.GetControl<Label>("countdown label"); // hook up to events RaceCountdown.OnCountdown += new RaceCountdownEvent(OnCountdown); LevelManager.OnLevelPreUnload += new LevelEvent(OnLevelPreUnload); }
public static void placePlayersInCorners(GUI gui) { GamePlayerFunctions.generalButtonClick(gui, gui.button1, 1); //replace with actions not gen button clicks GamePlayerFunctions.advanceTurn(gui); GamePlayerFunctions.generalButtonClick(gui, gui.button8, 8); GamePlayerFunctions.advanceTurn(gui); GamePlayerFunctions.generalButtonClick(gui, gui.button57, 57); GamePlayerFunctions.advanceTurn(gui); GamePlayerFunctions.generalButtonClick(gui, gui.button64, 64); GamePlayerFunctions.advanceTurn(gui); }
public HowToPlayScreen(Game game) : base(game) { _gui = new GUI(new Vector2(GraphicsDevice.Viewport.Height / 500f)) { CreateObjective(game), CreateKeyBindings(game), CreateBackButton(game) }; _music = Game.Content.Load<Song>("Audio/Music/help.wav"); }
public Form_SelectionnerValeurALire(GUI parent, List<Variable> listeDeVariables) // Liste d'au moins 1 élément { InitializeComponent(); this.parent = parent; this.listeDeVariables = listeDeVariables; foreach (Variable v in listeDeVariables) this.comboBox1.Items.Add(v.obtenirNom()); this.comboBox1.SelectedIndex = 0; }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); float x = position.x; float y = position.y; float inspectorWidth = position.width; // Draw label // Don't make child fields be indented var indent = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; var items = property.FindPropertyRelative("items"); var titles = new string[] {"Transform", "", "", ""}; var props = new string[] {"transform", "^", "v", "-"}; var widths = new float[] {.7f, .1f, .1f, .1f}; float lineHeight = 18; bool changedLength = false; if (items.arraySize > 0) { for (int i = 0; i < items.arraySize; i++) { var item = items.GetArrayElementAtIndex(i); float rowX = x; for (int n = 0; n < props.Length; ++n) { float w = widths[n]*inspectorWidth; // Calculate rects Rect rect = new Rect(rowX, y, w, lineHeight); rowX += w; if (i == -1) { EditorGUI.LabelField(rect, titles[n]); } else { if (n == 0) { EditorGUI.ObjectField(rect, item.objectReferenceValue, typeof (Transform), true); } else { if (GUI.Button(rect, props[n])) { switch (props[n]) { case "-": items.DeleteArrayElementAtIndex(i); items.DeleteArrayElementAtIndex(i); changedLength = true; break; case "v": if (i > 0) { items.MoveArrayElement(i, i + 1); } break; case "^": if (i < items.arraySize - 1) { items.MoveArrayElement(i, i - 1); } break; } } } } } y += lineHeight + spacing; if (changedLength) { break; } } } else { // add button var addButtonRect = new Rect((x + position.width) - widths[widths.Length - 1]*inspectorWidth, y, widths[widths.Length - 1]*inspectorWidth, lineHeight); if (GUI.Button(addButtonRect, "+")) { items.InsertArrayElementAtIndex(items.arraySize); } y += lineHeight + spacing; } // add all button var addAllButtonRect = new Rect(x, y, inspectorWidth, lineHeight); if (GUI.Button(addAllButtonRect, "Assign using all child objects")) { var circuit = property.FindPropertyRelative("circuit").objectReferenceValue as WaypointCircuit; var children = new Transform[circuit.transform.childCount]; int n = 0; foreach (Transform child in circuit.transform) { children[n++] = child; } Array.Sort(children, new TransformNameComparer()); circuit.waypointList.items = new Transform[children.Length]; for (n = 0; n < children.Length; ++n) { circuit.waypointList.items[n] = children[n]; } } y += lineHeight + spacing; // rename all button var renameButtonRect = new Rect(x, y, inspectorWidth, lineHeight); if (GUI.Button(renameButtonRect, "Auto Rename numerically from this order")) { var circuit = property.FindPropertyRelative("circuit").objectReferenceValue as WaypointCircuit; int n = 0; foreach (Transform child in circuit.waypointList.items) { child.name = "Waypoint " + (n++).ToString("000"); } } y += lineHeight + spacing; // Set indent back to what it was EditorGUI.indentLevel = indent; EditorGUI.EndProperty(); }
void OnGUI() { // Dragging events if (Event.current.type == EventType.mouseDrag) { if (currentRect.Contains(Event.current.mousePosition)) { if (!dragging) { dragging = true; startPos = currentPos; } } currentPos = Event.current.mousePosition; } if (Event.current.type == EventType.mouseUp) { dragging = false; } scrollPosition = GUILayout.BeginScrollView(scrollPosition); GUI.DrawTexture(imageBackgroundRect, backgroundPreviewTex); for (int i = 0; i < sceneRef.getBarriersList().getBarriersList().Count; i++) { Rect aRect = new Rect(sceneRef.getBarriersList().getBarriersList()[i].getX(), sceneRef.getBarriersList().getBarriersList()[i].getY(), sceneRef.getBarriersList().getBarriersList()[i].getWidth(), sceneRef.getBarriersList().getBarriersList()[i].getHeight()); GUI.DrawTexture(aRect, barrierTex); // Frame around current area if (calledBarrierIndexRef == i) { currentRect = aRect; GUI.DrawTexture(currentRect, selectedBarrierTex); } } GUILayout.EndScrollView(); /* * HANDLE EVENTS */ if (dragging) { OnBeingDragged(); } GUILayout.BeginHorizontal(); GUILayout.Box("X", GUILayout.Width(0.25f * backgroundPreviewTex.width)); GUILayout.Box("Y", GUILayout.Width(0.25f * backgroundPreviewTex.width)); GUILayout.Box(TC.get("SPEP.Width"), GUILayout.Width(0.25f * backgroundPreviewTex.width)); GUILayout.Box(TC.get("SPEP.Height"), GUILayout.Width(0.25f * backgroundPreviewTex.width)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); x = EditorGUILayout.IntField(sceneRef.getBarriersList().getBarriersList()[calledBarrierIndexRef].getX(), GUILayout.Width(0.25f * backgroundPreviewTex.width)); y = EditorGUILayout.IntField(sceneRef.getBarriersList().getBarriersList()[calledBarrierIndexRef].getY(), GUILayout.Width(0.25f * backgroundPreviewTex.width)); width = EditorGUILayout.IntField(sceneRef.getBarriersList().getBarriersList()[calledBarrierIndexRef].getWidth(), GUILayout.Width(0.25f * backgroundPreviewTex.width)); heigth = EditorGUILayout.IntField(sceneRef.getBarriersList().getBarriersList()[calledBarrierIndexRef].getHeight(), GUILayout.Width(0.25f * backgroundPreviewTex.width)); sceneRef.getBarriersList().getBarriersList()[calledBarrierIndexRef].setValues(x, y, width, heigth); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Ok")) { reference.OnDialogOk("Applied"); this.Close(); } //if (GUILayout.Button(TC.get("GeneralText.Cancel"))) //{ // reference.OnDialogCanceled(); // this.Close(); //} GUILayout.EndHorizontal(); }
public static bool DrawButtonReturn(float x, float y, float w, float h, string txt) { return(GUI.RepeatButton(new Rect(position_x(x), position_y(y), size_x(w), size_y(h)), txt)); }
void OnGUI() { if (!SceneManager.GetActiveScene().IsValid()) return; if (!currentWindow) { currentWindow = Resources.FindObjectsOfTypeAll( Params.WindowType ).FirstOrDefault() as EditorWindow; if (currentWindow) ResetWindow(); } if (!currentWindow) return; if (SceneManager.GetActiveScene().GetHashCode() != EditorPrefs.GetInt( "EModules/" + Params.TITLE + "/Scene", -1 )) ResetWindow(); if (Params.Label == null) { Params.Label = new GUIStyle( GUI.skin.label ); Params.Label.fontSize = 14; Params.Label.fontStyle = FontStyle.Bold; Params.Button = new GUIStyle( GUI.skin.button ); // Button.fontSize = 14; var t = new Texture2D(1,1,TextureFormat.ARGB32,false,true); t.hideFlags = HideFlags.DontSave; t.SetPixel( 0, 0, new Color( 0, 0.1f, 0.4f, 0.3f ) ); t.Apply(); Params.Button.normal.background = null; Params.Button.hover.background = null; Params.Button.focused.background = null; Params.Button.active.background = t; } if (!Camera.main) { GUILayout.Label( "No Camera", Params.Label ); return; } ISupportedPostComponent currentComponent = null; MonoBehaviour c1 = null; MonoBehaviour c2 = null; if (Params.PostProcessingBehaviourType != null) c1 = Camera.main.GetComponent( Params.PostProcessingBehaviourType ) as MonoBehaviour; if (Params.AmplifyBaseType != null) c2 = Camera.main.GetComponent( Params.AmplifyBaseType ) as MonoBehaviour; if (c1 && c1.enabled) currentComponent = postPresets_UnityPostGUI; else if (c2 && c2.enabled) currentComponent = postPresets_AmplifyPostGUI; else if (c1) currentComponent = postPresets_UnityPostGUI; else if (c2) currentComponent = postPresets_AmplifyPostGUI; else if (Params.PostProcessingBehaviourType != null) currentComponent = postPresets_UnityPostGUI; else if (Params.AmplifyBaseType != null) currentComponent = postPresets_AmplifyPostGUI; if (currentComponent == null) { GUILayout.Label( "Unity PostProcessing or AmplifyColor not imported", Params.Label ); if (GUILayout.Button( "Download Unity 'Post Processing Stack'", GUILayout.Height( 40 ) )) { Application.OpenURL( "https://www.assetstore.unity3d.com/#!/content/83912" ); } if (GUILayout.Button( "Download 'Amplify Color'", GUILayout.Height( 40 ) )) { Application.OpenURL( " https://www.assetstore.unity3d.com/en/#!/content/1894" ); } return; } // Left column //// GUILayout.BeginHorizontal(); var leftwidth = Mathf.Clamp( position.width / 3f, 200, 350 ); GUILayout.BeginVertical( GUILayout.Width( leftwidth ) ); GUILayout.Label( "Camera: " + Camera.main.name, Params.Label ); if (GUI.Button( GUILayoutUtility.GetLastRect(), "", Params.Button )) Selection.objects = new[] { Camera.main.gameObject }; EditorGUIUtility.AddCursorRect( GUILayoutUtility.GetLastRect(), MouseCursor.Link ); if (currentComponent.MonoComponent == null) { if (GUILayout.Button( "Add " + currentComponent.MonoComponentType + " Script", GUILayout.Height( 200 ) )) { Undo.RecordObject( Camera.main.gameObject, "Add " + currentComponent.MonoComponentType + " Script" ); Camera.main.gameObject.AddComponent( currentComponent.MonoComponentType ); EditorUtility.SetDirty( Camera.main.gameObject ); } return; } if (!currentComponent.MonoComponent.enabled) { GUILayout.Label( currentComponent.MonoComponent.GetType().Name + " Component Disabled", Params.Label ); if (GUILayout.Button( "Enable " + currentComponent.MonoComponent.GetType().Name + " Component", GUILayout.Height( 200 ) )) { Undo.RecordObject( currentComponent.MonoComponent, "Enable " + currentComponent.MonoComponent.GetType().Name + " Component" ); currentComponent.MonoComponent.enabled = true; EditorUtility.SetDirty( currentComponent.MonoComponent ); UnityEditorInternal.InternalEditorUtility.RepaintAllViews(); } return; } if (widthCheck == null) widthCheck = position.width; if (widthCheck.Value != position.width) { widthCheck = position.width; ClearImages( false ); currentWindow.Repaint(); } //! *** POSTPROCESSING COMPONENT GUI *** // currentComponent.LeftSideGUI( this, leftwidth ); //! *** POSTPROCESSING COMPONENT GUI *** // if (GUILayout.Button( "http://emodules.me/", Params.Button )) Application.OpenURL( "http://emodules.me/" ); EditorGUIUtility.AddCursorRect( GUILayoutUtility.GetLastRect(), MouseCursor.Link ); GUILayout.EndVertical(); // Left column GUILayout.Space( 10 ); leftwidth += 20; //! PRESETS GRID GUI if (currentComponent.IsValid) { GUILayout.BeginVertical(); //////////////////////// currentComponent.TopFastButtonsGUI( this, leftwidth ); //////////////////////// FiltresAndSorting( this, leftwidth ); //////////////////////// DrawPresets( currentComponent ); //////////////////////// GUILayout.EndVertical(); } //! PRESETS GRID GUI GUILayout.EndHorizontal(); }//!OnGUI
}//!OnGUI void FiltresAndSorting(EditorWindow window, float leftWidth) { #if !P128 GUI.enabled = true; #else GUI.enabled = false; #endif // FILTRES //var filtresCount = filtername_to_filterindex.Values.Max(); /*for (int i = 0 ; i < filtresCount ; i++) { var filtMask = 1 << i; var enable = ((int)Params.filtres & filtMask) != 0; var captureI=i; var name = filtername_to_filterindex.Where(f=>f.Value == captureI).Select(f=>f.Key).Aggregate((a,b)=>a+'\n' +b); if (Button( GetRect( leftWidth, 40, window, 8 ), name, enable )) { if (enable) Params.filtres.Set( ((int)Params.filtres & ~filtMask) ); else Params.filtres.Set( ((int)Params.filtres | filtMask) ); renderedDoubleCheck = new Texture2D[gradients.Length]; window.Repaint(); } }*/ GUILayout.BeginHorizontal(); var lineR= GetRect( leftWidth, 16, window, 1 ); //SPACE GUILayout.EndHorizontal(); var seaR = lineR; seaR.width *= 0.7f; lineR.x += seaR.width + 40; lineR.width -= seaR.width + 40; var newFilter = EditorGUI.TextField(seaR, "Search: ", (string)Params.filtres); if (newFilter != Params.filtres) { Params.filtres.Set( newFilter ); window.Repaint(); } seaR.x += seaR.width; seaR.width = 20; if (GUI.Button( seaR, "X" )) { Params.filtres.Set( "" ); EditorGUI.FocusTextInControl( null ); ClearImages( true ); window.Repaint(); } EditorGUIUtility.AddCursorRect( lineR, MouseCursor.Link ); if (GUI.Button( lineR, "Show Favorites", Params.Button )) { Params.showFav.Set( 1 - Params.showFav ); ClearImages( true ); if (Params.showFav == 0) mayResetScroll = WasElementsChanged; WasElementsChanged = false; window.Repaint(); } if (Params.showFav == 1) EditorGUI.DrawRect( lineR, new Color( 0.8f, 0.6f, 0.33f, 0.4f ) ); lineR.x += lineR.width; lineR.width = 16; #if !P128 GUI.DrawTexture( lineR, favicon_enable ); #endif // FILTRES // SORTING GUILayout.BeginHorizontal(); var D = 8; var r = GetRect( leftWidth, 20, window ,D); GUI.Label( r, "Sorting:" ); for (int i = 0 ; i < 4 ; i++) { var sortNotInverse = ((int)Params.sortInverse & (1 << i)) == 0; if (Button( GetRect( leftWidth, 20, window, D ), sotrNames[i] + (Params.sortMode == i ? (sortNotInverse ? "▼" : "▲") : ""), Params.sortMode == i, "Set Ordering Method" )) { if (Params.sortMode == i) { if (!sortNotInverse) Params.sortInverse.Set( ((int)Params.sortInverse & ~(1 << i)) ); else Params.sortInverse.Set( ((int)Params.sortInverse | (1 << i)) ); } else { Params.sortMode.Set( (float)i ); } ClearImages( true ); window.Repaint(); } } GUI.enabled = true; GetRect( leftWidth, 20, window, D ); //SPACE GUI.Label( GetRect( leftWidth, 20, window, D ), "Zoom:" ); var ZoomRect= GetRect( leftWidth, 20, window, D ); ZoomRect.width /= 3; for (int i = 0 ; i < 3 ; i++) { if (Button( ZoomRect, "x" + (i + 1) * 3, Params.zoomFactor == i, "Set Zooming Factor" )) { Params.zoomFactor.Set( i ); ClearImages( true ); window.Repaint(); } ZoomRect.x += ZoomRect.width; } GUILayout.EndHorizontal(); // SORTING }//!FiltresAndSorting
void OnGUI() { if (position.width != _oldPosition.width && Event.current.type == EventType.Layout) { Drawings = null; _oldPosition = position; } GUILayout.BeginHorizontal(); if (GUILayout.Toggle(_showingStyles, "Styles", EditorStyles.toolbarButton) != _showingStyles) { _showingStyles = !_showingStyles; _showingIcons = !_showingStyles; Drawings = null; } if (GUILayout.Toggle(_showingIcons, "Icons", EditorStyles.toolbarButton) != _showingIcons) { _showingIcons = !_showingIcons; _showingStyles = !_showingIcons; Drawings = null; } GUILayout.EndHorizontal(); string newSearch = GUILayout.TextField(_search); if (newSearch != _search) { _search = newSearch; Drawings = null; } float top = 36; if (Drawings == null) { string lowerSearch = _search.ToLower(); Drawings = new List<Drawing>(); GUIContent inactiveText = new GUIContent("inactive"); GUIContent activeText = new GUIContent("active"); float x = 5.0f; float y = 5.0f; if (_showingStyles) { foreach (GUIStyle ss in GUI.skin.customStyles) { if (lowerSearch != "" && !ss.name.ToLower().Contains(lowerSearch)) continue; GUIStyle thisStyle = ss; Drawing draw = new Drawing(); float width = Mathf.Max( 100.0f, GUI.skin.button.CalcSize(new GUIContent(ss.name)).x, ss.CalcSize(inactiveText).x + ss.CalcSize(activeText).x ) + 16.0f; float height = 60.0f; if (x + width > position.width - 32 && x > 5.0f) { x = 5.0f; y += height + 10.0f; } draw.Rect = new Rect(x, y, width, height); width -= 8.0f; draw.Draw = () => { if (GUILayout.Button(thisStyle.name, GUILayout.Width(width))) CopyText("(GUIStyle)\"" + thisStyle.name + "\""); GUILayout.BeginHorizontal(); GUILayout.Toggle(false, inactiveText, thisStyle, GUILayout.Width(width / 2)); GUILayout.Toggle(false, activeText, thisStyle, GUILayout.Width(width / 2)); GUILayout.EndHorizontal(); }; x += width + 18.0f; Drawings.Add(draw); } } else if (_showingIcons) { if (_objects == null) { _objects = new List<UnityEngine.Object>(Resources.FindObjectsOfTypeAll(typeof(Texture))); _objects.Sort((pA, pB) => System.String.Compare(pA.name, pB.name, System.StringComparison.OrdinalIgnoreCase)); } float rowHeight = 0.0f; foreach (UnityEngine.Object oo in _objects) { Texture texture = (Texture)oo; if (texture.name == "") continue; if (lowerSearch != "" && !texture.name.ToLower().Contains(lowerSearch)) continue; Drawing draw = new Drawing(); float width = Mathf.Max( GUI.skin.button.CalcSize(new GUIContent(texture.name)).x, texture.width ) + 8.0f; float height = texture.height + GUI.skin.button.CalcSize(new GUIContent(texture.name)).y + 8.0f; if (x + width > position.width - 32.0f) { x = 5.0f; y += rowHeight + 8.0f; rowHeight = 0.0f; } draw.Rect = new Rect(x, y, width, height); rowHeight = Mathf.Max(rowHeight, height); width -= 8.0f; draw.Draw = () => { if (GUILayout.Button(texture.name, GUILayout.Width(width))) CopyText("EditorGUIUtility.FindTexture( \"" + texture.name + "\" )"); Rect textureRect = GUILayoutUtility.GetRect(texture.width, texture.width, texture.height, texture.height, GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(false)); EditorGUI.DrawTextureTransparent(textureRect, texture); }; x += width + 8.0f; Drawings.Add(draw); } } _maxY = y; } Rect r = position; r.y = top; r.height -= r.y; r.x = r.width - 16; r.width = 16; float areaHeight = position.height - top; _scrollPos = GUI.VerticalScrollbar(r, _scrollPos, areaHeight, 0.0f, _maxY); Rect area = new Rect(0, top, position.width - 16.0f, areaHeight); GUILayout.BeginArea(area); int count = 0; foreach (Drawing draw in Drawings) { Rect newRect = draw.Rect; newRect.y -= _scrollPos; if (newRect.y + newRect.height > 0 && newRect.y < areaHeight) { GUILayout.BeginArea(newRect, GUI.skin.textField); draw.Draw(); GUILayout.EndArea(); count++; } } GUILayout.EndArea(); }
void DrawDisplayArea( Rect rect ) { Widgets.DrawMenuSection( rect ); if( SelectedHost == null ) { return; } if( ( PreviouslySelectedHost != null )&& ( PreviouslySelectedHost != SelectedHost ) ) { PreviouslySelectedHost.worker.PostClose(); } if( PreviouslySelectedHost != SelectedHost ) { SelectedHost.OpenedThisSession = true; SelectedHost.worker.PreOpen(); } PreviouslySelectedHost = SelectedHost; Text.Font = GameFont.Medium; Text.WordWrap = false; var titleRect = new Rect( rect.xMin, rect.yMin, rect.width, 60f ); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label( titleRect, SelectedHost.Label ); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; Text.WordWrap = true; Rect outRect = rect.ContractedBy( WindowMargin ); outRect.yMin += 60f; Rect viewRect = outRect; viewRect.width -= 16f; viewRect.height = ContentHeight; GUI.BeginGroup( outRect ); Widgets.BeginScrollView( outRect.AtZero(), ref DisplayScrollPos, viewRect.AtZero() ); bool userError = false; string userErrorStr = string.Empty; try { ContentHeight = SelectedHost.worker.DoWindowContents( viewRect.AtZero() ); } catch( Exception e ) { userError = true; userErrorStr = e.ToString(); } Widgets.EndScrollView(); GUI.EndGroup(); if( userError ) { CCL_Log.Trace( Verbosity.NonFatalErrors, userErrorStr, "Mod Configuration Menu" ); } }
void DrawPresets(Rect position, PresetLibrary curveLibrary) { if (curveLibrary == null || curveLibrary.Count() == 0) { return; } const int maxNumPresets = 9; int numPresets = curveLibrary.Count(); int showNumPresets = Mathf.Min(numPresets, maxNumPresets); const float swatchWidth = 30; const float swatchHeight = 15; const float spaceBetweenSwatches = 10; float presetButtonsWidth = showNumPresets * swatchWidth + (showNumPresets - 1) * spaceBetweenSwatches; float flexWidth = (position.width - presetButtonsWidth) * 0.5f; // Preset swatch area float curY = (position.height - swatchHeight) * 0.5f; float curX = 3.0f; if (flexWidth > 0) { curX = flexWidth; } GUI.BeginGroup(position); for (int i = 0; i < showNumPresets; i++) { if (i > 0) { curX += spaceBetweenSwatches; } var swatchRect = new Rect(curX, curY, swatchWidth, swatchHeight); m_TextContent.tooltip = curveLibrary.GetName(i); if (GUI.Button(swatchRect, m_TextContent, GUIStyle.none)) { // if there is only 1, no need to specify IEnumerable <CurveWrapper> wrappers = m_CurveWrappers; if (m_CurveWrappers.Length > 1) { wrappers = m_CurveWrappers.Where(x => x.selected == CurveWrapper.SelectionMode.Selected); } foreach (var wrapper in wrappers) { var presetCurve = (AnimationCurve)curveLibrary.GetPreset(i); wrapper.curve.keys = (Keyframe[])presetCurve.keys.Clone(); wrapper.changed = true; } } if (Event.current.type == EventType.Repaint) { curveLibrary.Draw(swatchRect, i); } curX += swatchWidth; } GUI.EndGroup(); }
void OnGUI() { //マップサイズの入力 GUILayout.Label("Map Size", EditorStyles.boldLabel); f_xInt = EditorGUILayout.IntSlider("size x", f_xInt, 1, 99); f_zInt = EditorGUILayout.IntSlider("size z", f_zInt, 1, f_xInt); EditorGUILayout.Space(); //カメラの位置調整するか否か WithCameraPos = EditorGUILayout.Toggle("カメラ調整", WithCameraPos); EditorGUILayout.Space(); //マップ用タイルの指定 tileObject = (GameObject)EditorGUILayout.ObjectField(tileObject, typeof(GameObject), true); //生成ボタン if (GUI.Button(new Rect(10.0f, 130.0f, 120.0f, 20.0f), "Create Map")) { //タイル用のオブジェクトが使用されていなければ終了 if (tileObject == null) { Debug.Log("Tileに使用するオブジェクトを指定してください"); return; } //Mapオブジェクトがなければ生成 var map = GameObject.Find("Map"); if (map == null) { map = new GameObject("Map"); } else { //Mapの子オブジェクトを削除 for (int i = map.transform.childCount - 1; i >= 0; --i) { DestroyImmediate(map.transform.GetChild(i).gameObject); } //配列情報削除 if (map.GetComponent <MapManager>() != null) { map.GetComponent <MapManager>().DeleteTilesArray(); } } //マップマネージャーを追加 var mapManager = map.GetComponent <MapManager>(); if (mapManager == null) { mapManager = map.AddComponent <MapManager>(); } //タイル格納用配列をマップサイズで初期化 mapManager.InitTilesArray(f_xInt, f_zInt); //Map生成 for (int i = 0; i < f_xInt; i++) { for (int j = 0; j < f_zInt; j++) { var tile = Instantiate(tileObject, new Vector3(i, 0, j), Quaternion.identity, map.transform); mapManager.AddTileToArray(tile, i, j); } } //カメラの位置調整 if (WithCameraPos) { var cam = Camera.main; //原点に最初のタイルの中心があるため、半個分マイナス float xpos = (f_xInt / 2.0f) - 0.5f; //カメラの視野角が60度なので1:2:√3(×1.1は端を見せるため) float ypos = (Mathf.Sqrt(3.0f) * f_xInt / 2.0f) * 1.2f; //原点に最初のタイルの中心があるため、半個分マイナス float zpos = (f_zInt / 2.0f) - 0.5f; cam.transform.position = new Vector3(xpos, ypos, zpos); //カメラの回転調整 cam.transform.rotation = Quaternion.Euler(90f, 0f, 0f); //マップの中心を中心にカメラを公転 cam.transform.RotateAround(new Vector3(xpos, 0.0f, zpos), Vector3.left, 30.0f); } } //削除ボタン if (GUI.Button(new Rect(10.0f, 160.0f, 120.0f, 20.0f), "Delete Map")) { var map = GameObject.Find("Map"); if (map != null) { //Mapの子オブジェクトを削除 for (int i = map.transform.childCount - 1; i >= 0; --i) { DestroyImmediate(map.transform.GetChild(i).gameObject); } //配列情報削除 if (map.GetComponent <MapManager>() != null) { map.GetComponent <MapManager>().DeleteTilesArray(); } } } }
private void OnGUI() { if (isDirty) { return; } SafetyCheck(); Rect windowRect = SNWindow.CreateWindow(new Rect(0, 30, 298, 700), "Runtime Helper Zero v.1.0"); GUI.Label(new Rect(windowRect.x + 5, windowRect.y, 290, 25), $"Base : {baseObject.name}", SNStyles.GetGuiItemStyle(GuiItemType.LABEL, GuiColor.Green, TextAnchor.MiddleLeft)); ScrollView_transforms_event = SNScrollView.CreateScrollView(new Rect(windowRect.x + 5, windowRect.y + 22, windowRect.width - 10, 212), ref scrollpos_transforms, ref guiItems_transforms, isRootList ? "Active Scenes Root Game Objects" : "Childs of", isRootList ? string.Empty : baseObject.name, 10); GUI.Label(new Rect(windowRect.x + 5, windowRect.y + 300, 40, 22), "Base :", SNStyles.GetGuiItemStyle(GuiItemType.LABEL, GuiColor.Green, TextAnchor.MiddleLeft)); if (GUI.Button(new Rect(windowRect.x + 60, windowRect.y + 300, 60, 22), MainWindow[0], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray))) { OnBaseObjectChange(selectedObject); } if (GUI.Button(new Rect(windowRect.x + 125, windowRect.y + 300, 60, 22), MainWindow[1], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray))) { OnRefreshBase(); } if (GUI.Button(new Rect(windowRect.x + 190, windowRect.y + 300, 103, 22), MainWindow[2], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray))) { GetRoots(); } GUI.Label(new Rect(windowRect.x + 5, windowRect.y + 325, 40, 22), "Object :", SNStyles.GetGuiItemStyle(GuiItemType.LABEL, GuiColor.Green, TextAnchor.MiddleLeft)); if (GUI.Button(new Rect(windowRect.x + 60, windowRect.y + 325, 30, 22), selectedObject.activeSelf ? MainWindow[4] : MainWindow[3], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray))) { if (selectedObject == gameObject) { OutputWindow_Log(WARNING_TEXT[WARNINGS.OBJECT_STATE_CANNOT_MODIFIED], LogType.Warning, selectedObject.name); return; } selectedObject.SetActive(!selectedObject.activeSelf); OutputWindow_Log(MESSAGE_TEXT[MESSAGES.ACTIVE_STATE_CHANGE], selectedObject.name, selectedObject.activeSelf.ToString()); } if (GUI.Button(new Rect(windowRect.x + 95, windowRect.y + 325, 40, 22), MainWindow[17], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray))) { AddToMarkList(selectedObject); } if (GUI.Button(new Rect(windowRect.x + 140, windowRect.y + 325, 40, 22), MainWindow[5], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray))) { if (selectedObject == gameObject) { OutputWindow_Log(WARNING_TEXT[WARNINGS.OBJECT_CANNOT_COPIED], LogType.Warning, selectedObject.name); } else { if (tempObject) { DestroyImmediate(tempObject); } selectedObject.CopyObject(out tempObject); OutputWindow_Log(MESSAGE_TEXT[MESSAGES.OBJECT_COPIED], tempObject.name); } } if (GUI.Button(new Rect(windowRect.x + 185, windowRect.y + 325, 45, 22), MainWindow[6], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray))) { if (tempObject) { OnPasteObject(); } else { OutputWindow_Log(WARNING_TEXT[WARNINGS.TEMP_OBJECT_EMPTY], LogType.Warning); } } if (GUI.Button(new Rect(windowRect.x + 235, windowRect.y + 325, 58, 22), MainWindow[7], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray))) { if (selectedObject == gameObject) { OutputWindow_Log(WARNING_TEXT[WARNINGS.PROGRAM_OBJECT_CANNOT_DESTROY], LogType.Warning, selectedObject.name); } /* * else if (selectedObject.IsRoot()) * { * OutputWindow_Log(WARNING_TEXT[WARNINGS.ROOT_OBJECT_CANNOT_DESTROY], LogType.Warning); * }*/ else { DestroyObject(true); } } GUI.TextArea(new Rect(windowRect.x + 5, windowRect.y + 355, windowRect.width - 10, 100), OBJECTINFO); if (isColliderSelected) { GUI.TextArea(new Rect(windowRect.x + 5, windowRect.y + 465, windowRect.width - 10, 72), COLLIDERINFO); } GUI.Label(new Rect(windowRect.x + 5, windowRect.y + 542, 145, 22), "Transform shorthands:", SNStyles.GetGuiItemStyle(GuiItemType.LABEL, GuiColor.Green, TextAnchor.MiddleLeft)); if (GUI.Button(new Rect(windowRect.x + 150, windowRect.y + 542, 140, 22), showLocal ? MainWindow[8] : MainWindow[9], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray))) { showLocal = !showLocal; if (showLocal) { OutputWindow_Log(MESSAGE_TEXT[MESSAGES.TRANSFORM_TO_LOCAL]); } else { OutputWindow_Log(MESSAGE_TEXT[MESSAGES.TRANSFORM_TO_WORLD]); } } if (GUI.Button(new Rect(windowRect.x + 5, windowRect.y + 567, 140, 22), MainWindow[10], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray))) { if (showLocal) { selectedObject.transform.SetLocalsToZero(); OutputWindow_Log(MESSAGE_TEXT[MESSAGES.LOCALS_TO_ZERO], selectedObject.name); } else { selectedObject.transform.SetWorldToZero(); OutputWindow_Log(MESSAGE_TEXT[MESSAGES.WORLD_TO_ZERO], selectedObject.name); } } if (GUI.Button(new Rect(windowRect.x + 150, windowRect.y + 567, 140, 22), MainWindow[11], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray))) { if (showLocal) { selectedObject.transform.SetLocalPositionToZero(); OutputWindow_Log(MESSAGE_TEXT[MESSAGES.LOCAL_POS_TO_ZERO], selectedObject.name); } else { selectedObject.transform.SetPositionToZero(); OutputWindow_Log(MESSAGE_TEXT[MESSAGES.WORLD_POS_TO_ZERO], selectedObject.name); } } if (GUI.Button(new Rect(windowRect.x + 5, windowRect.y + 592, 140, 22), MainWindow[12], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray))) { if (showLocal) { selectedObject.transform.SetLocalRotationToZero(); OutputWindow_Log(MESSAGE_TEXT[MESSAGES.LOCAL_ROT_TO_ZERO], selectedObject.name); } else { selectedObject.transform.SetRotationToZero(); OutputWindow_Log(MESSAGE_TEXT[MESSAGES.WORLD_ROT_TO_ZERO], selectedObject.name); } } if (GUI.Button(new Rect(windowRect.x + 150, windowRect.y + 592, 140, 22), MainWindow[13], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray))) { selectedObject.transform.SetLocalScaleToOne(); OutputWindow_Log(MESSAGE_TEXT[MESSAGES.LOCAL_SCALE_TO_ONE], selectedObject.name); } if (GUI.Button(new Rect(windowRect.x + 5, windowRect.y + 617, 140, 22), MainWindow[14], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray))) { DrawObjectBounds dob = selectedObject.GetOrAddVisualBase(BaseType.Object).GetComponent <DrawObjectBounds>(); selectedObject.transform.SetTransformInfo(ref dob.transformBase); OutputWindow_Log(MESSAGE_TEXT[MESSAGES.TRANSFORM_TO_ORIGINAL], selectedObject.name); } if (isColliderSelected) { if (GUI.Button(new Rect(windowRect.x + 150, windowRect.y + 617, 140, 22), MainWindow[15], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray))) { DrawColliderControl dcc = selectedObject.GetComponentInChildren <DrawColliderControl>(); int colliderID = objects[selected_component].GetInstanceID(); selectedObject.ResetCollider(dcc.ColliderBases[colliderID].ColliderBase, colliderID); GetColliderInfo(); OutputWindow_Log(MESSAGE_TEXT[MESSAGES.COLLIDER_TO_ORIGINAL], dcc.ColliderBases[colliderID].ColliderBase.ColliderType.ToString()); } } if (GUI.Button(new Rect(windowRect.x + 5, (windowRect.y + windowRect.height) - 27, windowRect.width - 10, 22), MainWindow[16], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray))) { OnDestroy(); } OutputWindow_OnGUI(); EditWindow_OnGUI(); ObjectWindow_OnGUI(); ComponentWindow_OnGUI(); RendererWindow_OnGUI(); ObjectInfoWindow_OnGUI(); AddComponentWindow_OnGUI(); MarkWindow_OnGUI(); FMODWindow_OnGUI(); if (GUI.tooltip != "") { GUIStyle gUIStyle = SNStyles.GetGuiItemStyle(GuiItemType.TEXTAREA, GuiColor.Green, TextAnchor.MiddleLeft); Vector2 vector2 = gUIStyle.CalcSize(new GUIContent(GUI.tooltip)); GUI.Label(new Rect(Event.current.mousePosition.x + 10, Event.current.mousePosition.y + 10, vector2.x, vector2.y), GUI.tooltip, gUIStyle); } }
void OnGUI() { GUILayout.Label("TEXTURE COMBINER", EditorStyles.boldLabel); GUILayout.Space(8); EditorGUI.BeginChangeCheck(); GUILayout.BeginHorizontal(); GUILayout.Label("Combined texture: ", GUILayout.ExpandWidth(false)); var newTexture = (Texture2D)EditorGUILayout.ObjectField(textureSaved, typeof(Texture2D), false); GUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck() && newTexture != textureSaved) { if (Load(newTexture)) { textureSaved = newTexture; } } GUILayout.Space(8f); float space = 8f; var r = EditorGUILayout.GetControlRect(false, (64f + space) * 4f); var texRect = r; texRect.x += 24f; texRect.height = 64f; texRect.width = 64f; textureR = (Texture2D)EditorGUI.ObjectField(texRect, textureR, typeof(Texture2D), false); texRect.y += 64f + space; textureG = (Texture2D)EditorGUI.ObjectField(texRect, textureG, typeof(Texture2D), false); texRect.y += 64f + space; textureB = (Texture2D)EditorGUI.ObjectField(texRect, textureB, typeof(Texture2D), false); texRect.y += 64f + space; textureA = (Texture2D)EditorGUI.ObjectField(texRect, textureA, typeof(Texture2D), false); var lblRect = r; lblRect.width = 20f; lblRect.x += 4f; lblRect.y += 22f; GUI.Label(lblRect, "R", EditorStyles.largeLabel); lblRect.y += 64f + space; GUI.Label(lblRect, "G", EditorStyles.largeLabel); lblRect.y += 64f + space; GUI.Label(lblRect, "B", EditorStyles.largeLabel); lblRect.y += 64f + space; GUI.Label(lblRect, "A", EditorStyles.largeLabel); var chanRect = r; chanRect.width = 120f; chanRect.x += texRect.x + texRect.width + space; chanRect.height = 64f; sourceR = (Channel)GUI_SourceChannel(chanRect, sourceR); chanRect.y += 64f + space; sourceG = (Channel)GUI_SourceChannel(chanRect, sourceG); chanRect.y += 64f + space; sourceB = (Channel)GUI_SourceChannel(chanRect, sourceB); chanRect.y += 64f + space; sourceA = (Channel)GUI_SourceChannel(chanRect, sourceA); var resultRect = r; resultRect.height = (64f + space) * 4f; resultRect.x += lblRect.x + lblRect.width + texRect.width + chanRect.width + 64f; resultRect.width = resultRect.height; if (textureCombined != null || textureSaved != null) { var alphaRect = resultRect; alphaRect.x += resultRect.width + space; //handy way to highlight the saved texture when clicking on the big preview if (textureSaved != null) { EditorGUI.ObjectField(resultRect, textureSaved, typeof(Texture2D), false); EditorGUI.ObjectField(alphaRect, textureSaved, typeof(Texture2D), false); } if (textureCombined != null) { GUI.Box(resultRect, GUIContent.none); GUI.Box(alphaRect, GUIContent.none); //rgb GUI.DrawTexture(resultRect, textureCombined, ScaleMode.StretchToFill, false, 0); //alpha GUI.DrawTexture(alphaRect, textureCombinedAlpha, ScaleMode.StretchToFill, false, 0); } } else { resultRect.width += resultRect.width + space; EditorGUI.HelpBox(resultRect, "texture not generated yet", MessageType.Warning); } GUILayout.Space(8f); GUILayout.BeginHorizontal(); //Texture size EditorGUI.BeginChangeCheck(); textureSize = EditorGUILayout.Popup(textureSize, textureSizes, GUILayout.Width(60f)); using (new EditorGUI.DisabledScope(textureSize != textureSizes.Length - 1)) textureWidth = EditorGUILayout.IntField(textureWidth, GUILayout.Width(60f)); GUILayout.Label("x"); using (new EditorGUI.DisabledScope(textureSize != textureSizes.Length - 1)) textureHeight = EditorGUILayout.IntField(textureHeight, GUILayout.Width(60f)); if (EditorGUI.EndChangeCheck()) { textureWidth = Mathf.Clamp(textureWidth, 1, 16384); textureHeight = Mathf.Clamp(textureHeight, 1, 16384); TextureSizeUpdated(); } GUILayout.FlexibleSpace(); //Save button if (GUILayout.Button("SAVE AS...", GUILayout.Width(120f))) { SaveAs(saveFormat); } GUILayout.EndHorizontal(); //Options GUILayout.BeginHorizontal(); saveFormat = (SaveFormat)EditorGUILayout.EnumPopup(saveFormat, GUILayout.Width(60f)); removeCompression = GUILayout.Toggle(removeCompression, new GUIContent("Remove compression (saved texture)", "Remove compression from input textures for the saved texture"), EditorStyles.miniButton); removeCompressionPreview = GUILayout.Toggle(removeCompressionPreview, new GUIContent("Remove compression (preview)", "Remove compression from input textures for the preview image.\n\nThis is a separate setting because disabling/enabling back compression takes a few seconds and that can be annoying when regularly changing the inputs."), EditorStyles.miniButton); GUILayout.FlexibleSpace(); //Reset button if (GUILayout.Button("RESET", GUILayout.Width(120f))) { Reset(); } GUILayout.EndHorizontal(); if (GUI.changed) { RefreshCombinedTexture(true); } }
public static void DrawButton(float x, float y, float w, float h, string txt) { GUI.Button(new Rect(position_x(x), position_y(y), size_x(w), size_y(h)), txt); }
/// <summary> /// Defines all the UI Drawing here /// </summary> void OnGUI() { // Set Window Min Size minSize = new Vector2(300.0f, 200.0f); // Label (Language-Based) GUILayout.Label(Lang.GetString(Key.SpecPrefabFolder)); // Get the resource folder path resourceFolderPath = GUILayout.TextField(resourceFolderPath); // Label GUILayout.Label("Specs"); if (GUILayout.Button(Lang.GetString(Key.Refresh))) { // Show a progress bar EditorUtility.DisplayProgressBar(Lang.GetString(Key.Loading), Lang.GetString(Key.Loading), 0.5f); System.Threading.Thread.Sleep(200); // For demoing // Clear the list guids.Clear(); // Find all the specs in the prefabs folder guids.AddRange(AssetDatabase.FindAssets("t:GameObject", new string[] { resourceFolderPath })); // We are done. Clear the Progress Bar from the screen EditorUtility.ClearProgressBar(); } // List all the Specs // -- Calculate widths and more const float NAME_LABEL_LENGTH = 100.0f; const float HEIGHT = 18.0f; const float VERTICAL_SPACING = HEIGHT + 2.0f; const float PADDING = 5.0f; const float START_HEIGHT = 5 * HEIGHT; float width = (position.width - NAME_LABEL_LENGTH * 0.1f * 10.0f - PADDING) * 0.245f; float horizontalSpacing = (position.width - NAME_LABEL_LENGTH * 0.1f * 10.0f - PADDING) * 0.25f; // -- Draw UI for each Spec for (int i = 0; i < guids.Count; ++i) { // Load it GameObject prefab = (GameObject)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(guids[i]), typeof(GameObject)); // Check if it is a Player Spec var spec = prefab.GetComponent <PlayerSpec>(); // Add it to the list if (spec != null) { // Draw Name GUI.Label(new Rect(5, START_HEIGHT + VERTICAL_SPACING * i, NAME_LABEL_LENGTH, HEIGHT), spec.name); // Draw Progress Bars showing stats EditorGUI.ProgressBar(new Rect(NAME_LABEL_LENGTH + horizontalSpacing * 0.0f, START_HEIGHT + VERTICAL_SPACING * i, width, HEIGHT), (float)spec.Strength / PlayerSpec.MAX_SINGLE_VALUE, Lang.GetString(Key.Strength)); EditorGUI.ProgressBar(new Rect(NAME_LABEL_LENGTH + horizontalSpacing * 1.0f, START_HEIGHT + VERTICAL_SPACING * i, width, HEIGHT), (float)spec.Agility / PlayerSpec.MAX_SINGLE_VALUE, Lang.GetString(Key.Agility)); EditorGUI.ProgressBar(new Rect(NAME_LABEL_LENGTH + horizontalSpacing * 2.0f, START_HEIGHT + VERTICAL_SPACING * i, width, HEIGHT), (float)spec.Accuracy / PlayerSpec.MAX_SINGLE_VALUE, Lang.GetString(Key.Accuracy)); // Draw Button to show the object in inspector if (GUI.Button(new Rect(NAME_LABEL_LENGTH + horizontalSpacing * 3.0f, START_HEIGHT + VERTICAL_SPACING * i, width, HEIGHT), Lang.GetString(Key.Open))) { Selection.activeGameObject = spec.gameObject; } } } }
public static bool DrawButtonReturn(float x, float y, float w, float h, string txt, string hoverTxt, GUIStyle style) { return(GUI.Button(new Rect(position_x(x), position_y(y), size_x(w), size_y(h)), new GUIContent(txt, hoverTxt), style)); }
void Window_Panel(int id) { GUI.backgroundColor = INC.color_background; if (SUPERUSER.isLogeds != "Logged") { GUILayout.Label("Login:"******"Password:"******"Logined")) { login = login.Trim(); pasword = pasword.Trim(); if (login == "") { PanelInformer.instance.Add("Введите ник.", PanelInformer.LOG_TYPE.WARNING); } else if (pasword == "") { PanelInformer.instance.Add("Введите пароль.", PanelInformer.LOG_TYPE.WARNING); } else if (!loggge) { loggge = true; PanelInformer.instance.Add("Logined....", PanelInformer.LOG_TYPE.INFORMAION); StartCoroutine(Logined()); } } } else { if (styleLabel == null) { styleLabel = new GUIStyle(GUI.skin.label); styleLabel.alignment = TextAnchor.MiddleCenter; } GUILayout.Label("---SUPERUSER---", styleLabel); GUILayout.Label("Спец приемы(Земля/Воздух):"); GUILayout.BeginHorizontal(); GUILayout.BeginVertical(GUILayout.Width(160f)); foreach (string str in special_list) { GUILayout.Label(str, GUI.skin.button); } GUILayout.EndVertical(); GUILayout.BeginVertical(); GUILayout.Space(0f); for (int i = 0; i < special_list.Count; i++) { string sss = ""; if (special_list[i] == special_ground) { sss = "✔"; } if (GUILayout.Button(sss)) { special_ground = special_list[i]; } } GUILayout.EndVertical(); GUILayout.BeginVertical(); GUILayout.Space(0f); for (int i = 0; i < special_list.Count; i++) { string sss = ""; if (special_list[i] == special_air) { sss = "✔"; } if (GUILayout.Button(sss)) { special_air = special_list[i]; } } GUILayout.EndVertical(); GUILayout.EndHorizontal(); Setting("Выбираться из лап:", 0, 1); GUILayout.Label("Скорость перезарядки: " + speed_dc.ToString("F") + " сек."); speed_dc = GUILayout.HorizontalSlider(speed_dc, 0.1f, 10f); } GUI.DragWindow(); RectS(); }
void OnGUI() { DoContextMenu(); GUILayout.Label("Quick Material", EditorStyles.boldLabel); Rect r = GUILayoutUtility.GetLastRect(); int left = Screen.width - 68; GUILayout.BeginHorizontal(GUILayout.MaxWidth(Screen.width - 74)); GUILayout.BeginVertical(); m_QueuedMaterial = (Material)EditorGUILayout.ObjectField(m_QueuedMaterial, typeof(Material), true); GUILayout.Space(2); if (GUILayout.Button("Apply (Ctrl+Shift+Click)")) ApplyMaterial(MeshSelection.topInternal, m_QueuedMaterial); GUI.enabled = editor != null && MeshSelection.selectedFaceCount > 0; if (GUILayout.Button("Match Selection")) { m_QueuedMaterial = EditorMaterialUtility.GetActiveSelection(); } GUI.enabled = true; GUILayout.EndVertical(); GUI.Box(new Rect(left, r.y + r.height + 2, 64, 64), ""); var previewTexture = EditorMaterialUtility.GetPreviewTexture(m_QueuedMaterial); if (previewTexture != null) { GUI.Label(new Rect(left + 2, r.y + r.height + 4, 60, 60), previewTexture); } else { GUI.Box(new Rect(left + 2, r.y + r.height + 4, 60, 60), ""); GUI.Label(new Rect(left + 2, r.height + 28, 120, 32), "None\n(Texture)"); } GUILayout.EndHorizontal(); GUILayout.Space(4); GUI.backgroundColor = PreferenceKeys.proBuilderDarkGray; UI.EditorGUIUtility.DrawSeparator(2); GUI.backgroundColor = Color.white; GUILayout.Label("Material Palette", EditorStyles.boldLabel); EditorGUI.BeginChangeCheck(); m_CurrentPaletteIndex = EditorGUILayout.Popup("", m_CurrentPaletteIndex, m_AvailablePalettes_Str); if (EditorGUI.EndChangeCheck()) { MaterialPalette newPalette = null; // Add a new material palette if (m_CurrentPaletteIndex >= m_AvailablePalettes.Length) { string path = AssetDatabase.GenerateUniqueAssetPath("Assets/Material Palette.asset"); newPalette = FileUtility.LoadRequired<MaterialPalette>(path); EditorGUIUtility.PingObject(newPalette); } else { newPalette = m_AvailablePalettes[m_CurrentPaletteIndex]; } SetMaterialPalette(newPalette); } EditorGUI.BeginChangeCheck(); s_CurrentPalette = (MaterialPalette)EditorGUILayout.ObjectField(s_CurrentPalette, typeof(MaterialPalette), false); if (EditorGUI.EndChangeCheck()) SetMaterialPalette(s_CurrentPalette); GUILayout.Space(4); Material[] materials = CurrentPalette; m_ViewScroll = GUILayout.BeginScrollView(m_ViewScroll); for (int i = 0; i < materials.Length; i++) { if (i == 10) { GUILayout.Space(2); GUI.backgroundColor = PreferenceKeys.proBuilderLightGray; UI.EditorGUIUtility.DrawSeparator(1); GUI.backgroundColor = Color.white; GUILayout.Space(2); } GUILayout.BeginHorizontal(); if (i < 10) { if (GUILayout.Button("Alt + " + (i == 9 ? 0 : (i + 1)).ToString(), EditorStyles.miniButton, GUILayout.MaxWidth(58))) ApplyMaterial(MeshSelection.topInternal, materials[i]); } else { if (GUILayout.Button("Apply", EditorStyles.miniButtonLeft, GUILayout.MaxWidth(44))) ApplyMaterial(MeshSelection.topInternal, materials[i]); GUI.backgroundColor = Color.red; if (GUILayout.Button("", EditorStyles.miniButtonRight, GUILayout.MaxWidth(14))) { Material[] temp = new Material[materials.Length - 1]; System.Array.Copy(materials, 0, temp, 0, materials.Length - 1); materials = temp; SaveUserMaterials(materials); return; } GUI.backgroundColor = Color.white; } EditorGUI.BeginChangeCheck(); materials[i] = (Material)EditorGUILayout.ObjectField(materials[i], typeof(Material), false); if (EditorGUI.EndChangeCheck()) SaveUserMaterials(materials); GUILayout.EndHorizontal(); } if (GUILayout.Button("Add")) { Material[] temp = new Material[materials.Length + 1]; System.Array.Copy(materials, 0, temp, 0, materials.Length); materials = temp; SaveUserMaterials(materials); } GUILayout.EndScrollView(); }
/// <summary> /// This displays the graph /// </summary> public void Display(GUIStyle AreaStyle, int horizontalBorder, int verticalBorder) { ScrollView = GUILayout.BeginScrollView(ScrollView, false, false); GUIStyle BackgroundStyle = new GUIStyle(GUI.skin.box); BackgroundStyle.hover = BackgroundStyle.active = BackgroundStyle.normal; GUILayout.Space(verticalBorder); //Vertical axis and labels GUILayout.BeginVertical(); GUILayout.BeginArea(new Rect(20 + horizontalBorder, 15 + verticalBorder, 30, displayRect.height + 2 * verticalBorder)); GUIStyle LabelStyle = new GUIStyle(GUI.skin.label); LabelStyle.alignment = TextAnchor.UpperCenter; GUILayout.Label(topBound, LabelStyle, GUILayout.Height(20), GUILayout.ExpandWidth(true)); int pixelspace = (int)displayRect.height / 2 - 72; GUILayout.Space(pixelspace); GUILayout.Label(verticalLabel, LabelStyle, GUILayout.Height(100), GUILayout.ExpandWidth(true)); GUILayout.Space(pixelspace); GUILayout.Label(bottomBound, LabelStyle, GUILayout.Height(20), GUILayout.ExpandWidth(true)); GUILayout.EndArea(); GUILayout.EndVertical(); //Graph itself GUILayout.BeginVertical(); Rect areaRect = new Rect(50 + horizontalBorder, 15 + verticalBorder, displayRect.width + 2 * horizontalBorder, displayRect.height + 2 * verticalBorder); GUILayout.BeginArea(areaRect); GUI.DrawTexture(displayRect, graph); foreach (KeyValuePair <string, ferramGraphLine> pair in allLines) { GUI.DrawTexture(displayRect, pair.Value.Line()); } GUILayout.EndArea(); //Horizontal Axis and Labels GUILayout.BeginArea(new Rect(50 + horizontalBorder, displayRect.height + verticalBorder + 15, displayRect.width + 2 * horizontalBorder, 30)); GUILayout.BeginHorizontal(GUILayout.Width(displayRect.width)); GUILayout.Label(leftBound, LabelStyle, GUILayout.Width(20), GUILayout.ExpandWidth(true)); pixelspace = (int)displayRect.width / 2 - 102; GUILayout.Space(pixelspace); GUILayout.Label(horizontalLabel, LabelStyle, GUILayout.Width(160)); GUILayout.Space(pixelspace); GUILayout.Label(rightBound, LabelStyle, GUILayout.Width(20), GUILayout.ExpandWidth(true)); GUILayout.EndHorizontal(); GUILayout.EndArea(); GUILayout.EndVertical(); GUILayout.BeginVertical(); //Legend Area int movementdownwards = ((int)displayRect.height - allLines.Count * 20) / 2; foreach (KeyValuePair <string, ferramGraphLine> pair in allLines) { if (!pair.Value.displayInLegend) { continue; } GUILayout.BeginArea(new Rect(60 + displayRect.width + 2 * horizontalBorder, 15 + verticalBorder + movementdownwards, 25, 15)); GUI.DrawTexture(new Rect(1, 1, 25, 15), pair.Value.LegendImage()); GUILayout.EndArea(); GUILayout.BeginArea(new Rect(85 + displayRect.width + 2 * horizontalBorder, 15 + verticalBorder + movementdownwards, 35, 15)); GUILayout.Label(pair.Key, LabelStyle); GUILayout.EndArea(); movementdownwards += 20; } GUILayout.EndVertical(); int rightofarea = (int)displayRect.width + 2 * horizontalBorder + 30; int bottomofarea = (int)displayRect.height + 2 * verticalBorder + 30; GUILayout.Space(bottomofarea); GUILayout.EndScrollView(); }
void OnGUI() { GUI.Label(new Rect(10, 10, 100, 20), "" + distance); }
internal bool DrawClosableTabButton( string buttonText, bool wasActive, bool isClosable, float width, Action repaintAction, out bool isCloseButtonClicked) { isCloseButtonClicked = false; GUIContent buttonContent = new GUIContent(buttonText); GUIStyle buttonStyle = (wasActive) ? UnityStyles.PlasticWindow.ActiveTabButton : EditorStyles.toolbarButton; Rect toggleRect = GUILayoutUtility.GetRect( buttonContent, buttonStyle, GUILayout.Width(width)); if (isClosable && Event.current.type == EventType.MouseMove) { if (mCloseButtonRect.Contains(Event.current.mousePosition)) { SetCloseButtonState( CloseButtonState.Hovered, repaintAction); } else { SetCloseButtonState( CloseButtonState.Normal, repaintAction); } } if (isClosable && Event.current.type == EventType.MouseDown) { if (mCloseButtonRect.Contains(Event.current.mousePosition)) { SetCloseButtonState( CloseButtonState.Clicked, repaintAction); Event.current.Use(); } } if (isClosable && Event.current.type == EventType.MouseUp) { if (mCloseButtonRect.Contains(Event.current.mousePosition)) { Event.current.Use(); isCloseButtonClicked = true; } if (IsTabClickWithMiddleButton(toggleRect, Event.current)) { Event.current.Use(); isCloseButtonClicked = true; } SetCloseButtonState( CloseButtonState.Normal, repaintAction); } bool isActive = GUI.Toggle( toggleRect, wasActive, buttonText, buttonStyle); if (isClosable && toggleRect.height > 1) { mCloseButtonRect = DrawCloseButton( toggleRect, mCloseButtonState); } if (wasActive) { DrawUnderline(toggleRect); } return(isActive); }
public void OnGUI() { if (_animator == null) { _animator = (Animator)Transform.FindObjectOfType(typeof(Animator)); } if (_active) { //Time Scale Vertical Slider //Time.timeScale = GUI.VerticalSlider (Rect (185, 50, 20, 150), Time.timeScale, 2.0, 0.0); //Check if there are more in list than max buttons (true adds "next" and "prev" buttons) if (_animations.Length > maxButtons) { //Prev button if (GUI.Button(new Rect(20.0f, (float)((maxButtons + 1) * 18), 75.0f, 18.0f), "Prev")) { if (page > 0) { page--; } else { page = pages; } } //Next button if (GUI.Button(new Rect(95.0f, (float)((maxButtons + 1) * 18), 75.0f, 18.0f), "Next")) { if (page < pages) { page++; } else { page = 0; } } //Page text GUI.Label(new Rect(60.0f, (float)((maxButtons + 2) * 18), 150.0f, 22.0f), "Page" + (page + 1) + " / " + (pages + 1)); } //Calculate how many buttons on current page (last page might have less) int pageButtonCount = _animations.Length - (page * maxButtons); //Debug.Log(pageButtonCount); if (pageButtonCount > maxButtons) { pageButtonCount = maxButtons; } //Adds buttons based on how many particle systems on page for (int i = 0; i < pageButtonCount; i++) { string buttonText = _animations[i + (page * maxButtons)]; if (removeTextFromButton != "") { buttonText = buttonText.Replace(removeTextFromButton, ""); } if (GUI.Button(new Rect(20.0f, (float)(i * 18 + 18), 150.0f, 18.0f), buttonText)) { if (_crossFade) { if (_lastAnim == (_animations[i + page * maxButtons])) { this._animator.Play(""); } _animator.CrossFade(_animations[i + page * maxButtons], .1f); this._lastAnim = _animations[i + page * maxButtons]; } else { _animator.Play(_animations[i + page * maxButtons]); } counter = i + (page * maxButtons); } } } if (image != null) { var tmp_cs1 = image.pixelInset; tmp_cs1.x = (float)((Screen.width) - (image.texture.width)); image.pixelInset = tmp_cs1; } }
void OnGUI() { GUI.Box(new Rect(20, 20, healthBarLength, 20), currentHealth + "/" + maxHealth); GUI.Box(new Rect(18, 18, baseBarLength + 4, 24), " "); }
public override void Render() { GUI.DrawTextureWithTexCoords(Position, Sprite, Coord); }
// Token: 0x06000007 RID: 7 private void OnGUI() { if (!this.state.MovementFrozen) { if (this.state.GameWin) { this.alphaFadeValue += Mathf.Clamp01(Time.deltaTime / 10f); this.orbFadeValue -= Mathf.Clamp01(Time.deltaTime / 5f); GUI.depth = 0; GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 1f - this.alphaFadeValue); GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), this.whiteTexture); GameObject.FindGameObjectWithTag("Audio").GetComponent<MyUnitySingleton>().volume = this.volume; GameObject.FindGameObjectWithTag("Audio").GetComponent<MyUnitySingleton>().mouseSensitivity = this.mouseSensitivity; GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 0.5f); GUI.skin.label = this.myStyle; if (this.times[0] != string.Empty) { GUI.skin.label.fontSize = (int)this.fontSizes.x; Vector2 vector = GUI.skin.label.CalcSize(new GUIContent(this.times[0])); GUI.Label(new Rect((float)Screen.width * 0.5f - vector.x / 2f, 100f * this.scale.y, vector.x, 100f), this.times[0]); GUI.skin.label.fontSize = (int)this.fontSizes.y; vector = GUI.skin.label.CalcSize(new GUIContent("All orbs collected!")); GUI.Label(new Rect((float)Screen.width * 0.5f - vector.x / 2f, 50f * this.scale.y, vector.x, 50f), "All orbs collected!"); } GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, this.alphaFadeValue); } else { if (this.loading) { GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, this.loadFadeValue); GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), this.loadingScreen); } GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, this.alphaFadeValue); GUI.skin.button.wordWrap = true; this.gamma = (float)this.state.SqrtOneMinusVSquaredCWDividedByCSquared; this.C = (float)this.state.SpeedOfLight; this.playerVel = (float)this.state.PlayerVelocity; float num = Mathf.Abs((float)this.state.MaxSpeed / this.C) * 75f; if (double.IsNaN((double)num) || num == 0f || num > 75f) { num = 0.001f; } float num2 = Mathf.Abs(this.playerVel / (float)this.state.MaxSpeed) * 15f; if (double.IsNaN((double)num2) || num2 == 0f) { num2 = 0.001f; } int num3 = (int)(this.gamma / (1f + this.playerVel / this.C) * 372f); int num4 = (int)(this.gamma / (1f - this.playerVel / this.C) * 767f); float width = (float)Mathf.Min(num4 - num3, this.hudEmpty.width) * this.widthChange; GUI.depth = 2; GUI.BeginGroup(new Rect(0f, (float)Screen.height - this.barSize.y, (float)Screen.width, this.barSize.y)); GUI.DrawTexture(new Rect(0f, 0f, this.barSize.x, this.barSize.y), this.hudEmpty); GUI.EndGroup(); GUI.depth = 2; GUI.BeginGroup(new Rect((float)(Screen.width / 2) - Mathf.Min((float)(num4 - 550) * this.widthChange, (float)(Screen.width / 2)), (float)Screen.height - this.barSize.y, width, this.barSize.y)); GUI.DrawTexture(new Rect(-Mathf.Max((float)(Screen.width / 2) - (float)(num4 - 550) * this.widthChange, 0f), 0f, this.barSize.x, this.barSize.y), this.hud); GUI.EndGroup(); GUI.depth = 1; GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, this.orbFadeValue / 3f); GUI.DrawTexture(new Rect(0f, (float)Screen.height - this.barSize.y, this.barSize.x, this.barSize.y), this.hudFlash); GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, this.alphaFadeValue); GUI.BeginGroup(new Rect(this.numberPos.x, this.numberPos.y, this.numberSize.x, this.numberSize.y)); GUI.DrawTexture(new Rect(this.numberOffset.x, this.numberOffset.y, this.totalNumberSize.x, this.totalNumberSize.y), this.numbers); GUI.EndGroup(); GUI.BeginGroup(new Rect(0f, (float)Screen.height - this.barSize.y, (float)Screen.width, this.barSize.y)); GUI.depth = 1; GUIUtility.RotateAroundPivot(num2, new Vector2(this.playerArrowPos.x + this.playerArrowSize.x, this.playerArrowPos.y + this.playerArrowSize.y)); GUI.DrawTexture(new Rect(this.playerArrowPos.x, this.playerArrowPos.y, this.playerArrowSize.x, this.playerArrowSize.y), this.playerArrow); GUIUtility.RotateAroundPivot(-num2, new Vector2(this.playerArrowPos.x + this.playerImageSize.x / 2f, this.playerArrowPos.y + this.playerImageSize.y / 2f)); GUI.DrawTexture(new Rect(this.playerArrowPos.x, this.playerArrowPos.y - this.playerImageSize.y * 0.8f, this.playerImageSize.x, this.playerImageSize.y), this.playerImage); GUIUtility.RotateAroundPivot(num2, new Vector2(this.playerArrowPos.x + this.playerImageSize.x / 2f, this.playerArrowPos.y + this.playerImageSize.y / 2f)); GUIUtility.RotateAroundPivot(-num2, new Vector2(this.playerArrowPos.x + this.playerArrowSize.x, this.playerArrowPos.y + this.playerArrowSize.y)); GUIUtility.RotateAroundPivot(-num, new Vector2(this.playerArrowPos.x + this.playerArrowSize.x + this.lightArrowSize.x / 10f, this.playerArrowPos.y)); GUI.DrawTexture(new Rect(this.lightArrowPos.x, this.lightArrowPos.y, this.lightArrowSize.x, this.lightArrowSize.y), this.lightArrow); GUIUtility.RotateAroundPivot(num, new Vector2(this.playerArrowPos.x + this.playerArrowSize.x + this.lightArrowSize.x / 10f, this.playerArrowPos.y)); GUI.EndGroup(); this.UpdateTmpTimes(); this.timeleft -= Time.deltaTime; this.accum += Time.timeScale / Time.deltaTime; this.frames++; if ((double)this.timeleft <= 0.0) { this.curFPS = this.accum / (float)this.frames; this.timeleft = this.updateInterval; this.accum = 0f; this.frames = 0; } float num5 = this.alphaFadeValue; if (this.orbFadeValue >= 0f) { this.orbFadeValue -= Mathf.Clamp01(Time.deltaTime); } } GUI.BeginGroup(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height)); int p = 10; RectOffset padding = new RectOffset(p, p, p, 0); float fontSize = this.fontSizes.y / 1.75f; GUI.skin.box.padding = padding; Vector2 testSize = GUI.skin.box.CalcSize(new GUIContent("test")); float maxY = (float)Screen.height - this.barSize.y; float currY = (float)GameState.wrSplits.Length * testSize.y; float scale; if (currY > maxY) { scale = maxY / currY; fontSize *= scale; p = (int)((float)p * scale); padding = new RectOffset(p, p, p, 0); } else { scale = 1f; } GUI.skin.box.normal.background = this.bgTex[1]; GUI.skin.box.fontSize = (int)fontSize; GUI.skin.box.font = this.myStyle.font; GUI.skin.label = new GUIStyle(this.myStyle); GUI.skin.label.fontSize = (int)fontSize; GUI.skin.label.padding = padding; GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 1f); Vector2 vecSplits = GUI.skin.box.CalcSize(new GUIContent("test")); Vector2 vector2 = GUI.skin.label.CalcSize(new GUIContent("Time: 000.000")); float col2Offset = GUI.skin.label.CalcSize(new GUIContent("-000.000")).x; if (this.showTimer) { float timerBoxWidth = 400f * scale; string playerTime = this.state.TotalTimePlayer.ToString("Time: 000.000"); string playerVel = this.state.playerVelocity.ToString("Speed: 00.000"); GUI.Box(new Rect(0f, 0f, vector2.x + 10f * scale, vector2.y), new GUIContent(playerTime)); GUI.Box(new Rect(0f, 0f + vector2.y, vector2.x + 10f * scale, vector2.y), new GUIContent(playerVel)); GUI.skin.box.alignment = TextAnchor.MiddleRight; GUI.Box(new Rect((float)Screen.width - timerBoxWidth, 0f, timerBoxWidth, vecSplits.y), new GUIContent("Time")); GUI.skin.box.normal.background = null; GUI.Box(new Rect((float)Screen.width - col2Offset, 0f, vecSplits.x, vecSplits.y), new GUIContent("+/-")); GUI.skin.box.alignment = TextAnchor.MiddleLeft; for (int s = 0; s < GameState.splitOn.Length; s++) { GUI.skin.box.normal.background = this.bgTex[s % 2]; double tempTime = this.state.splits[s]; GUI.Box(new Rect((float)Screen.width - timerBoxWidth, vecSplits.y * (float)(s + 1), timerBoxWidth, vecSplits.y), new GUIContent(GameState.splitNames[s])); if (tempTime > 0.0) { GUI.skin.box.normal.background = null; string splitTime = tempTime.ToString("F03"); vecSplits = GUI.skin.box.CalcSize(new GUIContent(splitTime)); float plusMinusSplitTime = (float)tempTime - GameState.wrSplits[s]; string pmSplit = ((plusMinusSplitTime < 0f) ? "" : "+") + plusMinusSplitTime.ToString("F02"); Vector2 vecPMSplit = GUI.skin.box.CalcSize(new GUIContent(pmSplit)); GUI.Label(new Rect((float)Screen.width - vecSplits.x, vecSplits.y * (float)(s + 1), vecSplits.x, vecSplits.y), splitTime); Color color = GUI.color; GUI.color = ((plusMinusSplitTime < 0f) ? Color.green : Color.red); GUI.Label(new Rect((float)Screen.width - vecSplits.x - col2Offset, vecSplits.y * (float)(s + 1), vecPMSplit.x, vecPMSplit.y), pmSplit); GUI.color = color; } } } GUI.color = Color.white; GUI.skin.box.fontSize = (int)(this.fontSizes.y * 0.5f); GUI.skin.box.normal.background = this.bgTex[1]; float orbsDisplayWidth = 0f; if (this.showOrbs) { orbsDisplayWidth = 400f; GUI.skin.box.padding = new RectOffset(0, 0, 0, 0); Vector2 boxTxtSize = GUI.skin.box.CalcSize(new GUIContent("00")); GUI.skin.box.padding = new RectOffset((int)(Math.Max(0f, GUIScripts.defaultOrbBoxSize - boxTxtSize.x) / 2f), 0, (int)((GUIScripts.defaultOrbBoxSize - boxTxtSize.y) / 2f), 0); GUI.BeginGroup(new Rect(10f, 100f, orbsDisplayWidth, 400f)); this.DrawRecentOrbs(); GUI.EndGroup(); GUI.skin.box.padding = new RectOffset(0, 0, 0, 0); boxTxtSize = GUI.skin.box.CalcSize(new GUIContent("@")); GUI.skin.box.padding = new RectOffset((int)((GUIScripts.defaultOrbBoxSize - boxTxtSize.x) / 2f), 0, (int)((GUIScripts.defaultOrbBoxSize - boxTxtSize.y) / 2f), 0); GUI.BeginGroup(new Rect(10f, 510f, orbsDisplayWidth, 400f)); this.DrawOrbsTotal(); GUI.EndGroup(); } GUI.EndGroup(); float keyOffset = this.keyDimensions + this.keyPadding; GUI.skin.label.fontSize = (int)(this.fontSizes.y * 1f); GUI.BeginGroup(new Rect((this.showOrbs ? orbsDisplayWidth : 0f) + 20f, (float)Screen.height - this.barSize.y - 2f * this.keyDimensions - 2.5f * this.keyPadding, 3f * keyOffset, 2f * keyOffset)); float num6 = this.keyPadding / 2f; GUI.Box(new Rect(0f, keyOffset, keyOffset, keyOffset), this.bgTex[0]); GUI.Box(new Rect(keyOffset, keyOffset, keyOffset, keyOffset), this.bgTex[0]); GUI.Box(new Rect(keyOffset * 2f, keyOffset, keyOffset, keyOffset), this.bgTex[0]); GUI.Box(new Rect(keyOffset, 0f, keyOffset, keyOffset), this.bgTex[0]); GUI.BeginGroup(new Rect(num6, num6, 3f * keyOffset - this.keyPadding, 2f * keyOffset - this.keyPadding)); GUI.Button(new Rect(0f, keyOffset, this.keyDimensions, this.keyDimensions), "A", Input.GetKey(KeyCode.A) ? this.pressedKeyStyle : this.keyStyle); GUI.Button(new Rect(keyOffset * 1f, keyOffset, this.keyDimensions, this.keyDimensions), "S", Input.GetKey(KeyCode.S) ? this.pressedKeyStyle : this.keyStyle); GUI.Button(new Rect(keyOffset * 2f, keyOffset, this.keyDimensions, this.keyDimensions), "D", Input.GetKey(KeyCode.D) ? this.pressedKeyStyle : this.keyStyle); GUI.Button(new Rect(keyOffset, 0f, this.keyDimensions, this.keyDimensions), "W", Input.GetKey(KeyCode.W) ? this.pressedKeyStyle : this.keyStyle); GUI.EndGroup(); GUI.EndGroup(); } else { GUI.depth = 2; GUI.BeginGroup(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height)); GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), this.blackTexture); GUI.DrawTexture(new Rect(this.difference.x, this.difference.y, this.size.x, this.size.y), this.optionsTexture); GUI.EndGroup(); GUI.depth = 1; GUI.BeginGroup(new Rect(this.difference.x, this.difference.y, this.size.x, this.size.y)); GUI.skin.button.normal.background = this.resumeTextures[0]; GUI.skin.button.hover.background = this.resumeTextures[1]; GUI.skin.button.active.background = this.resumeTextures[0]; if (GUI.Button(new Rect(this.resumeTexturePos.x, this.resumeTexturePos.y, this.resumeTextureSize.x, this.resumeTextureSize.y), string.Empty)) { this.state.ChangeState(); } GUI.skin.button.normal.background = this.menuTextures[0]; GUI.skin.button.hover.background = this.menuTextures[1]; GUI.skin.button.active.background = this.menuTextures[0]; if (GUI.Button(new Rect(this.menuTexturePos.x, this.menuTexturePos.y, this.menuTextureSize.x, this.menuTextureSize.y), string.Empty)) { Debug.Log("load level 1 -- GUIScripts OnGUI"); Application.LoadLevel(1); } GUI.DrawTexture(this.volumeRect, this.sliderBox); GUI.DrawTexture(this.mouseRect, this.sliderBox); this.saturated = GUI.Toggle(new Rect(this.saturatedPos.x, this.saturatedPos.y, this.checkBoxSize.x, this.checkBoxSize.y), !this.unSaturated, string.Empty); this.unSaturated = GUI.Toggle(new Rect(this.deSaturatedPos.x, this.deSaturatedPos.y, this.checkBoxSize.x, this.checkBoxSize.y), !this.saturated, string.Empty); GUI.EndGroup(); this.saturated = !this.unSaturated; if (base.GetComponentInChildren<ColorCorrectionEffect>()) { base.GetComponentInChildren<ColorCorrectionEffect>().enabled = this.unSaturated; } if (base.GetComponent<MovementScripts>()) { base.GetComponent<MovementScripts>().mouseSensitivity = this.mouseSensitivity; } if (GameObject.FindGameObjectWithTag("Playermesh")) { GameObject.FindGameObjectWithTag("Playermesh").GetComponent<AudioScripts>().volume = this.volume; } if (GameObject.FindGameObjectWithTag("Audio")) { GameObject.FindGameObjectWithTag("Audio").GetComponent<MyUnitySingleton>().mouseSensitivity = this.mouseSensitivity; GameObject.FindGameObjectWithTag("Audio").GetComponent<MyUnitySingleton>().volume = this.volume; GameObject.FindGameObjectWithTag("Audio").GetComponent<MyUnitySingleton>().saturated = this.saturated; } } if (this.unset && this.frames > 5) { GUI.skin.toggle.normal.background = this.checkBoxTextures[0]; GUI.skin.toggle.hover.background = this.checkBoxTextures[0]; GUI.skin.toggle.active.background = this.checkBoxTextures[1]; GUI.skin.toggle.onNormal.background = this.checkBoxTextures[1]; GUI.skin.toggle.onHover.background = this.checkBoxTextures[1]; GUI.skin.toggle.onActive.background = this.checkBoxTextures[0]; this.frames = 0; this.unset = false; } if (this.unset) { this.frames++; } }
public override void Display() { GUILayout.Label("GIT HISTORY", EditorStyles.boldLabel); #region ///// Header GUILayout.BeginHorizontal(); if (GUILayout.Button("Refresh")) { RefreshHistory(); } if (GUILayout.Button(string.Format("{0} Pull", behindBy))) { editorWindow.Close(); editorWindow.passwordWindow.callback = (password) => { SettingsTab settingsTab = editorWindow.GetSettingsTab(); RepositoryManager.Pull(settingsTab.GetUserUsername(), settingsTab.GetUserEmail(), password); GitEditor.GetWindow().Show(); }; editorWindow.passwordWindow.Show(true); } if (GUILayout.Button("Checkout current branch")) { RepositoryManager.CheckoutBranch(editorWindow.GetBranchesTab().GetCurrentBranchName()); } GUILayout.EndHorizontal(); #endregion /// Compute the total height of the scroll view float height = 0; historyCommits.ForEach((elt) => { // GUI Button, rule, space heght + status, id, message, changes height height += 70 + (elt.changes.Count + 2 + (elt.onlyLocal || elt.onlyRemote ? 1 : 0)) * EditorGUIUtility.singleLineHeight * 1.5f; }); historyScrollPos = GUILayout.BeginScrollView(historyScrollPos, false, true); #region ////// Display the scroll view GUI.BeginGroup(new Rect(0, 5, editorWindow.position.width - 15, height)); string currentCommitID = editorWindow.GetCommitTab().GetCurrentCommitID(); int historyCommitsCount = historyCommits.Count; for (int commitIdx = currentPage * 10; commitIdx < (currentPage + 1) * 10 && commitIdx < historyCommitsCount; commitIdx++) { HistoryCommit com = historyCommits[commitIdx]; if (com.onlyLocal) { GUI.backgroundColor = Color.green; } else if (com.onlyRemote) { GUI.backgroundColor = Color.red; } else if (com.id == currentCommitID) { GUI.backgroundColor = Color.blue; } #region ////// Display Box GUILayout.BeginVertical(new GUIStyle("Box")); #region ////// Display status if (com.onlyLocal || com.onlyRemote) { string status = ""; if (com.onlyLocal) { status = "Ready to be pushed"; } else if (com.onlyRemote) { status = "Ready to be pulled"; } else if (com.id == currentCommitID) { status = "Current deteched head"; } GUILayout.BeginHorizontal(); GUILayout.Label("Status : ", EditorStyles.boldLabel, GUILayout.Width(60)); GUILayout.Label(status, EditorStyles.boldLabel); GUILayout.EndHorizontal(); } #endregion GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label("ID : ", GUILayout.Width(60)); GUILayout.Label(com.id); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Author : ", GUILayout.Width(60)); GUILayout.Label(com.author); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Message : ", GUILayout.Width(60)); GUILayout.Label(com.message); GUILayout.EndHorizontal(); GUILayout.Space(10); foreach (string change in com.changes) { GUILayout.Label(change); } if (!com.onlyLocal && !com.onlyRemote) { if (GUILayout.Button("Revert to", GUILayout.Width(editorWindow.position.width - 30))) { RepositoryManager.Revert(com.id); } } GUILayout.EndVertical(); #endregion GUI.backgroundColor = Color.white; } GUI.EndGroup(); #endregion GUILayout.EndScrollView(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Prev page")) { if (currentPage > 0) { currentPage--; } } GUILayout.Label(string.Format("{0}/{1}", currentPage + 1, maxPage + 1)); if (GUILayout.Button("Next page")) { if (currentPage < maxPage - 1) { currentPage++; } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); }
void OnGUI() { GUI.Label(new Rect(10, 10, 100, 100), "Login!"); }
void OnGUI() { if (optionsClicked) { if (nameClicked) { playerName = playerName.Replace("\n", ""); MenuHide(); SetBackButtonEnable(true); nameClicked = true; optionsClicked = true; GUI.SetNextControlName("nameControll"); playerName = GUI.TextField(new Rect((Screen.width * 0.5f) - (Screen.width * 0.15f), Screen.height * 0.5f, Screen.width * 0.3f, Screen.height * 0.1f), playerName, 12, nameInputFieldStyle); GUI.FocusControl("nameControll"); playerName = playerName.Replace("\n", ""); } } if (hostClicked) { SetBackButtonEnable(true); GUI.Label(new Rect(Screen.width * 0.5f, Screen.height * 0.1f, 0, 0), "Server Name: ", serverNameLabel); serverName = GUI.TextField(new Rect((Screen.width * 0.5f) - (Screen.width * 0.15f), Screen.height * 0.3f, Screen.width * 0.3f, Screen.height * 0.1f), serverName, 20, nameInputFieldStyle); if (GUI.Button(new Rect(Screen.width * 0.4f, Screen.height * 0.4f, Screen.width * 0.2f, 30.0f), "OK", serverNameLabel)) { if (GlobalStorage.GetComponent <NetworkManager>().startServer(serverName)) { LobbyActive(); hostClicked = false; SetBackButtonEnable(false); } else { duplicateServer = true; //do something here } } if (duplicateServer) { GUI.Label(new Rect(Screen.width * 0.5f, Screen.height * 0.65f, 0, 0), "Server name is taken", serverNameLabel); } } if (serverListIsShown) { GUI.Label(new Rect(Screen.width * 0.5f, Screen.height * 0.05f, 0, 0), "Click servers to join", serverNameLabel); if (GlobalStorage.GetComponent <NetworkManager>().hostData != null) { int skipped = 0; if (GlobalStorage.GetComponent <NetworkManager>().hostData.Length > 0) { for (int i = 0; i < GlobalStorage.GetComponent <NetworkManager>().hostData.Length; i++) { if (GlobalStorage.GetComponent <NetworkManager>().hostData [i].comment == "Closed") { skipped++; continue; } if (GUI.Button(new Rect(Screen.width * 0.4f, serverListPosY * (i - skipped) + serverListOffestY, Screen.width * 0.2f, serverListPosY), GlobalStorage.GetComponent <NetworkManager>().hostData [i].gameName, serverNameLabel)) { GlobalStorage.GetComponent <NetworkManager>().Connect(i); LobbyActive(); serverListIsShown = false; } } } } else { GUI.Label(new Rect(Screen.width * 0.5f, Screen.height * 0.5f, 0, 0), "Waiting for servers...", serverNameLabel); } } }
public virtual void Render() { GUI.DrawTextureWithTexCoords(Position, Sprite, Coord); }
public override void OnRender() { if (gSkinB) { GUI.skin = gSkinB; } GUI.color = Color.white; //GUI.depth = -1000; GUI.DrawTexture(BoxPos, Box); switch (currentState) { case FishState.Brief: gSkinB.label.fontSize = 16; GUI.Label(new Rect((Screen.width * .5f) - 256, (Screen.height * .5f) + 256, 100, 50), "Profundidad: 0 m"); Back.Render(); Player.Render(); Bubbles.Render(); GUI.color = new Color(1, 0.36f, 0.22f, 1); GUI.Box(new Rect((Screen.width * .5f) - 224, (Screen.height * .5f) - 150, 448, 300), "\n \n\n\n\nMueve el anzuelo hacía los lados \n para evitar las palometas \n \nCuando enganches un Dorado \n pulsa varias veces Disparo \n para ascender y atraparlo \n \n \nPresiona Enter/Start para empezar \n¡Buena Suerte! \n"); gSkinB.label.fontSize = 24; GUI.color = new Color(1, 0.5f, 0.15f, 1); GUI.Label(new Rect((Screen.width * .5f) - 198, (Screen.height * .5f) - (Screen.height * .25f), (Screen.width * .5f), (Screen.height * .5f)), "\n - PESCA DEL DORADO -"); GUI.color = Color.white; break; case FishState.Start: Back.Render(); Player.Render(); gSkinB.label.fontSize = 14; GUI.Label(new Rect((Screen.width * .5f) - 256, (Screen.height * .5f) + 256, 100, 50), "Profundidad: 0 m"); gSkinB.label.fontSize = 48; if (Increment < 3.5f) { GUI.color = Color.yellow; GUI.Label(new Rect((Screen.width * .5f) - 196, (Screen.height * .25f), 100, 50), "PREPARADO"); } else if (Increment < 6.5f) { if (Time.frameCount % 2 == 0) { GUI.color = Color.white; } else { GUI.color = Color.yellow; } GUI.Label(new Rect((Screen.width * .5f) - 132, (Screen.height * .5f), 100, 50), "¿LISTO?"); } else { //ColorFade -= TimeStep * .25f; //GUI.color = new Color(1, 1, 1, ColorFade); if (Time.frameCount % 2 == 0) { GUI.color = Color.white; } else { GUI.color = Color.clear; } GUI.Label(new Rect((Screen.width * .5f) - 64, (Screen.height * .75f), 100, 50), "¡YA!"); } GUI.color = Color.white; Bubbles.Render(); break; case FishState.Falling: GUI.color = Color.white; gSkinB.label.fontSize = 14; GUI.Label(new Rect((Screen.width * .5f) - 256, (Screen.height * .5f) + 256, 100, 50), "Profundidad: " + (Increment * .1f).ToString("F2") + " m"); Back.Render(); Player.Render(); foreach (BonusObjects.Entity entity in Entoids) { if (entity.Position.center.y < Limits.yMax && entity.Position.center.y > Limits.yMin) { entity.Render(); } } Bubbles.Render(); break; case FishState.Rising: GUI.color = Color.white; gSkinB.label.fontSize = 14; GUI.Label(new Rect((Screen.width * .5f) - 256, (Screen.height * .5f) + 256, 100, 50), "Profundidad: " + (Increment * .1f).ToString("F2") + " m"); if (Time.frameCount % 2 == 0) { GUI.Label(new Rect((Screen.width * .5f) + 56, (Screen.height * .5f) + 256, 100, 50), "¡Pulsa Disparo!"); } Back.Render(); // Fishing Nylon Rendering GUI.DrawTextureWithTexCoords( new Rect((Screen.width * .5f) + ((BonusObjects.Player)Player).PosX, Player.Position.y - 256, Player.Sprite.width * .25f, Player.Sprite.height * 1), FishText, new Rect(0, .25f, .25f, .75f)); Player.Render(); foreach (BonusObjects.Entity entity in Entoids) { if (entity.Position.center.y < Limits.yMax && entity.Position.center.y > Limits.yMin) { entity.Render(); } } Bubbles.Render(); break; case FishState.Win: //if (Time.frameCount % 2 == 0) // GUI.color = Color.blue; //else GUI.color = Color.white; gSkinB.label.fontSize = 14; GUI.Label(new Rect((Screen.width * .5f) - 256, (Screen.height * .5f) + 256, 100, 50), "Profundidad: " + (Increment * .1f).ToString("F2") + " m"); Back.Render(); Player.Render(); //GUI.color = Color.green; if (Time.frameCount % 2 == 0) { GUI.color = Color.green; } else { GUI.color = Color.white; } foreach (BonusObjects.Entity entity in Entoids) { if (entity.Position.center.y < Limits.yMax && entity.Position.center.y > Limits.yMin) { entity.Render(); } } Bubbles.Render(); gSkinB.label.fontSize = 48; GUI.Label(new Rect((Screen.width * .5f) - 264, (Screen.height * .5f), 100, 50), "PESCA EXITOSA"); if (Target.myId == BonusObjects.Entity.typeId.Dorado) { gSkinB.label.fontSize = 14; if (Deep < 60) { GUI.Label(new Rect((Screen.width * .5f) - 250, (Screen.height * .75f), 100, 50), "Atrapaste un Dorado a " + (Deep * .1f).ToString("F2") + " metros\n" + " Recuperaste 30% de Energía extra!"); } else { GUI.Label(new Rect((Screen.width * .5f) - 250, (Screen.height * .75f), 100, 50), "Atrapaste un Dorado a " + (Deep * .1f).ToString("F2") + " metros\n" + " Recuperaste 100% Energía extra!"); } } else if (Target.myId == BonusObjects.Entity.typeId.Treasure) { gSkinB.label.fontSize = 14; GUI.Label(new Rect((Screen.width * .5f) - 204, (Screen.height * .75f), 100, 50), "¡Has Encontrado el 3º Tesoro de Iguazú!"); } else { gSkinB.label.fontSize = 14; GUI.Label(new Rect((Screen.width * .5f) - 204, (Screen.height * .75f), 100, 50), "¡Has Encontrado un Item Especial!"); } GUI.color = Color.white; break; case FishState.Lose: //if (Time.frameCount % 2 == 0) GUI.color = Color.red; //else //GUI.color = Color.white; gSkinB.label.fontSize = 14; GUI.Label(new Rect((Screen.width * .5f) - 256, (Screen.height * .5f) + 256, 100, 50), "Profundidad: " + (Increment * .1f).ToString("F2") + " m"); Back.Render(); foreach (BonusObjects.Entity entity in Entoids) { if (entity.Position.center.y < Limits.yMax && entity.Position.center.y > Limits.yMin) { entity.Render(); } } Player.Render(); //GUI.color = Color.red; Bubbles.Render(); gSkinB.label.fontSize = 48; if (Time.frameCount % 2 == 0) { GUI.color = Color.red; } else { GUI.color = Color.white; } GUI.Label(new Rect((Screen.width * .5f) - 186, (Screen.height * .5f), 100, 50), "¡SONASTE!"); if (Increment > 130) { gSkinB.label.fontSize = 14; GUI.Label(new Rect((Screen.width * .5f) - 204, (Screen.height * .75f), 100, 50), "Caiste muy Profundo, Perdiste tu anzuelo"); } else { gSkinB.label.fontSize = 14; GUI.Label(new Rect((Screen.width * .5f) - 204, (Screen.height * .75f), 100, 50), "Las Palometas se morfaron tu carnada"); } GUI.color = Color.white; break; } }
public static void DrawTexture(float x, float y, float w, float h, Texture texture) { GUI.DrawTexture(new Rect(position_x(x), position_y(y), size_x(w), size_y(h)), texture); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent _) { if (membersToDraw == null) { return; } if (error != null) { EditorGUI.HelpBox(position, error, MessageType.Error); return; } // var debugText = string.Join(", ", membersToDraw.Select(m => m.Name)); var instance = property.serializedObject.targetObject; using (new EditorGUI.DisabledScope(true)) { for (var index = 0; index < membersToDraw.Count; index++) { var mem = membersToDraw[index]; var rect = new Rect(position.x, position.y + EditorGUIUtility.singleLineHeight * index, position.width, EditorGUIUtility.singleLineHeight); var prefix = mem.Name; prefix = ObjectNames.NicifyVariableName(prefix); GUI.Label(rect, new GUIContent(prefix)); rect = EditorGUI.PrefixLabel(rect, new GUIContent(prefix)); GUIContent?label = null; // first check cache if previous access did cause exception if (guiContentCache.Count > index) { if (guiContentCache[index].wasError) { // previous access did cause exception // so dont call GetValue again to avoid internal exception spam // this CAN happen e.g in edit time when reading a property getter // that expects a certain setup label = guiContentCache[index].label; } } if (label == null) { try { label = new GUIContent(GetValue(instance, mem)?.ToString() ?? "null"); // put in cache so we can lookup by index, every member should have one label in the cache at least if (index >= guiContentCache.Count) { guiContentCache.Add((label, false)); } } catch (Exception e) { // cache that exception the first time it happens if (index >= guiContentCache.Count) { var errorLabel = label = new GUIContent(e.GetType().Name, e.ToString()); guiContentCache.Add((errorLabel, true)); } else { label = guiContentCache[index].label; } } } GUI.Label(rect, label); } } }