Example #1
0
    public static void CommandLineBuild()
    {
        EditorApplication.Beep();
        EditorApplication.Beep();
        EditorApplication.Beep();
        EditorApplication.Beep();
        EditorApplication.Beep();
        EditorApplication.Beep();
        EditorApplication.Beep();
        EditorApplication.Beep();
        EditorApplication.Beep();
        EditorApplication.Beep();
        EditorApplication.Beep();

        //make sure the recompiled scripts are reimported
        AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate | ImportAssetOptions.ImportRecursive);

        //make a new scene
        EditorApplication.NewScene();

        //set the scene up with the single game object we have
        SceneSelector.LoadHangoutScene();

        //save the scene out
        EditorApplication.SaveScene(Application.dataPath + "/AutogeneratedScene");

        //set the resolution of the web build
        Screen.SetResolution(760, 500, false);

        //pass scene
        BuildPipeline.BuildPlayer(null, Application.dataPath + "/hangout.unity3d", BuildTarget.WebPlayer, BuildOptions.CompressTextures);
    }
Example #2
0
    private static void LoadScene <T>() where T : AppEntry
    {
        EditorApplication.NewScene();
        GameObject entryObject = new GameObject("Entry Point");

        entryObject.AddComponent(typeof(T));
    }
Example #3
0
        private void RunTests(string[] tests)
        {
            if (!OkToRun())
            {
                return;
            }

            var currentScene = EditorApplication.currentScene;

            if (runTestOnANewScene || UnityEditorInternal.InternalEditorUtility.inBatchMode)
            {
                EditorApplication.NewScene();
            }

            StartTestRun(tests, new TestRunnerEventListener(UpdateTestInfo), !runTestOnANewScene);
            shouldUpdateTestList = true;

            if (runTestOnANewScene)
            {
                if (!string.IsNullOrEmpty(currentScene))
                {
                    EditorApplication.OpenScene(currentScene);
                }
                else
                {
                    EditorApplication.NewScene();
                }
            }

            if (Event.current != null)
            {
                GUIUtility.ExitGUI();
            }
        }
Example #4
0
        public override IEnumerator Run()
        {
            if (!force)
            {
                FileInfo fi = new FileInfo(kScene);
                if (fi.Exists)
                {
                    Debug.Log("Default scene exists. Skipping. ");
                    yield break;
                }
            }

            if (EditorApplication.isUpdating || EditorApplication.isCompiling)
            {
                Debug.Log("Wait");
                yield return(0);
            }

            EditorApplication.NewScene();


            ClearScene();

            GameObject go = new GameObject();

            go.name = kGameRoot;

            System.Type type = UGBSetupPostProcessor.GetGameInitializerType();
            go.AddComponent(type);

            EditorApplication.SaveScene(kScene);
        }
        public override IEnumerator Run()
        {
            if (!force)
            {
                FileInfo fi = new FileInfo(kScene);
                if (fi.Exists)
                {
                    Debug.Log("Default scene exists. Skipping. ");
                    yield break;
                }
            }

            if (EditorApplication.isUpdating)
            {
                Debug.Log("Wait");
                yield return(0);
            }
            EditorApplication.NewScene();

            ClearScene();

            GameObject go = new GameObject();

            go.name = kGameRoot;
            go.AddComponent <Game>();

            EditorApplication.SaveScene(kScene);
        }
Example #6
0
    private void CacheBundles()
    {
        Console.WriteLine("Caching bundles...");

        _bundlesCachePath = Path.Combine(_params.BundlesLocation, _bundlesDatabaseBuilder.Database.Id + "_cache");

        BuildUtils.PrepareCleanDirectory(_bundlesCachePath);

        // Note: All this flow break is required because WWW.LoadFromCacheOrDownload() is allowed only in play mode
        EditorUtility.SetDirty(this);

        EditorApplication.NewScene();
        var go             = new GameObject("AssetsBundleDatabaseCacher", typeof(AssetBundlesDatabaseCacher));
        var databaseCacher = go.GetComponent <AssetBundlesDatabaseCacher>();

        databaseCacher.Setup(_bundlesDatabaseBuilder.Database, Path.GetFullPath(_bundlesPath));

        // Application will only actually enter playmode after the call stack returns to the editor
        Application.runInBackground = true;
        EditorApplication.isPaused  = false;
        EditorApplication.isPlaying = true;

        EditorPrefs.SetBool("Builder.ContinuePending", true);
        _continueRequired = true;         // Prevents FinishAll() on Dispose
        throw new ContinueRequiredException();
    }
