Пример #1
0
 static void PrepareToCapture()
 {
     RecorderInternalOptions.StartRecordingOnEnterPlayMode = true;
     EditorApplication.EnterPlaymode();
     // ここでシーンに配置した VideoRecorderBridge が StartCapturing を叩く。
     // なぜならプレイモードに入るタイミングで、おそらくドメインがリロードされて実行が停止してしまうからだ。
 }
        public static void StartRuntimeRenderTextureBackground()
        {
            if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
            {
                return;
            }

            EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);

            var go  = new GameObject("UI");
            var doc = go.AddComponent <UIDocument>();

            go.AddComponent <EventSystem>();
            var component = go.AddComponent <RenderTextureBackgroundDemo>();

            doc.panelSettings   = component.panelSettings;
            doc.visualTreeAsset = component.visualTreeAsset;

            go = new GameObject("Shapes");

            RenderTexture capsuleRt = component.capsuleRt;

            component.cubeRt     = AddCameraSetup(go, PrimitiveType.Cube, null, "Cube", 0);
            component.cylinderRt = AddCameraSetup(go, PrimitiveType.Cylinder, null, "Cylinder", 10);
            component.capsuleRt  = AddCameraSetup(go, PrimitiveType.Capsule, capsuleRt, "Capsule", 20);

            // let's send it far away for now
            go.transform.localPosition = new Vector3(100, 100, 100);

            EditorApplication.EnterPlaymode();
            EditorGUIUtility.PingObject(MonoScript.FromMonoBehaviour(component));
        }
Пример #3
0
        public static void StartRuntimeRenderTexture()
        {
            if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
            {
                return;
            }

            EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);

            var go         = new GameObject("UITextureProjection");
            var projection = go.AddComponent <UITextureProjection>();

            var material = CreateDefaultMaterial(projection.TargetPanel.targetTexture);

            go = new GameObject("Whack-A-Button");
            var component = go.AddComponent <ClickEventSample>();

            component.SetPanelSettings(projection.TargetPanel);

            var cube = CreatePrimitive(PrimitiveType.Cube, material, 0.8f);

            //Let's show the other side of the cube
            cube.transform.localEulerAngles = new Vector3(0, 180, 0);

            CreatePrimitive(PrimitiveType.Cylinder, material, -0.8f);

            EditorApplication.EnterPlaymode();
            EditorGUIUtility.PingObject(MonoScript.FromMonoBehaviour(component));
        }
Пример #4
0
        public void StartVideo(bool record = false, int ForceClipIndex = -1)
        {
            var mainCamera = GameObject.FindObjectOfType <Camera>();

            if (mainCamera == null)
            {
                Debug.LogError("Please add a Camera in the scene!");
                return;
            }
            if (this.currentSelectedProject == null)
            {
                Debug.LogError("Please Select a Project first!");
                return;
            }
            var player = mainCamera.GetComponent <ATVideoClipPlayer>();

            if (player == null)
            {
                player = mainCamera.gameObject.AddComponent <ATVideoClipPlayer>();
            }

            player.ForcedClipIndex = ForceClipIndex;
            player.mProject        = this.currentSelectedProject;
            player.RecordVideo     = record;

            EditorApplication.EnterPlaymode();
        }
Пример #5
0
 static void PlayFromMasterScene()
 {
     if (EditorSceneManager.GetSceneByName("MasterScene").IsValid() == false)
     {
         AddMasterScene();
     }
     EditorApplication.EnterPlaymode();
 }
Пример #6
0
 private static void PlayScene()
 {
     // Play the editor
     if (!EditorApplication.isPlaying)
     {
         EditorApplication.EnterPlaymode();
     }
 }
Пример #7
0
    async static void PlayAsync()
    {
        Debug.Log("Waiting 1 second...");
        await Task.Delay(1000);

        EditorApplication.EnterPlaymode();
        Debug.Log("After 1 second...");
    }
Пример #8
0
        protected void Play()
        {
#if UNITY_EDITOR && UNITY_2019
            EditorApplication.EnterPlaymode();
#elif UNITY_EDITOR
            Debug.Log("Looks like entering play mode by script is not allowed in your unity version.");
#endif
        }
