public void AddBranch(ScenimaticSerializedNode newBranch) { EventBranchObjectData node = new EventBranchObjectData(newBranch, this); branchEntityDatas.Add(node); script.branches.Add(newBranch); }
public EventBranchObjectData(ScenimaticSerializedNode branchData, INodeGraph graph) : base(graph) { this.serializedNode = branchData; GUID = branchData.GUID; inputConnections = branchData.data.connectionInputs; outputConnections = branchData.data.connectionOutputs; nodeStyle = ScenimaticScriptEditor.branchWindowStyle; windowRect = new Rect(branchData.position, nodeStyle.size); }
public void Initialize(ScenimaticScript newScript) { refreshConnections = new List <ConnectionPoint>(); connectionPoints = new Dictionary <string, ConnectionPoint>(); script = newScript; CreateBranchEditorWindow(); zoomerSettings = new ZoomerSettings(); zoomerSettings.zoomOrigin = script.zoomOrigin; zoomerSettings.zoomScale = script.zoomScale > ZoomWindow.MIN_ZOOM ? script.zoomScale : 1; if (!string.IsNullOrEmpty(script.spriteAtlas)) { string[] matches = AssetDatabase.FindAssets(script.spriteAtlas); foreach (var match in matches) { string path = AssetDatabase.GUIDToAssetPath(match); if (Path.GetExtension(path) != ".spriteatlas") { Debug.Log(path + " not a spriteatlas"); } else { spriteAtlas = AssetDatabase.LoadAssetAtPath <SpriteAtlas>(path); break; } } } ConnectionPoint.nodeGraph = this; inputNode = new ScriptGatewayNodeData(this, newScript.inputNode); outputNode = new ScriptGatewayNodeData(this, newScript.outputNode); branchEntityDatas = new List <GraphEntityData>(); for (int i = 0; i < script.branches.Count; ++i) { ScenimaticSerializedNode branchData = script.branches[i]; EventBranchObjectData node = new EventBranchObjectData(branchData, this); branchEntityDatas.Add(node); } if (script.lastSelectedNode < 0 || script.lastSelectedNode >= branchEntityDatas.Count) { SelectEntity(inputNode); } else { SelectEntity(branchEntityDatas[script.lastSelectedNode]); } }
public ScenimaticScript(string sceneName, ScenimaticSerializedNode firstBranch) { this.sceneName = sceneName; inputNode = new GatewaySerializedNode() { GUID = System.Guid.NewGuid().ToString(), position = Vector2.zero, data = new Gateway() { gatewayType = GatewayType.Entrance, connections = new List <Connection>() { new Connection() { GUID = System.Guid.NewGuid().ToString(), type = ConnectionType.ControlFlow, variableName = Connection.ControlFlowOutName, } }, }, }; outputNode = new GatewaySerializedNode() { GUID = System.Guid.NewGuid().ToString(), position = new Vector2(800, 0), data = new Gateway() { gatewayType = GatewayType.Exit, connections = new List <Connection>() { new Connection() { GUID = System.Guid.NewGuid().ToString(), type = ConnectionType.ControlFlow, variableName = Connection.ControlFlowInName, } }, }, }; branches = new List <ScenimaticSerializedNode>(); branches.Add(firstBranch); inputNode.data.connections[0].connectedToGUIDs.Add(firstBranch.data.GetMainControlFlowInputGUID()); firstBranch.data.connectionInputs[0].connectedToGUIDs.Add(inputNode.data.connections[0].GUID); firstBranch.data.connectionOutputs[0].connectedToGUIDs.Add(outputNode.data.connections[0].GUID); outputNode.data.connections[0].connectedToGUIDs.Add(firstBranch.data.GetMainControlFlowOutputGUID()); }
public void DeleteEntity(GraphEntityData entityData) { // warn if branch has connections ScenimaticSerializedNode serializedEntity = null; foreach (var branch in script.branches) { if (branch.GUID == entityData.GUID) { serializedEntity = branch; break; } } if (serializedEntity == null) { Debug.LogError("Entity Deletion Error: Entity " + entityData.GUID + " could not be found in script"); return; } bool confirmed = false; foreach (var conn in serializedEntity.data.connectionInputs) { // check if anything still connected so we can warn the user if (IsConnected(conn)) { // show warning if (!confirmed && !EditorUtility.DisplayDialog("Delete this Branch?", "This branch has connections to other branches." + " If you continue, connections will be lost." + "\nAre you sure?", "Yes", "No")) { return; } confirmed = true; Disconnect(conn); } } foreach (var conn in serializedEntity.data.connectionOutputs) { // check if anything still connected so we can warn the user if (IsConnected(conn)) { // show warning if (!confirmed && !EditorUtility.DisplayDialog("Delete this Branch?", "This branch has connections to other branches." + " If you continue, connections will be lost." + "\nAre you sure?", "Yes", "No")) { return; } confirmed = true; Disconnect(conn); } } // check if this is the selected branch and switch branched if it is if (IsEntitySelected() && selectedEntity != entityData) { selectedEntity.GetWindow().Deselect(); } // delete branchEntityDatas.Remove(entityData); script.branches.Remove(serializedEntity); }