Example #7
0
        public static void Build(Action callback = null)
        {
            if (!EditorApplication.SaveCurrentSceneIfUserWantsTo())
            {
                return;
            }

            var currentScene = EditorApplication.currentScene;

            var data = new Data();

            Generate.Build(AssetDatabase.GetAllAssetPaths(), assetData =>
            {
                data.assetData.AddRange(assetData);
                EditorUtility.UnloadUnusedAssets();

                if (string.IsNullOrEmpty(currentScene))
                {
                    EditorApplication.NewScene();
                }
                else
                {
                    EditorApplication.OpenScene(currentScene);
                }

                Export(data);
                if (callback != null)
                {
                    callback();
                }
            });
        }
        private void LoadPreviousScene(string currentScene)
        {
#if UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2
            if (!string.IsNullOrEmpty(currentScene))
            {
                EditorApplication.OpenScene(currentScene);
            }
            else
            {
                EditorApplication.NewScene();
            }
#else
            if (!string.IsNullOrEmpty(currentScene))
            {
                UnityEditor.SceneManagement.EditorSceneManager.OpenScene(currentScene);
            }
            else
            {
                UnityEditor.SceneManagement.EditorSceneManager.NewScene(UnityEditor.SceneManagement.NewSceneSetup.DefaultGameObjects);
            }
#endif

            if (Event.current != null)
            {
                GUIUtility.ExitGUI();
            }
        }
        public static void UpdateFSMEvent()
        {
            if (!EditorUtility.DisplayDialog("FsmEvent Update", "If you choose \'Go Ahead\', BehaviourMachine will automatically upgrade all FsmEvents in your project (it includes all game objects in your scenes and prefabs). You should make a backup before proceeding.\n\nYou can always run the FsmEvent Updater manually through the preferences window.", "I Made a Backup. Go Ahead!", "No Thanks"))
            {
                return;
            }

            // save the current opened scene
            string originalScene = EditorApplication.currentScene;

            // Saves the current scene if user wants
            EditorApplication.SaveCurrentSceneIfUserWantsTo();

            UpdateAllBlackboards(AutoUpdate.FsmEvent2ConcreteFsmEvent);

            // Opens the original scene
            if (!string.IsNullOrEmpty(originalScene))
            {
                EditorApplication.OpenScene(originalScene);
            }
            else
            {
                EditorApplication.NewScene();
            }
        }
Example #10
0
        private void InitCanvas()
        {
#if UNITY_5_2
            EditorApplication.NewScene();
#elif UNITY_5_3
            EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);
#endif
            Canvas temp = AssetDatabase.LoadAssetAtPath(PSDImporterConst.ASSET_PATH_CANVAS, typeof(Canvas)) as Canvas;
            PSDImportUtility.canvas            = GameObject.Instantiate(temp) as Canvas;
            PSDImportUtility.canvas.renderMode = RenderMode.ScreenSpaceOverlay;

            UnityEngine.UI.CanvasScaler scaler = PSDImportUtility.canvas.GetComponent <UnityEngine.UI.CanvasScaler>();
            scaler.screenMatchMode     = UnityEngine.UI.CanvasScaler.ScreenMatchMode.MatchWidthOrHeight;
            scaler.matchWidthOrHeight  = 1f;
            scaler.referenceResolution = new Vector2(psdUI.psdSize.width, psdUI.psdSize.height);

            // find
            var _eventSystem = Object.FindObjectOfType <EventSystem>();

            if (_eventSystem != null)
            {
                PSDImportUtility.eventSys = _eventSystem.gameObject;
            }
            else
            {
                GameObject go = AssetDatabase.LoadAssetAtPath(PSDImporterConst.ASSET_PATH_EVENTSYSTEM, typeof(GameObject)) as GameObject;

                PSDImportUtility.eventSys = GameObject.Instantiate(go) as GameObject;
            }
        }
Example #11
0
        private void InitCanvas()
        {
#if UNITY_5_2
            EditorApplication.NewScene();
#elif UNITY_5_3
            EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);