Пример #9
0
    private static void OnSceneOpened(Scene scene, OpenSceneMode mode)
    {
        if (!shouldPlay)
        {
            return;
        }
        shouldPlay = false;

        EditorApplication.EnterPlaymode();
    }
Пример #10
0
        private static void PlayStop()
        {
            if (EditorApplication.isPlaying)
            {
                EditorApplication.isPlaying = false;
                return;
            }

            EditorApplication.EnterPlaymode();
        }
Пример #11
0
        static void InitializeTextAssetsScene()
        {
            TextDelegates.OnTextSettingsImported -= InitializeTextAssetsScene;
            EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);
            var go        = new GameObject("Sample Object");
            var component = go.AddComponent <TextAssets>();

            EditorApplication.EnterPlaymode();
            EditorGUIUtility.PingObject(MonoScript.FromMonoBehaviour(component));
        }
Пример #12
0
 private void OnGUI()
 {
     using (new EditorGUILayout.HorizontalScope())
     {
         if (GUILayout.Button("Refresh and Play"))
         {
             AssetDatabase.Refresh(ImportAssetOptions.Default);
             EditorApplication.EnterPlaymode();
         }
     }
 }
Пример #13
0
 void OnPlayButtonValueChanged(ChangeEvent <bool> evt)
 {
     if (evt.newValue)
     {
         EditorApplication.EnterPlaymode();
     }
     else
     {
         EditorApplication.ExitPlaymode();
     }
 }
Пример #14
0
    void OnGUI()
    {
        if (GUILayout.Button("Stop"))
        {
            EditorApplication.ExitPlaymode();
        }

        if (Server.PlayMode.bRun == true)
        {
            EditorApplication.EnterPlaymode();
        }
    }
Пример #15
0
 /// <summary>
 ///   Refresh this unity.
 ///   If any args are given, also start playmode
 /// </summary>
 static void Refresh(params string[] args)
 {
     if (EditorApplication.isPlaying)
     {
         EditorApplication.ExitPlaymode();
     }
     AssetDatabase.Refresh();
     if (args.Length > 0)
     {
         EditorApplication.EnterPlaymode();
     }
 }
Пример #16
0
    private void Update()
    {
#if (UNITY_EDITOR)
        if (EditorApplication.isPlayingOrWillChangePlaymode)
        {
            if (SceneManager.GetActiveScene() != SceneManager.GetSceneByName("LogScene"))
            {
                SceneManager.LoadScene("LogScene");
                EditorApplication.EnterPlaymode();
            }
        }
#endif
    }
Пример #17
0
    public static void testWindows()
    {
        runWindows();
        GameLauncherSettings gls = GameObject.FindObjectOfType <GameLauncherSettings>();

        if (gls)
        {
            if (gls.enterPlayMode)
            {
                EditorApplication.EnterPlaymode();
            }
        }
    }
Пример #18
0
        public static void StartRuntimeEventClickEvent()
        {
            if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
            {
                return;
            }

            EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);
            var go        = new GameObject("Whack-A-Button");
            var component = go.AddComponent <ClickEventSample>();

            EditorApplication.EnterPlaymode();
            EditorGUIUtility.PingObject(MonoScript.FromMonoBehaviour(component));
        }
Пример #19
0
            public static void PlayCurrentScene()
            {
                if (EditorApplication.isPlaying)
                {
                    EditorApplication.ExitPlaymode();
                }
                else
                {
                    EditorSceneManager.playModeStartScene =
                        AssetDatabase.LoadAssetAtPath <SceneAsset>(EditorSceneManager.GetActiveScene().path);

                    EditorApplication.EnterPlaymode();
                }
            }
Пример #20
0
 public static void PlayStartUpScene()
 {
     if (EditorApplication.isPlaying)
     {
         EditorApplication.ExitPlaymode();
     }
     else
     {
         string     scenePath          = "Assets/WhiteDream/Scenes/GameStart.unity";
         SceneAsset myWantedStartScene = AssetDatabase.LoadAssetAtPath <SceneAsset>(scenePath);
         EditorSceneManager.playModeStartScene = myWantedStartScene;
         EditorApplication.EnterPlaymode();
     }
 }
