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> (); }
protected override void DrawStartGUI() { if (!hasTriedFinddingExample) { hasTriedFinddingExample = true; scriptDataService = new ConstellationEditorDataService(); scriptDataService.OpenConstellation(Application.dataPath + "/Constellation/Examples/Nodes/" + helpName + ".asset", false); Background = AssetDatabase.LoadAssetAtPath(editorPath + "background.png", typeof(Texture2D)) as Texture2D; Setup(); } else { if (Background != null) { for (var i = 0; i < 50; i++) { for (var j = 0; j < 25; j++) { Rect texRect = new Rect(i * Background.width, j * Background.height, Background.width, Background.height); GUI.DrawTexture(texRect, Background); } } } } }
public void OpenConstellationInstance(Constellation.Constellation constellation, string path) { scriptDataService = new ConstellationEditorDataService(); scriptDataService.OpenConstellationInstance(constellation, path); CurrentEditedInstancesName = scriptDataService.currentInstancePath.ToArray(); Setup(); }
public void Recover() { try { scriptDataService = new ConstellationEditorDataService(); ConstellationCompiler = new ConstellationCompiler(); scriptDataService.RefreshConstellationEditorDataList(); if (scriptDataService.OpenEditorData().LastOpenedConstellationPath == null) { return; } if (scriptDataService.OpenEditorData().LastOpenedConstellationPath.Count != 0) { var scriptData = scriptDataService.Recover(scriptDataService.OpenEditorData().LastOpenedConstellationPath[0]); if (scriptData != null) { Setup(); return; } } } catch (ConstellationError e) { ShowError(e, e); } catch (Exception e) { var formatedError = new UnknowError(this.GetType().Name); ShowError(formatedError, e); } }
public void Open(string _path = "") { scriptDataService = new ConstellationEditorDataService(); var script = scriptDataService.OpenConstellation(_path); if (script == null) { return; } Setup(); Repaint(); }
protected override void DrawStartGUI() { wantsMouseMove = true; if (!hasTriedFinddingExample) { hasTriedFinddingExample = true; scriptDataService = new ConstellationEditorDataService(); scriptDataService.OpenConstellation(Application.dataPath + "/Constellation/Examples/Nodes/" + helpName + ".asset", false); Background = AssetDatabase.LoadAssetAtPath(editorPath + "background.png", typeof(Texture2D)) as Texture2D; Setup(); } else { DrawBackgroundGrid(Screen.width, Screen.height); } }
protected override void Setup() { wantsMouseMove = true; canDrawUI = false; WindowInstance = this as ConstellationUnityWindow; SceneManager.sceneLoaded += OnSceneLoaded; EditorApplication.playModeStateChanged += OnPlayStateChanged; scriptDataService = new ConstellationEditorDataService(); ConstellationCompiler = new ConstellationCompiler(); scriptDataService.RefreshConstellationEditorDataList(); if (scriptDataService.OpenEditorData().LastOpenedConstellationPath == null) { return; } if (scriptDataService.OpenEditorData().LastOpenedConstellationPath.Count != 0) { var scriptData = scriptDataService.Recover(scriptDataService.OpenEditorData().LastOpenedConstellationPath[0]); } RequestCompilation(); if (scriptDataService != null) { nodeEditorPanel = new NodeEditorPanel(this, this, scriptDataService.GetCurrentScript(), this, scriptDataService.GetEditorData().clipBoard, scriptDataService.GetLastEditorScrollPositionX(), scriptDataService.GetLastEditorScrollPositionY(), // Saved editor position OnLinkAdded, OnLinkRemoved, OnNodeAdded, OnNodeRemoved, OnHelpRequested, // callBacks SaveConstellationInstance, scriptDataService.GetAllNestableScriptsInProject()); nodeTabPanel = new ConstellationsTabPanel(this); if (scriptDataService.GetCurrentScript() != null) { WindowInstance.titleContent.text = scriptDataService.GetCurrentScript().name; } else { WindowInstance.titleContent.text = "Constellation"; } scriptDataService.ClearActions(); } nodeSelector = new NodeSelectorPanel(OnNodeAddRequested, scriptDataService.GetAllCustomNodesNames()); }
public void Recover() { scriptDataService = new ConstellationEditorDataService(); ConstellationCompiler = new ConstellationCompiler(); if (scriptDataService.OpenEditorData().LastOpenedConstellationPath == null) { return; } if (scriptDataService.OpenEditorData().LastOpenedConstellationPath.Count != 0) { var scriptData = scriptDataService.Recover(scriptDataService.OpenEditorData().LastOpenedConstellationPath[0]); if (scriptData != null) { Setup(); return; } } }
public NodeWindow(string _editorPath, ConstellationEditorDataService _constellationEditorData, Vector2 windowSize, Vector2 scrollPosition) { 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); NodeFactory = new NodesFactory(ConstellationScript.ScriptAssembly.GetAllStaticScriptData()); foreach (var node in ConstellationScript.GetNodes()) { DisplayNode(node); } }
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; }
public void New() { scriptDataService = new ConstellationEditorDataService(); scriptDataService.New(); Setup(); }