示例#1
0
        public void RunExample(string name, ConstellationEditorDataService constellationEditorDataService)
        {
            SceneManager.CreateScene("Example");
            UnloadAllScenesExcept("Example");
            ClearConsole();
            GameObject light = new GameObject("Light");

            light.AddComponent <Light> ().type = LightType.Directional;

            GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);

            cube.transform.position = new Vector3(0, 0, 0);
            cube.gameObject.SetActive(false);
            var behaviour            = cube.AddComponent <ConstellationBehaviour> () as ConstellationBehaviour;
            var exampleConstellation = constellationEditorDataService.GetConstellationByName(name);

            if (exampleConstellation == null)
            {
                EditorUtility.DisplayDialog("Oops...",
                                            "The example you are trying to open does not exist... If you need more info on " + name + ", you can still double right click on either input or outputs.",
                                            "Go back");
                EditorApplication.isPlaying = false;
                return;
            }
            behaviour.SetConstellationScript(exampleConstellation);
            Selection.activeGameObject = cube;
            cube.gameObject.SetActive(true);

            GameObject camera = new GameObject("Camera");

            camera.transform.position = new Vector3(0, 0, -10);
            camera.tag = "MainCamera";
            camera.AddComponent <Camera> ();
        }
        public void RunExample(string name, ConstellationEditorDataService constellationEditorDataService)
        {
            var newScene = SceneManager.CreateScene("Example");

            UnloadAllScenesExcept("Example");
            GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);

            cube.transform.position = new Vector3(0, 0, 0);
            cube.gameObject.SetActive(false);
            var behaviour = cube.AddComponent <ConstellationBehaviour> () as ConstellationBehaviour;

            behaviour.ConstellationData = constellationEditorDataService.GetConstellationByName(name);
            Selection.activeGameObject  = cube;
            cube.gameObject.SetActive(true);

            GameObject camera = new GameObject("Camera");

            camera.transform.position = new Vector3(0, 0, -10);
            camera.AddComponent <Camera>();

            GameObject light = new GameObject("Light");

            light.AddComponent <Light>().type = LightType.Directional;
        }