Пример #21
0
 public static void OpenNuitrackTestScene()
 {
     if (EditorApplication.isPlaying)
     {
         EditorApplication.ExitPlaymode();
     }
     else
     {
         if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
         {
             EditorSceneManager.OpenScene(Path.Combine("Assets", "NuitrackSDK", "NuitrackDemos", "AllModulesScene.unity"));
             EditorApplication.EnterPlaymode();
         }
     }
 }
Пример #22
0
        private static void PlayStop()
        {
            if (!ToolnitySettingsRegister.BasicShortcutsEnabled)
            {
                return;
            }

            if (EditorApplication.isPlaying)
            {
                EditorApplication.isPlaying = false;
                return;
            }

            EditorApplication.EnterPlaymode();
        }
Пример #23
0
    public void StartPlay()
    {
        EditorApplication.EnterPlaymode();
        FindObjectOfType <SubtitleTest>().song = song;

        /*
         * string fileLocation = "Assets/Prefabs/SubtitleControlerTest.prefab";
         * GameObject temp = new GameObject();
         *
         * var newObject = PrefabUtility.SaveAsPrefabAsset(temp, fileLocation);
         * subTest = PrefabUtility.InstantiatePrefab(newObject) as GameObject;
         *
         * DestroyImmediate(temp);
         *
         * subTest.GetComponent<SubtitleTest>().song = song;*/
    }
Пример #24
0
        private void OnGUI()
        {
            var guids       = AssetDatabase.FindAssets("t:scene").ToList();
            var ignoreGuids = AssetDatabase.FindAssets("t:scene l:Ignore").ToList();

            guids.RemoveAll(g => ignoreGuids.Contains(g));

            scroll = EditorGUILayout.BeginScrollView(scroll);

            foreach (var sceneGuid in guids)
            {
                // TODO: could search using a tag to avoid scenes
                var scenePath = AssetDatabase.GUIDToAssetPath(sceneGuid);
                var name      = Path.GetFileName(scenePath);

                EditorGUILayout.BeginVertical();
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(name);

                if (GUILayout.Button("Open"))
                {
                    EditorSceneManager.OpenScene(scenePath, OpenSceneMode.Single);
                }

                if (GUILayout.Button("Add"))
                {
                    EditorSceneManager.OpenScene(scenePath, OpenSceneMode.Additive);
                }

                if (GUILayout.Button("Play"))
                {
                    var playFromSceneObject = new GameObject("~PlayFromSceneData");
                    var playFromSceneData   = playFromSceneObject.AddComponent <PlayFromSceneData>();
                    playFromSceneData.scenePath = scenePath;
                    EditorApplication.EnterPlaymode();
                }

                EditorGUILayout.EndHorizontal();
                EditorGUILayout.EndVertical();
            }

            EditorGUILayout.EndScrollView();
        }
Пример #25
0
    private void OpenAndPlayScene(string sceneName)
    {
        if (EditorApplication.isPlaying)
        {
            // If already playing a scene then switch scenes
            EditorSceneManager.LoadScene(sceneName);
        }
        else
        {
            // If not already playing then open first then play
            EditorSceneManager.OpenScene(sceneName);

            // Play
#if UNITY_2019_1_OR_NEWER
            EditorApplication.EnterPlaymode();
#else
            EditorApplication.ExecuteMenuItem("Edit/Play");
#endif
        }
    }
Пример #26
0
        public static void RunSketch(Type sketchType)
        {
            EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo();
            var currentScene = SceneManager.GetActiveScene();

            EditorPrefs.SetString(SCENE_BEFORE_SKETCH_KEY, currentScene.path);

            var sketchScene = EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);

            sketchScene.name = "Sketch";
            SceneManager.SetActiveScene(sketchScene);

            EditorApplication.EnterPlaymode();
            EditorPrefs.SetBool(RUNNING_SKETCH_KEY, true);

            var sketchGo = new GameObject(sketchType.Name);

            sketchGo.AddComponent <SketchServiceInstaller>();
            sketchGo.AddComponent(sketchType);
        }
