Beispiel #1
0
 private void Update()
 {
     if (this.shouldExit)
     {
         this.DoExitGame();
     }
     else if (this.bridge != null)
     {
         if ((this.oldWidth != ((int)base.position.width)) || (this.oldHeight != ((int)base.position.height)))
         {
             int  num            = (int)Mathf.Clamp(base.position.width, base.minSize.x, 1280f);
             int  num2           = (int)Mathf.Clamp(base.position.height, base.minSize.y, 720f);
             bool fitsInsideRect = true;
             this.remoteViewRect         = GameViewSizes.GetConstrainedRect(new Rect(0f, 0f, (float)num, (float)num2), ScriptableSingleton <GameViewSizes> .instance.currentGroupType, ScriptableSingleton <NScreenManager> .instance.SelectedSizeIndex, out fitsInsideRect);
             this.remoteViewRect.y      += this.ToolBarHeight;
             this.remoteViewRect.height -= this.ToolBarHeight;
             this.bridge.SetResolution((int)this.remoteViewRect.width, (int)this.remoteViewRect.height);
             this.oldWidth  = (int)base.position.width;
             this.oldHeight = (int)base.position.height;
         }
         this.bridge.Update();
         base.Repaint();
     }
     if (this.shouldBuild)
     {
         this.shouldBuild = false;
         NScreenManager.Build();
     }
 }
Beispiel #2
0
 private void SelectionCallback(int indexClicked, object objectSelected)
 {
     if (indexClicked != ScriptableSingleton <NScreenManager> .instance.SelectedSizeIndex)
     {
         ScriptableSingleton <NScreenManager> .instance.SelectedSizeIndex = indexClicked;
         NScreenManager.RepaintAllGameViews();
     }
 }
Beispiel #3
0
        private void OnGUI()
        {
            GUI.color = Color.white;
            GUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[0]);
            EditorGUILayout.GameViewSizePopup(ScriptableSingleton <GameViewSizes> .instance.currentGroupType, ScriptableSingleton <NScreenManager> .instance.SelectedSizeIndex, this, EditorStyles.toolbarDropDown, new GUILayoutOption[]
            {
                GUILayout.Width(160f)
            });
            GUILayout.FlexibleSpace();
            GUI.enabled = !Application.isPlaying;
            bool buildOnPlay = ScriptableSingleton <NScreenManager> .instance.BuildOnPlay;

            ScriptableSingleton <NScreenManager> .instance.BuildOnPlay = GUILayout.Toggle(ScriptableSingleton <NScreenManager> .instance.BuildOnPlay, "Build on Play", EditorStyles.toolbarButton, new GUILayoutOption[0]);
            if (buildOnPlay != ScriptableSingleton <NScreenManager> .instance.BuildOnPlay)
            {
                NScreenManager.RepaintAllGameViews();
            }
            if (GUILayout.Button("Build Now", EditorStyles.toolbarButton, new GUILayoutOption[0]))
            {
                this.shouldBuild = true;
            }
            GUI.enabled = Application.isPlaying;
            GUILayout.EndHorizontal();
            if (!this.shouldExit && this.bridge != null)
            {
                Texture2D screenTexture = this.bridge.GetScreenTexture();
                if (screenTexture != null)
                {
                    GUI.DrawTexture(this.remoteViewRect, screenTexture);
                }
                if (this == EditorWindow.focusedWindow)
                {
                    this.bridge.SetInput((int)Event.current.mousePosition.x - (int)this.remoteViewRect.x, (int)base.position.height - (int)Event.current.mousePosition.y - (int)this.remoteViewRect.y + this.ToolBarHeight - (int)Mathf.Max(0f, base.position.height - 720f), Event.current.button, (int)((!Event.current.isKey) ? ((KeyCode)(-1)) : Event.current.keyCode), (int)Event.current.type);
                }
                else
                {
                    this.bridge.ResetInput();
                }
            }
            else
            {
                GUILayout.Label("Game Stopped", new GUILayoutOption[0]);
            }
        }