#endif
            var    root = GameObject.Find("UIRoot");
            Canvas temp = AssetDatabase.LoadAssetAtPath(PSDImporterConst.ASSET_PATH_CANVAS, typeof(Canvas)) as Canvas;
            PSDImportUtility.canvas      = GameObject.Instantiate(temp) as Canvas;
            PSDImportUtility.canvas.name = _systemName;
            var rt = PSDImportUtility.canvas.GetComponent <RectTransform>();
            rt.anchorMax = Vector2.one;
            rt.anchorMin = Vector2.zero;
            rt.offsetMax = Vector2.zero;
            rt.offsetMin = Vector2.zero;
            rt.pivot     = new Vector2(0.5f, 0.5f);
            if (root != null)
            {
                rt.SetParent(root.transform, false);
            }
            else
            {
                Debug.LogError("čÆ·åœØ:Assets/Mainåœŗę™Æäø­åƼ兄PSD");
            }
            PSDImportUtility.canvas.renderMode = RenderMode.ScreenSpaceOverlay;

            //UnityEngine.UI.CanvasScaler scaler = PSDImportUtility.canvas.GetComponent<UnityEngine.UI.CanvasScaler>();
            //scaler.screenMatchMode = UnityEngine.UI.CanvasScaler.ScreenMatchMode.MatchWidthOrHeight;
            //scaler.matchWidthOrHeight = 1f;
            //scaler.referenceResolution = new Vector2(psdUI.psdSize.width, psdUI.psdSize.height);

            //GameObject go = AssetDatabase.LoadAssetAtPath(PSDImporterConst.ASSET_PATH_EVENTSYSTEM, typeof(GameObject)) as GameObject;
            //PSDImportUtility.eventSys = GameObject.Instantiate(go) as GameObject;
        }
Example #12
0
        private static void BackgroudRunner()
        {
            if (EditorApplication.isPlayingOrWillChangePlaymode)
            {
                EditorApplication.update -= BackgroudRunner;
                return;
            }
            if (EditorApplication.isCompiling)
            {
                if (!shouldRunOnRecompilation)
                {
                    return;
                }
                EditorPrefs.SetString(uttRecompile, Application.dataPath);
                EditorApplication.update -= BackgroudRunner;
                return;
            }
            var t = (int)Time.realtimeSinceStartup;

            if (t < nextCheck)
            {
                return;
            }
            nextCheck = t + 1;

            if (!shouldRunOnRecompilation)
            {
                return;
            }

            if (EditorPrefs.HasKey(uttRecompile))
            {
                var recompile = EditorPrefs.GetString(uttRecompile);
                if (recompile == Application.dataPath && OkToRun())
                {
                    var currentScene = EditorApplication.currentScene;

                    if (shouldRunTestOnANewScene || UnityEditorInternal.InternalEditorUtility.inBatchMode)
                    {
                        EditorApplication.NewScene();
                    }

                    StartTestRun(new string[0], new BackgroundTestRunnerEventListener(), !shouldRunTestOnANewScene);

                    if (shouldRunTestOnANewScene)
                    {
                        if (!string.IsNullOrEmpty(currentScene))
                        {
                            EditorApplication.OpenScene(currentScene);
                        }
                        else
                        {
                            EditorApplication.NewScene();
                        }
                    }
                }
                EditorPrefs.DeleteKey(uttRecompile);
            }
        }