Пример #27
0
    static void ShowMenu(GameObject obj, Vector3 hitPoint, Vector3 hitNormal)
    {
        var menu = new GenericMenu();

        if (obj)
        {
            menu.AddDisabledItem(new GUIContent(obj.name));
        }
        menu.AddDisabledItem(new GUIContent($"Position: {hitPoint}"));
        menu.AddDisabledItem(new GUIContent($"Normal: {hitNormal}"));
        menu.AddSeparator(string.Empty);

        AddCreationOptions(menu, hitPoint, hitNormal);

        menu.AddItem(new GUIContent("Play From Here"), false, () =>
        {
            if (!EditorApplication.isPlaying)
            {
                PlayStateNotifier.PlayFrom = hitPoint;
                EditorApplication.EnterPlaymode();
            }
            else
            {
                var gs = FSGameLoop.GetGameInstance(true);
                if (gs &&
                    Human.Local != null &&
                    gs.EntityManager.TryFindEntity(Human.Local.EntityId, out NetEntity pl) &&
                    pl is Human hu)
                {
                    hu.Origin       = hitPoint;
                    hu.Velocity     = Vector3.zero;
                    hu.BaseVelocity = Vector3.zero;
                }
            }
        });
        menu.AddSeparator(string.Empty);

        menu.AddItem(new GUIContent("Close"), false, () => { });
        menu.ShowAsContext();
    }
Пример #28
0
    static void Update()
    {
        if (Debugger.IsAttached)
        {
            if (EditorApplication.isPlaying)
            {
                if (!startedFromDebugger)
                {
                    checkedFile         = true;
                    startedFromDebugger = true;
                }
            }
            else if (!dontPlay)
            {
                Touch();
                EditorApplication.EnterPlaymode();
            }
        }
        else if (!Debugger.IsAttached && EditorApplication.isPlaying)
        {
            if (!checkedFile)
            {
                startedFromDebugger = Exists();
                checkedFile         = true;
                if (startedFromDebugger)
                {
                    Delete();
                }
            }

            if (startedFromDebugger)
            {
                startedFromDebugger = false;
                dontPlay            = false;
                EditorApplication.ExitPlaymode();
            }
        }
    }
Пример #29
0
    private void OnGUI()
    {
        GUILayout.Space(10);
        GUILayout.Label("Запуск Main сцены в обход Menu");

        GUILayout.Space(10);
        isGridCanvasTurnedOn = EditorGUILayout.Toggle("Координаты клеток", isGridCanvasTurnedOn);

        GUILayout.Space(10);
        isDebugTurned = EditorGUILayout.Toggle("Включен ли Debugger", isDebugTurned);

        GUILayout.Space(10);
        GUILayout.Label("Выбранные персонажи");
        for (int i = 0; i < characters.Length; i++)
        {
            characters[i] = (CharacterInitialData)EditorGUILayout.ObjectField(characters[i], typeof(CharacterInitialData), false);
        }

        GUILayout.Space(20);
        if (EditorApplication.isPlaying)
        {
            if (GUILayout.Button("Остановка PlayMode"))
            {
                EditorApplication.ExitPlaymode();
            }
        }
        else
        {
            if (GUILayout.Button("Запуск PlayMode"))
            {
                EditorSceneManager.OpenScene("Assets/Scenes/Main.unity");

                SetStartData();

                EditorApplication.EnterPlaymode();
            }
        }
    }
Пример #30
0
        void OnGUI()
        {
            if (!Application.isPlaying)
            {
                if (GUILayout.Button("Enter Play Mode"))
                {
                    EditorApplication.EnterPlaymode();
                }

                GUI.enabled = false;
            }

            _fileName = EditorGUILayout.TextField("File Name", _fileName);

            if (GUILayout.Button("Download Sources"))
            {
                DownloadSources().ConfigureAwait(false);
            }

            if (GUILayout.Button("Download US Top Headlines"))
            {
                DownloadUsTopHeadlines().ConfigureAwait(false);
            }

            if (GUILayout.Button("Download All Countries Top Headlines"))
            {
                DownloadAllCountriesTopHeadlines().ConfigureAwait(false);
            }

            GUI.enabled = true;

            if (GUILayout.Button("Open Folder"))
            {
                EditorUtility.RevealInFinder(NewsApiOfflineCopyWriter.ResourceFilePath);
            }
        }