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 NodeWindow(string _editorPath, ConstellationEditorDataService _constellationEditorData, Vector2 windowSize, Vector2 scrollPosition) { constellationRules = new ConstellationEditorRules(); farNodeX = windowSize.x; farNodeY = windowSize.y; editorScrollSize = new Vector2(farNodeX + 400, farNodeY + 400); ScrollPosition = scrollPosition; var backgroundTexture = AssetDatabase.LoadAssetAtPath(editorPath + "background.png", typeof(Texture2D)) as Texture2D; background = new NodeEditorBackground(backgroundTexture); editorPath = _editorPath; SelectedNodes = new List <NodeView>(); Nodes = new List <NodeView>(); EditorData = _constellationEditorData; ConstellationScript = EditorData.Script; Links = new LinksView(ConstellationScript, constellationRules); NodeFactory = new NodesFactory(ConstellationScript.ScriptAssembly.GetAllStaticScriptData()); foreach (var node in ConstellationScript.GetNodes()) { DisplayNode(node); } }