Example #13
0
        private void CreateScene()
        {
            // Create a new scene
                        #if UNITY_5_3_OR_NEWER || UNITY_5_3 // Because UNITY_X_Y_OR_NEWER is defined starting Unity 5.3.4
            UnityEditor.SceneManagement.EditorSceneManager.NewScene(UnityEditor.SceneManagement.NewSceneSetup.EmptyScene);
                        #else
            EditorApplication.NewScene();
                        #endif

            GameObject light = new GameObject("Light");

            light.AddComponent <Light>();

            light.transform.Translate(0.0f, 2.0f, 0.0f);

            const float width  = 10.0f;
            const float height = 4.0f;
            const int   steps  = 50;          // Min: 3

            float scale    = (float)((double)width * System.Math.Sin(System.Math.PI / (double)steps));
            float distance = (float)(0.5 * (double)width * System.Math.Cos(System.Math.PI / (double)steps));

            Material darker = new Material(Shader.Find("Diffuse"));
            darker.SetColor("_Color", new Color32(128, 128, 128, 255));

            Material lighter = new Material(Shader.Find("Diffuse"));
            lighter.SetColor("_Color", new Color32(255, 255, 255, 255));

            GameObject floor = GameObject.CreatePrimitive(PrimitiveType.Quad);
            floor.name = "Floor";
            floor.GetComponent <MeshRenderer>().sharedMaterial = darker;
            floor.transform.Rotate(90.0f, 0.0f, 0.0f);
            floor.transform.localScale = new Vector3(width, width, 1.0f);

            GameObject ceiling = GameObject.CreatePrimitive(PrimitiveType.Quad);
            ceiling.name = "Ceiling";
            ceiling.GetComponent <MeshRenderer>().sharedMaterial = lighter;
            ceiling.transform.Translate(0.0f, height, 0.0f);
            ceiling.transform.Rotate(-90.0f, 0.0f, 0.0f);
            ceiling.transform.localScale = new Vector3(width, width, 1.0f);

            GameObject walls = new GameObject();
            walls.name = "Walls";

            for (int i = 0; i < steps; i++)
            {
                GameObject wall = GameObject.CreatePrimitive(PrimitiveType.Quad);
                wall.name = "Wall_" + (i + 1);
                wall.GetComponent <MeshRenderer>().sharedMaterial = darker;

                wall.transform.Rotate(0.0f, (float)i * 360.0f / (float)steps, 0.0f);
                wall.transform.Translate(0.0f, height / 2.0f, distance);
                wall.transform.localScale = new Vector3(scale, height, 1.0f);

                wall.transform.parent = walls.transform;
            }

            viewPoint = light.transform;
        }
Example #14
0
    public static void CreateNewScene()
    {
#if UNITY_5_0_TO_5_2
        EditorApplication.NewScene();
#else
        m_currentScene = UnityEditor.SceneManagement.EditorSceneManager.NewScene(UnityEditor.SceneManagement.NewSceneSetup.DefaultGameObjects);
#endif
    }
Example #15
0
 public static void NewScene()
 {
                 #if UNITY_5_3 || UNITY_5_4
     EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);
                 #else
     EditorApplication.NewScene();
                 #endif
 }
Example #16
0
        public static void NewScene(bool empty = false)
        {
#if UNITY_5_3_PLUS
            EditorSceneManager.NewScene(empty ? NewSceneSetup.EmptyScene : NewSceneSetup.DefaultGameObjects);
#else
            EditorApplication.NewScene();
#endif
        }
Example #17
0
    private bool Check(bool needSuccessNotify = true)
    {
        OnDestroy();

        bool isSuccessful = true;

        string dir = EditorUtility.OpenFolderPanel("Choose need checked folder", EditorTools.GetPathForDisk("Resources"), string.Empty);

        {
            string[] dotUnityFiles = EditorTools.GetDotUnityFiles(dir);
            foreach (string file in dotUnityFiles)
            {
                string scenePath = EditorTools.GetPathForAsset(file);
                EditorApplication.OpenScene(scenePath);

                GameObject[] goArray = GameObject.FindObjectsOfType(typeof(GameObject)) as GameObject[];
                isSuccessful = Check_Impl(goArray, Path.GetFileName(scenePath) + ": ");
            }

            EditorApplication.NewScene();
            {
                List <GameObject> goList = new List <GameObject>();

                string[] prefabFiles = EditorTools.GetPrefabFiles(dir);
                foreach (string file in prefabFiles)
                {
                    string prefabPath = EditorTools.GetPathForAsset(file);

                    GameObject go = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject)) as GameObject;
                    if (go != null)
                    {
                        Transform[] transArray = go.GetComponentsInChildren <Transform>(true);
                        foreach (Transform trans in transArray)
                        {
                            goList.Add(trans.gameObject);
                        }
                    }
                }

                isSuccessful = Check_Impl(goList.ToArray(), "Prefab: ");
            }

            Resources.UnloadUnusedAssets();
        }

        if (isSuccessful && needSuccessNotify)
        {
            EditorUtility.DisplayDialog("Missing script check Success!", "Great!", "ok");
            return(true);
        }
        else if (!isSuccessful)
        {
            EditorUtility.DisplayDialog("Missing script check Failed!", "You need to Fix below as shown!", "ok");
            return(true);
        }

        return(false);
    }
Example #18
0
    /// <summary>
    /// Crea un mapa dado su ancho, alto y nombre.
    /// </summary>
    public void CreateMap()
    {
        EditorApplication.NewScene();         // Crea una scene nueva.
        GameObject MapObj = new GameObject("Map");

        Camera.main.transform.parent        = MapObj.transform;
        Camera.main.orthographicSize        = 5;                                                                           // Ajusta el tamaƱo de la camara ( la cantidad de espacio que va enfocar)
        Camera.main.transform.localPosition = new Vector3((float)(Data.Width - 1) / 2, (float)(Data.Heigth - 1) / 2, -10); // Posiciona la camara en el centro del mapa
        Camera.main.backgroundColor         = Color.black;
        Camera.main.gameObject.AddComponent <MainCamera>();
        UnityEngine.Object prefab  = AssetDatabase.LoadAssetAtPath(@"Assets/Resources/Tile/DefaultTile1.prefab", typeof(GameObject)); // Carga el prefab que esta por defecto para crear el mapa
        UnityEngine.Object prefab2 = AssetDatabase.LoadAssetAtPath(@"Assets/Resources/Tile/DefaultTile2.prefab", typeof(GameObject)); // Carga el prefab que esta por defecto para crear el mapa
        for (int i = 0; i < Data.Width; i++)
        {
            for (int j = 0; j < Data.Heigth; j++)
            {
                Vector2    position = new Vector2(i, j);
                GameObject clone    = new GameObject();

                if ((i + j) % 2 == 0)
                {
                    clone = EditorWindow.Instantiate(prefab, position, Quaternion.identity) as GameObject;                     // Agrega un objeto nuevo a la scene.
                }
                else
                {
                    clone = EditorWindow.Instantiate(prefab2, new Vector3(i, j, 0f), Quaternion.identity) as GameObject;
                }
                clone.tag = "RPG-CORE";
                clone.transform.parent = MapObj.transform;
                EditorWindow.DestroyImmediate(GameObject.Find("New Game Object"));
            }
        }
        GameObject settings = new GameObject("Settings");

        settings.AddComponent <Map>();

        if (this.Data.Background != null)
        {
            Audio audio = new Audio("BackgroundAudio");
            audio.CreateAudioSource(this.Data.Background);
            audio.gameobject.transform.parent = MapObj.transform;
        }

        Map x = settings.GetComponent <Map>();

        x.Name        = x.Data.Name = this.Data.Name;
        x.Data.Width  = this.Data.Width;
        x.Data.Heigth = this.Data.Heigth;
        x.Icon        = AssetDatabase.LoadAssetAtPath <Sprite>("Assets/TurnBaseRPG-Creator/RPG-Sprites/MapIcon.png");
        x.Id          = Guid.NewGuid().ToString();
        string returnPath = "Assets/Resources/Maps/" + x.Id + ".unity";

        x.Data.MapPath = returnPath;
        PrefabUtility.CreatePrefab("Assets/Resources/Maps/" + x.Id + ".prefab", x.gameObject);
        DestroyImmediate(settings);
        EditorApplication.SaveScene(returnPath);// Guarda la scene.
        Constant.AddSceneToBuild(returnPath);
    }
Example #19
0
    private static void ClearAtlasRef()
    {
        EditorApplication.NewScene();

        var atlasRef = Resources.Load("Atlas/AtlasRef", typeof(UIAtlas)) as UIAtlas;

        atlasRef.replacement    = null;
        atlasRef.spriteMaterial = null;
    }
Example #20
0
        public void searchPrefab(string prefabLocation)
        {
            string assetPath = prefabLocation.Replace(Application.dataPath, "").Replace('\\', '/');

            if (!prefabLocation.StartsWith("Assets"))
            {
                assetPath = "Assets/" + assetPath;
            }
            var prefab = (GameObject)AssetDatabase.LoadAssetAtPath(assetPath, typeof(GameObject));

            if (prefab == null)
            {
                Debug.LogError("could not load prefab at path: " + assetPath + " input:" + prefabLocation);
            }

            //getAllGameObjectsInPrefab()

            var originalScene = EditorApplication.currentScene;

            //cheat with a scene in order to make sure to get disabled components.  Feels odd, but I hope I find something better later
            EditorApplication.NewScene();

            //delete the main camera and any other default objects
            var gameobjects = GameObject.FindObjectsOfType <GameObject>();

            foreach (var existingGo in gameobjects)
            {
                GameObject.DestroyImmediate(existingGo);
            }

            GameObject instanceOfPrefab = GameObject.Instantiate(prefab) as GameObject;

            var listOfGameobjectsInPrefab = getAllGameObjectsInScene();

            searchGameObjects(listOfGameobjectsInPrefab);

            //PrefabUtility.SetPropertyModifications(prefab,new PropertyModification[]{PropertyModification. });

            bool connected = PrefabUtility.ReconnectToLastPrefab(instanceOfPrefab);

            if (!connected)
            {
                //ReplacePrefabOptions.namebasedone
                PrefabUtility.ReplacePrefab(instanceOfPrefab, prefab, ReplacePrefabOptions.ConnectToPrefab);
            }
            else
            {
                EditorUtility.SetDirty(prefab);
            }

            AssetDatabase.SaveAssets();

            GameObject.DestroyImmediate(instanceOfPrefab);
            string scene = originalScene.Replace("Assets/", "");

            EditorApplication.OpenScene(scene);             //go back to the scene we started with
        }
Example #21
0
    public static GameObject NewScene(_TileType tileType)
    {
        EditorApplication.NewScene();

        GameObject rootObj = new GameObject();

        rootObj.name = "TBTK";
        Transform rootT = rootObj.transform;

        GameObject obj = new GameObject(); obj.transform.parent = rootT;

        obj.name = "Units";

        obj      = new GameObject(); obj.transform.parent = rootT;
        obj.name = "GameControl";
        //obj.AddComponent<GameControlTB>();
        GameControlTB gameControl = obj.AddComponent <GameControlTB>();

        gameControl.playerFactionID.Add(0);

        obj      = new GameObject(); obj.transform.parent = rootT;
        obj.name = "GridManager";
        GridManager gridManager = obj.AddComponent <GridManager>();

        gridManager.playerPlacementAreas.Add(new Rect());

        GameObject hexTile = Resources.Load("ScenePrefab/HexTile", typeof(GameObject)) as GameObject;

        gridManager.hexTilePrefab = hexTile;
        GameObject SquareTile = Resources.Load("ScenePrefab/SquareTile", typeof(GameObject)) as GameObject;

        gridManager.squareTilePrefab = SquareTile;
        GenerateHexGrid(gridManager, tileType);

        obj      = new GameObject(); obj.transform.parent = rootT;
        obj.name = "AudioManager";
        obj.AddComponent <AudioManager>();
        //AudioManager HexGridManager=obj.AddComponent<AudioManager>();

        obj      = new GameObject(); obj.transform.parent = rootT;
        obj.name = "PerkManager";
        obj.AddComponent <PerkManagerTB>();
        //PerkManagerTB perkManager=obj.AddComponent<PerkManagerTB>();

        DestroyImmediate(Camera.main.gameObject);
        GameObject cam = Resources.Load("ScenePrefab/CameraControl", typeof(GameObject)) as GameObject;

        obj      = (GameObject)Instantiate(cam);       obj.transform.parent = rootT;
        obj.name = "CameraControl";
        //foreach(Transform child in obj.transform) child.localPosition=new Vector3(0, 20, -20);

        Camera.main.transform.position = new Vector3(0, 12, -12);
        Camera.main.transform.rotation = Quaternion.Euler(45, 0, 0);

        return(rootObj);
    }
Example #22
0
        private string OpenNewScene()
        {
            var currentScene = EditorApplication.currentScene;

            if (settings.runTestOnANewScene)
            {
                EditorApplication.NewScene();
            }
            return(currentScene);
        }
Example #23
0
    public static void RunIntegrationTests()
    {
        Debug.Log("RunIntegrationTests");
        EditorApplication.NewScene();
        var go = new GameObject("BatchTestRunner");

        go.AddComponent <BatchTestRunner> ();
        DontDestroyOnLoad(go);
        EditorApplication.isPlaying = true;
    }
Example #24
0
        public static void RunUnitTests()
        {
            var resultFilePath = GetParameterArgument(resultFilePathParam) ?? Directory.GetCurrentDirectory();

            if (Directory.Exists(resultFilePath))
            {
                resultFilePath = Path.Combine(resultFilePath, defaultResultFileName);
            }
            EditorApplication.NewScene();
            UnitTestView.StartTestRun(new string[0], new TestRunnerEventListener(resultFilePath), false);
        }
Example #25
0
        static void CreateEmptyScene()
        {
                        #if UNITY_5_3_OR_NEWER
            EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);
                        #else
            EditorApplication.NewScene();
                        #endif

            //EditorApplication.NewScene();
            GameObject camObj = Camera.main.gameObject;       DestroyImmediate(camObj);
        }
Example #26
0
        static void UpdateAllBlackboards(BlackboardEditDelegate blackboardDelegate)
        {
            // Update GameObjects in all scenes
            List <string> sceneNames = FileUtility.SearchFiles(Application.dataPath, "*.unity");

            foreach (string sceneName in sceneNames)
            {
                // Open scene
                EditorApplication.OpenScene(sceneName);

                // Get all GameObjects in the scene
                var objects       = GameObject.FindObjectsOfType(typeof(GameObject)).Where(g => !AssetDatabase.Contains(g.GetInstanceID())).ToArray();
                int objectsLength = objects.Length;

                for (int i = 0; i < objectsLength; i++)
                {
                    var gameObject = objects[i] as GameObject;
                    EditorUtility.DisplayProgressBar("Updating Scene:" + sceneName, gameObject.name, (float)(i + 1) / objectsLength);

                    // Try to get a blackboard on the gameObject
                    var blackboard = gameObject.GetComponent <InternalBlackboard>();
                    if (blackboard != null)
                    {
                        blackboardDelegate(blackboard, false);
                    }
                }

                EditorApplication.SaveScene();
            }

            // Update Prefabs
            List <string> prefabNames    = FileUtility.SearchFiles(Application.dataPath, "*.prefab");
            int           dataPathLength = Application.dataPath.Length - 6; // 6 == "Assets".Length

            EditorApplication.NewScene();
            for (int i = 0; i < prefabNames.Count; i++)
            {
                // Get the prefab
                var prefab         = AssetDatabase.LoadAssetAtPath(prefabNames[i].Remove(0, dataPathLength), typeof(GameObject)) as GameObject;
                var prefabInstance = PrefabUtility.InstantiatePrefab(prefab) as GameObject;

                EditorUtility.DisplayProgressBar("Updating Prefab", prefab.name, (float)(i + 1) / prefabNames.Count);

                // Try to get a Blackboard in children
                foreach (InternalBlackboard blackboard in prefabInstance.GetComponentsInChildren <InternalBlackboard>(true))
                {
                    blackboardDelegate(blackboard, true);
                }

                PrefabUtility.ReplacePrefab(prefabInstance, prefab);
            }

            EditorUtility.ClearProgressBar();
        }
Example #27
0
    static void Combine()
    {
        Object[] objects = Selection.objects;

        EditorApplication.SaveCurrentSceneIfUserWantsTo();
        EditorApplication.NewScene();

        foreach (Object item in objects)
        {
            EditorApplication.OpenSceneAdditive(AssetDatabase.GetAssetPath(item));
        }
    }
Example #28
0
    public static void EndScene()
    {
        EditorApplication.SaveCurrentSceneIfUserWantsTo();
        EditorApplication.NewScene();
        GameObject stmain = (GameObject)GameObject.Instantiate(
            Resources.LoadAssetAtPath("Assets/Spider-Toolkit/st Main/st Main.prefab", typeof(GameObject)));

        stmain.name                 = "st Main";
        stmain.transform.parent     = Camera.main.transform;
        Camera.main.backgroundColor = Color.black;
        Camera.main.orthographic    = true;
    }
Example #29
0
 private static void FinishSearch()
 {
     if (String.IsNullOrEmpty(searchStartScene))
     {
         EditorApplication.NewScene();
     }
     else if (EditorApplication.currentScene != searchStartScene)
     {
         EditorApplication.OpenScene(searchStartScene);
     }
     EditorUtility.ClearProgressBar();
 }
Example #30
0
    public void CreateDefaultProject()
    {
        if (!_isSceneOpen)
        {
            EditorApplication.NewScene();

            // TODO: Add stuff to default scene

            EditorApplication.SaveScene("Tutorial", false);

            _isSceneOpen = true;
        }
    }