diff --git a/Docs/Node Editor Documentation.odt b/Docs/Node Editor Documentation.odt deleted file mode 100644 index 072929d5..00000000 Binary files a/Docs/Node Editor Documentation.odt and /dev/null differ diff --git a/Docs/Node Editor Documentation.pdf b/Docs/Node Editor Documentation.pdf deleted file mode 100644 index 65d96152..00000000 Binary files a/Docs/Node Editor Documentation.pdf and /dev/null differ diff --git a/Node_Editor/Framework/Canvas Save Objects/NodeCanvas.cs b/Node_Editor/Framework/Canvas Save Objects/NodeCanvas.cs deleted file mode 100644 index 0219270e..00000000 --- a/Node_Editor/Framework/Canvas Save Objects/NodeCanvas.cs +++ /dev/null @@ -1,15 +0,0 @@ -using UnityEngine; -using System.Collections.Generic; -using NodeEditorFramework; - -namespace NodeEditorFramework -{ - public class NodeCanvas : ScriptableObject - { // Just contains the nodes and global canvas stuff; an associated NodeEditorState holds the actual state now - public List nodes = new List (); - - // current states in the state system - public Node currentNode; - public Transition currentTransition; - } -} \ No newline at end of file diff --git a/Node_Editor/Framework/Canvas Save Objects/NodeCanvas.cs.meta b/Node_Editor/Framework/Canvas Save Objects/NodeCanvas.cs.meta deleted file mode 100644 index 601c7ff7..00000000 --- a/Node_Editor/Framework/Canvas Save Objects/NodeCanvas.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 0e0c2324a9ab1224ebe3edad393e3544 -timeCreated: 1437395312 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Node_Editor/Framework/Canvas Save Objects/NodeEditorState.cs b/Node_Editor/Framework/Canvas Save Objects/NodeEditorState.cs deleted file mode 100644 index 34768e96..00000000 --- a/Node_Editor/Framework/Canvas Save Objects/NodeEditorState.cs +++ /dev/null @@ -1,48 +0,0 @@ -using UnityEngine; -using System; -using System.Collections.Generic; -using NodeEditorFramework; - -namespace NodeEditorFramework -{ - public class NodeEditorState : ScriptableObject - { // holds the state of a NodeCanvas inside a NodeEditor - public NodeCanvas canvas; - public NodeEditorState parentEditor; - - // Canvas options - public bool drawing = true; // whether to draw the canvas - - // Selection State - public Node selectedNode; // selected Node - [NonSerialized] - public Node focusedNode; // Node under mouse - - // Current Action - [NonSerialized] - public bool dragNode = false; - [NonSerialized] - public Node makeTransition; // make transition from node - [NonSerialized] - public NodeOutput connectOutput; // connection this output - - // Navigation State - public Vector2 panOffset = new Vector2 (); // pan offset - public float zoom = 1; // zoom; Ranges in 0.2er-steps from 0.6-2.0; applied 1/zoom; - - // Temporary Navigation State - [NonSerialized] - public bool navigate = false; // navigation ('N') - [NonSerialized] - public bool panWindow = false; // window panning - - // Temporary State - [NonSerialized] - public Rect canvasRect; // canvas Rect - public Vector2 zoomPos { get { return canvasRect.size/2; } } // zoom center in canvas space - [NonSerialized] - public Vector2 zoomPanAdjust; // calculated value to offset elements with when zooming - [NonSerialized] - public List ignoreInput = new List (); // Rects inside the canvas to ignore input in (nested canvases, fE) - } -} \ No newline at end of file diff --git a/Node_Editor/Framework/Canvas Save Objects/NodeEditorState.cs.meta b/Node_Editor/Framework/Canvas Save Objects/NodeEditorState.cs.meta deleted file mode 100644 index aa97cff6..00000000 --- a/Node_Editor/Framework/Canvas Save Objects/NodeEditorState.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: f6ab6487237ff124ea4c2aa5de9ce3fb -timeCreated: 1437395312 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Node_Editor/Framework/Canvas Save Objects/NodeInput.cs b/Node_Editor/Framework/Canvas Save Objects/NodeInput.cs deleted file mode 100644 index 2c534ab2..00000000 --- a/Node_Editor/Framework/Canvas Save Objects/NodeInput.cs +++ /dev/null @@ -1,165 +0,0 @@ -using UnityEngine; -using System.Collections.Generic; - -namespace NodeEditorFramework -{ - /// - /// NodeInput accepts one connection to a NodeOutput by default - /// - public class NodeInput : NodeKnob - { - // NodeKnob Members - protected override NodeSide defaultSide { get { return NodeSide.Left; } } - - // NodeInput Members - public NodeOutput connection; - public string type; - [System.NonSerialized] - internal TypeData typeData; - // Multiple connections -// public List connections; - - #region Contructors - - /// - /// Creates a new NodeInput in NodeBody of specified type - /// - public static NodeInput Create (Node nodeBody, string inputName, string inputType) - { - return Create (nodeBody, inputName, inputType, NodeSide.Left, 20); - } - - /// - /// Creates a new NodeInput in NodeBody of specified type at the specified NodeSide - /// - public static NodeInput Create (Node nodeBody, string inputName, string inputType, NodeSide nodeSide) - { - return Create (nodeBody, inputName, inputType, nodeSide, 20); - } - - /// - /// Creates a new NodeInput in NodeBody of specified type at the specified NodeSide and position - /// - public static NodeInput Create (Node nodeBody, string inputName, string inputType, NodeSide nodeSide, float sidePosition) - { - NodeInput input = CreateInstance (); - input.type = inputType; - input.InitBase (nodeBody, nodeSide, sidePosition, inputName); - nodeBody.Inputs.Add (input); - return input; - } - - #endregion - - #region Additional Serialization - - protected internal override void CopyScriptableObjects (System.Func replaceSerializableObject) - { - connection = replaceSerializableObject.Invoke (connection) as NodeOutput; - // Multiple connections -// for (int conCnt = 0; conCnt < connections.Count; conCnt++) -// connections[conCnt] = replaceSerializableObject.Invoke (connections[conCnt]) as NodeOutput; - } - - #endregion - - #region KnobType - - protected override void ReloadTexture () - { - CheckType (); - knobTexture = typeData.InputKnob; - } - - private void CheckType () - { - if (typeData.declaration == null || typeData.Type == null) - typeData = ConnectionTypes.GetTypeData (type); - } - - #endregion - - #region Value - - /// - /// Gets the value of the connection or the default value - /// - public T GetValue () - { - return connection != null? connection.GetValue () : NodeOutput.GetDefault (); - } - - /// - /// Sets the value of the connection if the type matches - /// - public void SetValue (T value) - { - if (connection != null) - connection.SetValue (value); - } - - #endregion - - #region Connecting Utility - - /// - /// Check if the passed NodeOutput can be connected to this NodeInput - /// - public bool CanApplyConnection (NodeOutput output) - { - if (output == null || body == output.body || connection == output || typeData.Type != output.typeData.Type) - return false; - - if (output.body.isChildOf (body)) - { // Recursive - if (!output.body.allowsLoopRecursion (body)) - { - // TODO: Generic Notification - Debug.LogWarning ("Cannot apply connection: Recursion detected!"); - return false; - } - } - return true; - } - - /// - /// Applies a connection between the passed NodeOutput and this NodeInput. 'CanApplyConnection' has to be checked before to avoid interferences! - /// - public void ApplyConnection (NodeOutput output) - { - if (output == null) - return; - - if (connection != null) - { - NodeEditorCallbacks.IssueOnRemoveConnection (this); - connection.connections.Remove (this); - } - connection = output; - output.connections.Add (this); - - NodeEditor.RecalculateFrom (body); - output.body.OnAddOutputConnection (output); - body.OnAddInputConnection (this); - NodeEditorCallbacks.IssueOnAddConnection (this); - } - - /// - /// Removes the connection from this NodeInput - /// - public void RemoveConnection () - { - if (connection == null) - return; - - NodeEditorCallbacks.IssueOnRemoveConnection (this); - connection.connections.Remove (this); - connection = null; - - NodeEditor.RecalculateFrom (body); - } - - - #endregion - } -} \ No newline at end of file diff --git a/Node_Editor/Framework/Canvas Save Objects/NodeInput.cs.meta b/Node_Editor/Framework/Canvas Save Objects/NodeInput.cs.meta deleted file mode 100644 index 4ce34a56..00000000 --- a/Node_Editor/Framework/Canvas Save Objects/NodeInput.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 4caff27366054dd44a30ddb5be369acc -timeCreated: 1437395312 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Node_Editor/Framework/Canvas Save Objects/NodeOutput.cs b/Node_Editor/Framework/Canvas Save Objects/NodeOutput.cs deleted file mode 100644 index 2bf93ebe..00000000 --- a/Node_Editor/Framework/Canvas Save Objects/NodeOutput.cs +++ /dev/null @@ -1,134 +0,0 @@ -using UnityEngine; -using System.Collections.Generic; - -namespace NodeEditorFramework -{ - /// - /// Node output accepts multiple connections to NodeInputs by default - /// - public class NodeOutput : NodeKnob - { - // NodeKnob Members - protected override NodeSide defaultSide { get { return NodeSide.Right; } } - private static GUIStyle _defaultStyle; - protected override GUIStyle defaultLabelStyle { get { if (_defaultStyle == null) { _defaultStyle = new GUIStyle (GUI.skin.label); _defaultStyle.alignment = TextAnchor.MiddleRight; } return _defaultStyle; } } - - // NodeInput Members - public List connections = new List (); - public string type; - [System.NonSerialized] - internal TypeData typeData; - [System.NonSerialized] - private object value = null; - - #region Contructors - - /// - /// Creates a new NodeOutput in NodeBody of specified type - /// - public static NodeOutput Create (Node nodeBody, string outputName, string outputType) - { - return Create (nodeBody, outputName, outputType, NodeSide.Right, 20); - } - - /// - /// Creates a new NodeOutput in NodeBody of specified type - /// - public static NodeOutput Create (Node nodeBody, string outputName, string outputType, NodeSide nodeSide) - { - return Create (nodeBody, outputName, outputType, nodeSide, 20); - } - - /// - /// Creates a new NodeOutput in NodeBody of specified type at the specified Node Side - /// - public static NodeOutput Create (Node nodeBody, string outputName, string outputType, NodeSide nodeSide, float sidePosition) - { - NodeOutput output = CreateInstance (); - output.type = outputType; - output.InitBase (nodeBody, nodeSide, sidePosition, outputName); - nodeBody.Outputs.Add (output); - return output; - } - - #endregion - - #region Additional Serialization - - protected internal override void CopyScriptableObjects (System.Func replaceSerializableObject) - { - for (int conCnt = 0; conCnt < connections.Count; conCnt++) - connections[conCnt] = replaceSerializableObject.Invoke (connections[conCnt]) as NodeInput; - } - - #endregion - - #region KnobType - - protected override void ReloadTexture () - { - CheckType (); - knobTexture = typeData.OutputKnob; - } - - private void CheckType () - { - if (typeData.declaration == null || typeData.Type == null) - typeData = ConnectionTypes.GetTypeData (type); - } - - #endregion - - #region Value - - public bool IsValueNull { get { return value == null; } } - - /// - /// Gets the output value if the type matches - /// - /// Value, if null default(T) (-> For reference types, null. For value types, default value) - public T GetValue () - { - if (typeData.Type == null) - CheckType (); - if (typeData.Type == typeof(T)) - return (T)(value?? (value = GetDefault ())); - Debug.LogError ("Trying to GetValue<" + typeof(T).FullName + "> for Output Type: " + typeData.Type.FullName); - return GetDefault (); - } - - /// - /// Sets the output value if the type matches - /// - public void SetValue (T Value) - { - if (typeData.Type == null) - CheckType (); - if (typeData.Type == typeof(T)) - value = Value; - else - Debug.LogError ("Trying to SetValue<" + typeof(T).FullName + "> for Output Type: " + typeData.Type.FullName); - } - - /// - /// Resets the output value to null. - /// - public void ResetValue () - { - value = null; - } - - /// - /// For value types, the default value; for reference types, the default constructor if existant, else null - /// - public static T GetDefault () - { - if (typeof(T).GetConstructor (System.Type.EmptyTypes) != null) // Try to create using an empty constructor if existant - return System.Activator.CreateInstance (); - else // Else try to get default. Returns null only on reference types - return default(T); - } - - #endregion - } -} \ No newline at end of file diff --git a/Node_Editor/Framework/Canvas Save Objects/NodeOutput.cs.meta b/Node_Editor/Framework/Canvas Save Objects/NodeOutput.cs.meta deleted file mode 100644 index 1d89ef06..00000000 --- a/Node_Editor/Framework/Canvas Save Objects/NodeOutput.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 42e7026d0da7df848ab67d517ac12d74 -timeCreated: 1437395312 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Node_Editor/Framework/Canvas Save Objects/Transition.cs b/Node_Editor/Framework/Canvas Save Objects/Transition.cs deleted file mode 100644 index 5a83f514..00000000 --- a/Node_Editor/Framework/Canvas Save Objects/Transition.cs +++ /dev/null @@ -1,170 +0,0 @@ -using UnityEngine; -using UnityEngine.Events; -using System; -using System.Collections.Generic; - -using NodeEditorFramework.Utilities; - -namespace NodeEditorFramework -{ - /// - /// Represents a Transition between two nodes [states] with conditions and a transition time. WIP - /// - [Serializable] - public class Transition : ScriptableObject - { - // Unfortunately, unity cannot serialize properties, so we create a serialized backing variable - public Node startNode { get { return _startNode; } internal set { _startNode = value; } } - [SerializeField] - internal Node _startNode; - public Node endNode { get { return _endNode; } internal set { _endNode = value; } } - [SerializeField] - internal Node _endNode; - - [SerializeField] - public List conditions = new List (); - //public List> conditions; - - public bool isTransitioning { get; private set; } - private float startTransitioningTime; - public float transitionTime = 2; // In seconds - - private static float totalTime { get { - #if UNITY_EDITOR - return (float)UnityEditor.EditorApplication.timeSinceStartup; - #else - return Time.time; - #endif - } } - - #region General - - /// - /// Creates a Transition between the given Nodes with a transitioning time of two secs - /// - public static Transition Create (Node fromNode, Node toNode) - { - return Create (fromNode, toNode, 2); - } - - /// - /// Creates a Transition between the given Nodes with the given transitioning time in secs - /// - public static Transition Create (Node fromNode, Node toNode, float TransitionTimeInSec) - { - if (fromNode.AcceptsTranstitions == false || toNode.AcceptsTranstitions == false || fromNode == toNode) - return null; - - Transition transition = CreateInstance (); - transition.name = "Transition " + fromNode.name + "-" + toNode.name; - transition.startNode = fromNode; - transition.endNode = toNode; - transition.transitionTime = TransitionTimeInSec; - - fromNode.transitions.Add (transition); - toNode.transitions.Add (transition); - - return transition; - } - - /// - /// Deletes this Transition from the Nodes - /// - public void Delete () - { - NodeEditorCallbacks.IssueOnRemoveTransition (this); - startNode.transitions.Remove (this); - endNode.transitions.Remove (this); - UnityEngine.Object.DestroyImmediate (this, true); - } - - #endregion - - #region Transition Logic - - /// - /// Returns whether all conditions for this transition to start are met - /// - public bool conditionsMet () - { - foreach (TransitionCondition condition in conditions) - { - if (!condition.Invoke (this)) - return false; - } - return true; - } - - /// - /// Starts the transitioning process with timing - /// - public void startTransition () - { - startTransitioningTime = totalTime; - isTransitioning = true; - } - - /// - /// Returns the transitioning process based on timing - /// - public float transitionProgress () - { - if (!isTransitioning) - throw new UnityException ("Can't check transitioning progress when not transitioning!"); - //Debug.Log ("TransitionProgress = ( CurTime:" + totalTime + " - StartTime:" + startTransitioningTime + " ) / TimeLenght:" + transitionTime + " = " + ((totalTime-startTransitioningTime)/transitionTime)); - return (totalTime-startTransitioningTime)/transitionTime; - } - - /// - /// Returns whether the transitioning process has finished and automatically stops it if true - /// - public bool finishedTransition () - { - if (!isTransitioning) - throw new UnityException ("Can't check whether transitioning finished when not transitioning!"); - bool finished = (totalTime-startTransitioningTime) >= transitionTime; - if (finished) - stopTransition (); - return finished; - } - - /// - /// Stops the transitioning process - /// - public void stopTransition () - { - isTransitioning = false; - startTransitioningTime = 0; - } - - #endregion - - #region Drawing - - /// - /// Draws this transition as a line and a button to select it. Has to be called from the start node - /// - public void DrawFromStartNode () - { - Vector2 StartPoint = startNode.rect.center + NodeEditor.curEditorState.zoomPanAdjust; - Vector2 EndPoint = endNode.rect.center + NodeEditor.curEditorState.zoomPanAdjust; - - if (isTransitioning) - RTEditorGUI.DrawLine (StartPoint, Vector2.Lerp (StartPoint, EndPoint, transitionProgress ()), Color.cyan, null, 4); - RTEditorGUI.DrawLine (StartPoint, EndPoint, Color.grey, null, 3); - - Rect selectRect = new Rect (0, 0, 20, 20); - selectRect.center = Vector2.Lerp (StartPoint, EndPoint, 0.5f); - if (GUI.Button (selectRect, "#")) - { - Debug.Log ("Selected " + name); - // TODO: Select - #if UNITY_EDITOR - UnityEditor.Selection.activeObject = this; - #endif - } - } - - #endregion - } -} \ No newline at end of file diff --git a/Node_Editor/Framework/Canvas Save Objects/Transition.cs.meta b/Node_Editor/Framework/Canvas Save Objects/Transition.cs.meta deleted file mode 100644 index 1693a8d4..00000000 --- a/Node_Editor/Framework/Canvas Save Objects/Transition.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: f9514494d336f3648b463b2e74635e37 -timeCreated: 1437395314 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Node_Editor/Nodes/AllAroundNode.cs b/Node_Editor/Nodes/AllAroundNode.cs deleted file mode 100644 index 1303ab23..00000000 --- a/Node_Editor/Nodes/AllAroundNode.cs +++ /dev/null @@ -1,60 +0,0 @@ -using UnityEngine; -using NodeEditorFramework; - -[Node (false, "AllAround Node")] -public class AllAroundNode : Node -{ - public const string ID = "allaroundNode"; - public override string GetID { get { return ID; } } - - public override bool AllowRecursion { get { return true; } } - public override bool ContinueCalculation { get { return true; } } - - public override Node Create (Vector2 pos) - { - AllAroundNode node = CreateInstance (); - - node.rect = new Rect (pos.x, pos.y, 60, 60); - node.name = "AllAround Node"; - - node.CreateInput ("Input Top", "Float", NodeSide.Top, 20); - node.CreateInput ("Input Bottom", "Float", NodeSide.Bottom, 20); - node.CreateInput ("Input Right", "Float", NodeSide.Right, 20); - node.CreateInput ("Input Left", "Float", NodeSide.Left, 20); - - node.CreateOutput ("Output Top", "Float", NodeSide.Top, 40); - node.CreateOutput ("Output Bottom", "Float", NodeSide.Bottom, 40); - node.CreateOutput ("Output Right", "Float", NodeSide.Right, 40); - node.CreateOutput ("Output Left", "Float", NodeSide.Left, 40); - - return node; - } - - protected internal override void DrawNode () - { - Rect nodeRect = rect; - nodeRect.position += NodeEditor.curEditorState.zoomPanAdjust; - - Rect bodyRect = new Rect (nodeRect.x, nodeRect.y, nodeRect.width, nodeRect.height); - - GUI.changed = false; - GUILayout.BeginArea (bodyRect, GUI.skin.box); - NodeGUI (); - GUILayout.EndArea (); - } - - protected internal override void NodeGUI () - { - - } - - public override bool Calculate () - { - Outputs [0].SetValue (Inputs [0].GetValue ()); - Outputs [1].SetValue (Inputs [1].GetValue ()); - Outputs [2].SetValue (Inputs [2].GetValue ()); - Outputs [3].SetValue (Inputs [3].GetValue ()); - - return true; - } -} \ No newline at end of file diff --git a/Node_Editor/Nodes/AllAroundNode.cs.meta b/Node_Editor/Nodes/AllAroundNode.cs.meta deleted file mode 100644 index eb378d85..00000000 --- a/Node_Editor/Nodes/AllAroundNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: ec20c217ebe61744d82a69ad83ff2447 -timeCreated: 1444930712 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Node_Editor/Nodes/ExampleNode.cs b/Node_Editor/Nodes/ExampleNode.cs deleted file mode 100644 index 6ef707be..00000000 --- a/Node_Editor/Nodes/ExampleNode.cs +++ /dev/null @@ -1,50 +0,0 @@ -using UnityEngine; -using NodeEditorFramework; -using NodeEditorFramework.Utilities; - -[Node (true, "Example Node")] -public class ExampleNode : Node -{ - public const string ID = "exampleNode"; - public override string GetID { get { return ID; } } - - public override Node Create (Vector2 pos) - { - ExampleNode node = CreateInstance (); - - node.rect = new Rect (pos.x, pos.y, 150, 60); - node.name = "Example Node"; - - node.CreateInput ("Value", "Float"); - node.CreateOutput ("Output val", "Float"); - - return node; - } - - protected internal override void NodeGUI () - { - GUILayout.Label ("This is a custom Node!"); - - GUILayout.BeginHorizontal (); - GUILayout.BeginVertical (); - - Inputs [0].DisplayLayout (); - - GUILayout.EndVertical (); - GUILayout.BeginVertical (); - - Outputs [0].DisplayLayout (); - - GUILayout.EndVertical (); - GUILayout.EndHorizontal (); - - } - - public override bool Calculate () - { - if (!allInputsReady ()) - return false; - Outputs[0].SetValue (Inputs[0].GetValue () * 5); - return true; - } -} diff --git a/Node_Editor/Nodes/ExampleNode.cs.meta b/Node_Editor/Nodes/ExampleNode.cs.meta deleted file mode 100644 index c8c74374..00000000 --- a/Node_Editor/Nodes/ExampleNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 039d2c5c84d9bf0489aecb2b0b669362 -timeCreated: 1447019305 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Node_Editor/Nodes/FloatCalc.meta b/Node_Editor/Nodes/FloatCalc.meta deleted file mode 100644 index 65e555a2..00000000 --- a/Node_Editor/Nodes/FloatCalc.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: c34c6824880fe4948aee0e4e66cfc5e8 -folderAsset: yes -timeCreated: 1437395312 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Node_Editor/Nodes/GroupNode.cs b/Node_Editor/Nodes/GroupNode.cs deleted file mode 100644 index 5148d6ec..00000000 --- a/Node_Editor/Nodes/GroupNode.cs +++ /dev/null @@ -1,186 +0,0 @@ -using UnityEngine; -using System; -using System.Collections.Generic; -using NodeEditorFramework; - -[System.Serializable] -[Node (true, "Group")] -public class GroupNode : Node -{ - public const string ID = "groupNode"; - public override string GetID { get { return ID; } } - - public bool edit = false; - public NodeCanvas nodeGroupCanvas; - public NodeEditorState editorState; - - private Vector2 canvasSize = new Vector2 (400, 400); - private const int borderWidth = 6; - public Rect nodeRect; - public Rect openedRect { get { return new Rect (rect.center.x - canvasSize.x/2 - borderWidth - 100, rect.y, canvasSize.x + borderWidth*2 + 200, 62 + canvasSize.y + borderWidth); } } - - public override Node Create (Vector2 pos) - { // This function has to be registered in Node_Editor.ContextCallback - GroupNode node = CreateInstance (); - - node.name = "Group Node"; - node.rect = node.nodeRect = new Rect (pos.x, pos.y, 300, 80); - - return node; - } - - protected internal override void NodeGUI () - { - GUILayout.BeginHorizontal (); -#if UNITY_EDITOR - if (GUILayout.Button (new GUIContent ("Load", "Loads the group from an extern Canvas Asset File."))) - { - string path = UnityEditor.EditorUtility.OpenFilePanel ("Load Node Canvas", NodeEditor.editorPath + "Saves/", "asset"); - if (!path.Contains (Application.dataPath)) - { - // TODO: Generic Notification - //if (path != String.Empty) - //ShowNotification (new GUIContent ("You should select an asset inside your project folder!")); - return; - } - path = path.Replace (Application.dataPath, "Assets"); - LoadNodeCanvas (path); - //AdoptInputsOutputs (); - } - if (GUILayout.Button (new GUIContent ("Save", "Saves the group as a new Canvas Asset File"))) - { - NodeEditorSaveManager.SaveNodeCanvas (UnityEditor.EditorUtility.SaveFilePanelInProject ("Save Group Node Canvas", "Group Canvas", "asset", "", NodeEditor.editorPath + "Saves/"), nodeGroupCanvas); - } -#endif - if (GUILayout.Button (new GUIContent ("New Group Canvas", "Creates a new Canvas"))) - { - nodeGroupCanvas = CreateInstance (); - - editorState = CreateInstance (); - editorState.drawing = edit; - editorState.name = "GroupNode_EditorState"; - - Node node = NodeTypes.getDefaultNode ("exampleNode"); - if (node != null) - { - NodeCanvas prevNodeCanvas = NodeEditor.curNodeCanvas; - NodeEditor.curNodeCanvas = nodeGroupCanvas; - node = node.Create (Vector2.zero); - node.InitBase (); - NodeEditor.curNodeCanvas = prevNodeCanvas; - } - } - GUILayout.EndHorizontal (); - - if (nodeGroupCanvas != null) - { - foreach (NodeInput input in Inputs) - input.DisplayLayout (); - - foreach (NodeOutput output in Outputs) - output.DisplayLayout (); - - if (!edit) - { - if (GUILayout.Button ("Edit Node Canvas")) - { - rect = openedRect; - edit = true; - editorState.canvasRect = GUILayoutUtility.GetRect (canvasSize.x, canvasSize.y, GUIStyle.none); - editorState.drawing = true; - } - } - else - { - if (GUILayout.Button ("Stop editing Node Canvas")) - { - nodeRect.position = openedRect.position + new Vector2 (canvasSize.x/2 - nodeRect.width/2, 0); - rect = nodeRect; - edit = false; - editorState.drawing = false; - } - - Rect canvasRect = GUILayoutUtility.GetRect (canvasSize.x, canvasSize.y, new GUILayoutOption[] { GUILayout.ExpandWidth (false) }); - if (Event.current.type != EventType.Layout) - { - editorState.canvasRect = canvasRect; - Rect canvasControlRect = editorState.canvasRect; - canvasControlRect.position += rect.position + contentOffset; - NodeEditor.curEditorState.ignoreInput.Add (NodeEditorFramework.NodeEditor.CanvasGUIToScreenRect (canvasControlRect)); - } - - NodeEditor.DrawSubCanvas (nodeGroupCanvas, editorState); - - - GUILayout.BeginArea (new Rect (canvasSize.x + 8, 45, 200, canvasSize.y), GUI.skin.box); - GUILayout.Label (new GUIContent ("Node Editor (" + nodeGroupCanvas.name + ")", "The currently opened canvas in the Node Editor")); - #if UNITY_EDITOR - editorState.zoom = UnityEditor.EditorGUILayout.Slider (new GUIContent ("Zoom", "Use the Mousewheel. Seriously."), editorState.zoom, 0.6f, 2); - #endif - GUILayout.EndArea (); - - - // Node is drawn by parent nodeCanvas, usually the mainNodeCanvas, because the zoom feature requires it to be drawn outside of any GUI group - } - } - } - - public void LoadNodeCanvas (string path) - { - nodeGroupCanvas = NodeEditorSaveManager.LoadNodeCanvas (path); - if (nodeGroupCanvas != null) - { - List editorStates = NodeEditorSaveManager.LoadEditorStates (path); - editorState = editorStates.Count == 0? CreateInstance () : editorStates[0]; - editorState.canvas = nodeGroupCanvas; - editorState.parentEditor = NodeEditor.curEditorState; - editorState.drawing = edit; - editorState.name = "GroupNode_EditorState"; - - string[] folders = path.Split (new char[] {'/'}, StringSplitOptions.None); - string canvasName = folders [folders.Length-1]; - if (canvasName.EndsWith (".asset")) - canvasName = canvasName.Remove (canvasName.Length-6); - name = canvasName; - } - else - name = "Node Group"; - } - - public void AdoptInputsOutputs () - { - Inputs = new List (); - Outputs = new List (); - - if (nodeGroupCanvas == null) - return; - - Debug.Log ("Adopting Inputs/Outputs"); - foreach (Node node in nodeGroupCanvas.nodes) - { - Debug.Log ("Checking node!"); - if (node.Inputs.Count == 0) - { // Input Node - Debug.Log ("Adopting input node!"); - foreach (NodeOutput output in node.Outputs) - Inputs.Add (NodeInput.Create (node, output.name, output.type)); - } - else if (node.Outputs.Count == 0) - { // Output node - Debug.Log ("Adopting output node!"); - foreach (NodeInput input in node.Inputs) - Outputs.Add (NodeOutput.Create (node, input.name, input.type)); - } - } - } - - public override bool Calculate () - { - // And set inputs/outputs -// if (nodeGroupCanvas != null) -// NodeEditor.RecalculateAll (nodeGroupCanvas, false); - return true; - } -} - - diff --git a/Node_Editor/Nodes/GroupNode.cs.meta b/Node_Editor/Nodes/GroupNode.cs.meta deleted file mode 100644 index 8d16b184..00000000 --- a/Node_Editor/Nodes/GroupNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 6e97db52e19c0944b83038a27dddc938 -timeCreated: 1437395312 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Node_Editor/Nodes/StateNode.cs b/Node_Editor/Nodes/StateNode.cs deleted file mode 100644 index 1fb77199..00000000 --- a/Node_Editor/Nodes/StateNode.cs +++ /dev/null @@ -1,66 +0,0 @@ -using UnityEngine; -using UnityEngine.Events; -using System.Collections.Generic; -using NodeEditorFramework; -using NodeEditorFramework.Utilities; - -[System.Serializable] -public class TransitionCondition : UnityFunc { public TransitionCondition (System.Delegate func) : base (func) {} } - -[System.Serializable] -[Node(false, "State Machine/State")] -public class StateNode : Node -{ - [System.Serializable] - public class StateChange : UnityEvent {} - - public StateChange OnStateEnter; - public StateChange OnStateLeave; - public string stateName = ""; - - public override bool AcceptsTranstitions { get { return true; } } - - public override string GetID - { - get { return "stateNode"; } - } - - public override Node Create (Vector2 pos) - { - StateNode node = CreateInstance (); - name = "StateNode"; - node.rect = new Rect (pos.x, pos.y, 200, 80); - - OnStateEnter = new StateChange (); - OnStateLeave = new StateChange (); - - return node; - } - - protected internal override void NodeGUI () - { - name = stateName = RTEditorGUI.TextField (new GUIContent ("State Name"), stateName); - if (GUILayout.Button ("Start Transitioning!")) - NodeEditor.BeginTransitioning (NodeEditor.curNodeCanvas, this); - } - - public override bool Calculate () - { - return true; - } - - protected internal override void OnEnter (Transition originTransition) - { - OnStateEnter.Invoke (originTransition); - } - - protected internal override void OnLeave (Transition transition) - { - OnStateLeave.Invoke (transition); - } - -// protected internal override void OnAddTransition (Transition trans) -// { -// Debug.Log ("Node " + name + " was assigned the new Transition " + trans); -// } -} diff --git a/Node_Editor/Nodes/StateNode.cs.meta b/Node_Editor/Nodes/StateNode.cs.meta deleted file mode 100644 index e8057c7f..00000000 --- a/Node_Editor/Nodes/StateNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: cd18c40fc0cb4f343855d6409db3031e -timeCreated: 1437395312 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Node_Editor/Resources/Saves/AllAround Connections Test.asset b/Node_Editor/Resources/Saves/AllAround Connections Test.asset deleted file mode 100644 index 781fbc7b..00000000 Binary files a/Node_Editor/Resources/Saves/AllAround Connections Test.asset and /dev/null differ diff --git a/Node_Editor/Resources/Saves/AllAround Connections Test.asset.meta b/Node_Editor/Resources/Saves/AllAround Connections Test.asset.meta deleted file mode 100644 index d37db4aa..00000000 --- a/Node_Editor/Resources/Saves/AllAround Connections Test.asset.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: b5159b85322979a4aa41c816d11380b1 -timeCreated: 1455405843 -licenseType: Free -NativeFormatImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Node_Editor/Resources/Textures/BoxSelection.png b/Node_Editor/Resources/Textures/BoxSelection.png deleted file mode 100644 index acd62963..00000000 Binary files a/Node_Editor/Resources/Textures/BoxSelection.png and /dev/null differ diff --git a/Node_Editor/Resources/Textures/BoxSelection.png.meta b/Node_Editor/Resources/Textures/BoxSelection.png.meta deleted file mode 100644 index c62af3fc..00000000 --- a/Node_Editor/Resources/Textures/BoxSelection.png.meta +++ /dev/null @@ -1,57 +0,0 @@ -fileFormatVersion: 2 -guid: 76982e090bfa153419ddb86ee7a7b129 -timeCreated: 1453657600 -licenseType: Free -TextureImporter: - fileIDToRecycleName: {} - serializedVersion: 2 - mipmaps: - mipMapMode: 0 - enableMipMap: 0 - linearTexture: 1 - correctGamma: 0 - fadeOut: 0 - borderMipMap: 0 - mipMapFadeDistanceStart: 1 - mipMapFadeDistanceEnd: 3 - bumpmap: - convertToNormalMap: 0 - externalNormalMap: 0 - heightScale: 0.25 - normalMapFilter: 0 - isReadable: 1 - grayScaleToAlpha: 0 - generateCubemap: 0 - cubemapConvolution: 0 - cubemapConvolutionSteps: 7 - cubemapConvolutionExponent: 1.5 - seamlessCubemap: 0 - textureFormat: -3 - maxTextureSize: 32 - textureSettings: - filterMode: -1 - aniso: 1 - mipBias: -1 - wrapMode: 1 - nPOTScale: 0 - lightmap: 0 - rGBM: 2 - compressionQuality: 50 - allowsAlphaSplitting: 0 - spriteMode: 1 - spriteExtrude: 1 - spriteMeshType: 1 - alignment: 0 - spritePivot: {x: 0.5, y: 0.5} - spriteBorder: {x: 8, y: 8, z: 8, w: 8} - spritePixelsToUnits: 100 - alphaIsTransparency: 1 - textureType: 5 - buildTargetSettings: [] - spriteSheet: - sprites: [] - outline: [] - spritePackingTag: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Node_Editor/Utilities/Editor/UnityFuncEditor.cs b/Node_Editor/Utilities/Editor/UnityFuncEditor.cs deleted file mode 100644 index a1b0aadf..00000000 --- a/Node_Editor/Utilities/Editor/UnityFuncEditor.cs +++ /dev/null @@ -1,102 +0,0 @@ -using UnityEngine; -using UnityEditor; - -[CustomPropertyDrawer(typeof(UnityFuncBase), true)] -public class UnityFuncEditor : PropertyDrawer -{ - private static float lineHeight { get { return GUI.skin.label.lineHeight + 4; } } - public override float GetPropertyHeight (SerializedProperty prop, GUIContent label) - { - SerializedProperty argumentsProp = prop.FindPropertyRelative ("_arguments"); - return lineHeight * (2 + argumentsProp.arraySize); - } - - public override void OnGUI (Rect pos, SerializedProperty property, GUIContent label) - { - EditorGUI.BeginProperty (pos, label, property); - - SerializedProperty callStateProp = property.FindPropertyRelative ("callState"); - SerializedProperty methodNameProp = property.FindPropertyRelative ("_methodName"); - SerializedProperty argumentsProp = property.FindPropertyRelative ("_arguments"); - SerializedProperty targetObjProp = property.FindPropertyRelative ("_targetObject"); - - int indent = EditorGUI.indentLevel; - EditorGUI.indentLevel = 0; - - Rect[] gridRects = calcRectGrid (pos, lineHeight, new float[] { pos.width/2, pos.width/2 }); - - GUI.Label (gridRects[0], label); - - EditorGUI.PropertyField (gridRects[1], callStateProp); - - //targetObjProp.objectReferenceValue = EditorGUI.ObjectField (gridRects[2], targetObjProp.objectReferenceValue, typeof(Object), true); - - EditorGUI.PropertyField (gridRects[2], targetObjProp); - - methodNameProp.stringValue = EditorGUI.TextField (gridRects[3], methodNameProp.stringValue); - - for (int argCnt = 0; argCnt < argumentsProp.arraySize; argCnt++) - { - SerializedProperty argProp = argumentsProp.GetArrayElementAtIndex (argCnt).FindPropertyRelative ("objectValue"); - EditorGUI.PropertyField (gridRects[4+argCnt], argProp); - } - -// GUILayout.BeginHorizontal (); -// // Label -// GUILayout.Label (label); -// // CallState -// EditorGUILayout.PropertyField (callStateProp); -// GUILayout.EndHorizontal (); -// -// GUILayout.BeginHorizontal (); -// // Target Object -// targetObjProp.objectReferenceValue = EditorGUILayout.ObjectField (targetObjProp.objectReferenceValue, typeof(Object), true); -// // Method -// methodNameProp.stringValue = EditorGUILayout.TextField (methodNameProp.stringValue); -// GUILayout.EndHorizontal (); - -// int controlCount = argumentsProp.arraySize; -// float xPos = pos.x; -// -// Rect objectFieldRect = new Rect (xPos, pos.y, pos.width/controlCount, pos.height); -// xPos += pos.width/controlCount; -// targetObjProp.objectReferenceValue = EditorGUI.ObjectField (objectFieldRect, targetObjProp.objectReferenceValue, typeof(Object), true); -// -// Rect methodDropdownRect = new Rect (xPos, pos.y, pos.width/controlCount, pos.height); -// xPos += pos.width/controlCount; -// methodNameProp.stringValue = EditorGUI.TextField (methodDropdownRect, methodNameProp.stringValue); -// -// for (int argCnt = 0; argCnt < argumentsProp.arraySize; argCnt++) -// { -// Rect paramRect = new Rect (xPos, pos.y, pos.width/controlCount, pos.height); -// xPos += pos.width/controlCount; -// SerializedProperty argProp = argumentsProp.GetArrayElementAtIndex (argCnt).FindPropertyRelative ("objectValue"); -// EditorGUI.PropertyField (paramRect, argProp); -// } - - EditorGUI.indentLevel = indent; - - EditorGUI.EndProperty (); - } - - /// - /// Splites the parentRect up into a grid. - /// The number of rows is determined by the number of lines matching into the parentRect, - /// the number of columns by the passed array which also determines the column's widths. - /// - private Rect[] calcRectGrid (Rect parentRect, float cellHeight, float[] columnWidths) - { - int columns = columnWidths.Length, rows = (int)(parentRect.height/cellHeight); - Debug.Log ("Created " + columns + " cols and " + rows + " rows"); - Rect[] gridRects = new Rect[columns*rows]; - for (int rowCnt = 0; rowCnt < rows; rowCnt++) - { - for (int colCnt = 0; colCnt < columns; colCnt++) - { - float colWidth = columnWidths[colCnt]; - gridRects[rowCnt*columns + colCnt] = new Rect (parentRect.x + colWidth*colCnt, parentRect.y + cellHeight*rowCnt, colWidth, cellHeight); - } - } - return gridRects; - } -} diff --git a/Node_Editor/Utilities/Editor/UnityFuncEditor.cs.meta b/Node_Editor/Utilities/Editor/UnityFuncEditor.cs.meta deleted file mode 100644 index 6f68890b..00000000 --- a/Node_Editor/Utilities/Editor/UnityFuncEditor.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 2738cd2a9ff55a041b23b3a3f4d13b59 -timeCreated: 1454975752 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Node_Editor/Utilities/UnityFunc.cs b/Node_Editor/Utilities/UnityFunc.cs deleted file mode 100644 index 38d0477b..00000000 --- a/Node_Editor/Utilities/UnityFunc.cs +++ /dev/null @@ -1,336 +0,0 @@ -using UnityEngine; -using UnityEngine.Events; -using System; -using System.Text.RegularExpressions; -using System.Reflection; -using System.Collections.Generic; - -using Object = UnityEngine.Object; - -/// -/// Base for all UnityFuncs. Includes all serialization stuff of the delegates. -/// -[Serializable] -public abstract class UnityFuncBase -{ - // Following are the serialized method details - [SerializeField] - private Object _targetObject; - [SerializeField] - private string _methodName; - [SerializeField] - private FuncSerializedType _returnType; - [SerializeField] - private FuncSerializedTypeValue[] _arguments; - - public UnityEventCallState callState; - - #region Base Code - - /// - /// Creates a serializeable UnityFunc from the passed delegate - /// - public UnityFuncBase (Delegate func) - { - if (func.Target == null || func.Method == null) - throw new ArgumentException ("Func " + func + " is anonymous!"); - - _targetObject = (Object)func.Target; - _methodName = func.Method.Name; - _returnType = new FuncSerializedType (func.Method.ReturnType); - - ParameterInfo[] parameters = func.Method.GetParameters (); - _arguments = new FuncSerializedTypeValue[parameters.Length]; - for (int paramCnt = 0; paramCnt < parameters.Length; paramCnt++) - _arguments[paramCnt] = new FuncSerializedType (parameters[paramCnt].ParameterType) as FuncSerializedTypeValue; - } - - /// - /// Creates a serializeable UnityFunc from the passed method on the targetObject - /// - public UnityFuncBase (Object targetObject, MethodInfo methodInfo) - { - _targetObject = targetObject; - _methodName = methodInfo.Name; - _returnType = new FuncSerializedType (methodInfo.ReturnType); - - ParameterInfo[] parameters = methodInfo.GetParameters (); - _arguments = new FuncSerializedTypeValue[parameters.Length]; - for (int paramCnt = 0; paramCnt < parameters.Length; paramCnt++) - _arguments[paramCnt] = new FuncSerializedType (parameters[paramCnt].ParameterType) as FuncSerializedTypeValue; - } - - /// - /// Returns the runtime delegate this UnityFunc representates. Create only once on initialisation! - /// Returns a System.Func with of apropriate type depending on return and argument types boxed as a delegate. - /// Handled and stored on initialisation by children func variations. - /// - protected Delegate DeserializeToDelegate () - { - if (callState == UnityEventCallState.Off || (callState == UnityEventCallState.RuntimeOnly && !Application.isPlaying)) - return null; - - Type[] runtimeArgumentTypes = new Type[_arguments.Length]; - for (int argCnt = 0; argCnt < _arguments.Length; argCnt++) - runtimeArgumentTypes[argCnt] = _arguments[argCnt].GetRuntimeType (); - - MethodInfo methodInfo = GetValidMethodInfo (_targetObject, _methodName, _returnType.GetRuntimeType (), runtimeArgumentTypes); - if (methodInfo == null) - return null; - return Delegate.CreateDelegate (typeof (Func<>), methodInfo); - } - - #endregion - - #region Static Helpers - - /// - /// Gets the valid MethodInfo of the method on targetObj called functionName with the specified returnType (may be null incase of void) and argumentTypes - /// - protected static MethodInfo GetValidMethodInfo (object targetObj, string methodName, Type returnType, Type[] argumentTypes) - { - Type targetType = targetObj.GetType (); - if (returnType == null) // Account for void return type, too - returnType = typeof(void); - while (targetType != typeof(object) && targetType != null) - { // Search targetObj's type hierarchy for the functionName until we hit the object base type or found it (incase the function is inherited) - MethodInfo method = targetType.GetMethod (methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, argumentTypes, null); - if (method != null && method.ReturnType == returnType) - { // This type contains a method with the specified name, arguments and return type - ParameterInfo[] parameters = method.GetParameters (); - bool flag = true; - for (int paramCnt = 0; paramCnt < parameters.Length; paramCnt++) - { // Check whether the arguments match in that they are primitives (isn't this already sorted out in getMethod?) - if (!(flag = (argumentTypes [paramCnt].IsPrimitive == parameters [paramCnt].ParameterType.IsPrimitive))) - break; // Else, this is not the right method - } - if (flag) // We found the method! - return method; - } - // Move up in the type hierarchy (function was inherited) - returnType = returnType.BaseType; - } - return null; // No valid method found on targetObj that has this functionName - } - - /// - /// Creates a new UnityFunc from the specified parameters, useful for when arguments are not known compile time. - /// - private static UnityFuncBase GetObjectCall (Object targetObj, MethodInfo method, Type returnType, FuncSerializedTypeValue[] arguments) - { - // Built Argument and GenericArgument arrays - Type[] contrustorArgTypes = new Type[arguments.Length+3]; - contrustorArgTypes[0] = typeof(Object); - contrustorArgTypes[1] = typeof(MethodInfo); - contrustorArgTypes[2] = typeof(Type); - Type[] genericTypeArgs = new Type[arguments.Length+1]; - genericTypeArgs[0] = returnType; - for (int argCnt = 0; argCnt < arguments.Length; argCnt++) - contrustorArgTypes[argCnt+3] = genericTypeArgs[argCnt+1] = arguments[argCnt].GetRuntimeType (); - // Create Contructor for the func - Type baseGenericType = typeof(UnityFunc<>); - Type funcType = baseGenericType.MakeGenericType (genericTypeArgs); - ConstructorInfo funcContructor = funcType.GetConstructor (contrustorArgTypes); - // Built Argument array - object[] contructorArgObjects = new object[arguments.Length+3]; - contructorArgObjects[0] = targetObj; - contructorArgObjects[1] = method; - contructorArgObjects[2] = returnType; - for (int argCnt = 0; argCnt < arguments.Length; argCnt++) - contructorArgObjects[argCnt+3] = arguments[argCnt].objectValue; - // Create func using the generated contructor - return funcContructor.Invoke (contructorArgObjects) as UnityFuncBase; - } - - #endregion - - #region Nested Types - - [Serializable] - private class FuncSerializedType : ISerializationCallbackReceiver - { - [SerializeField] - private string argAssemblyTypeName; - - [NonSerialized] - private Type runtimeType; - - public FuncSerializedType (Type type) - { - SetType (type); - } - - protected void SetType (Type type) - { - runtimeType = type; - argAssemblyTypeName = type.AssemblyQualifiedName; - } - - public void OnAfterDeserialize () - { - TidyAssemblyTypeName (); - } - - public void OnBeforeSerialize () - { - TidyAssemblyTypeName (); - } - - private void TidyAssemblyTypeName () - { - if (String.IsNullOrEmpty (argAssemblyTypeName)) - return; - argAssemblyTypeName = Regex.Replace (argAssemblyTypeName, @", Version=\d+.\d+.\d+.\d+", String.Empty); - argAssemblyTypeName = Regex.Replace (argAssemblyTypeName, @", Culture=\w+", String.Empty); - argAssemblyTypeName = Regex.Replace (argAssemblyTypeName, @", PublicKeyToken=\w+", String.Empty); - } - - public Type GetRuntimeType () - { - return runtimeType ?? (runtimeType = Type.GetType (argAssemblyTypeName, false) ?? typeof(Object)); - } - } - - [Serializable] - private class FuncSerializedTypeValue : FuncSerializedType - { - [SerializeField] - private Object objVal; - - public Object objectValue - { - get { return objVal; } - set - { - if (GetRuntimeType () != objVal.GetType ()) - throw new ArgumentException ("Object " + objVal + " not of required type " + GetRuntimeType ().Name + " but of " + objVal.GetType ().Name); - objVal = value; - SetType (objVal.GetType ()); - } - } - - public FuncSerializedTypeValue (Object obj) : base (obj.GetType ()) - { - objVal = obj; - } - } - - - #endregion -} - -#region Parameter Variation - -[Serializable] -public class UnityFunc : UnityFuncBase -{ - [NonSerialized] - private Func runtimeDelegate; - - // Retarget constructors to base - public UnityFunc (Object targetObject, MethodInfo methodInfo) : base (targetObject, methodInfo) {} - public UnityFunc (Delegate func) : base (func) {} - - public TR Invoke (T1 arg1, T2 arg2, T3 arg3, T4 arg4) - { - if (runtimeDelegate == null) - runtimeDelegate = DeserializeToDelegate () as Func; - if (runtimeDelegate != null) - return runtimeDelegate.Invoke (arg1, arg2, arg3, arg4); - return default(TR); - } -} - -/// -/// UnityFunc with three paramteters. Extend this and use that class to make it serializeable -/// -[Serializable] -public class UnityFunc : UnityFuncBase -{ - [NonSerialized] - private Func runtimeDelegate; - - // Retarget constructors to base - public UnityFunc (Object targetObject, MethodInfo methodInfo) : base (targetObject, methodInfo) {} - public UnityFunc (Delegate func) : base (func) {} - - public TR Invoke (T1 arg1, T2 arg2, T3 arg3) - { - if (runtimeDelegate == null) - runtimeDelegate = DeserializeToDelegate () as Func; - if (runtimeDelegate != null) - return runtimeDelegate.Invoke (arg1, arg2, arg3); - return default(TR); - } -} - -/// -/// UnityFunc with two paramteters. Extend this and use that class to make it serializeable -/// -[Serializable] -public class UnityFunc : UnityFuncBase -{ - [NonSerialized] - private Func runtimeDelegate; - - // Retarget constructors to base - public UnityFunc (Object targetObject, MethodInfo methodInfo) : base (targetObject, methodInfo) {} - public UnityFunc (Delegate func) : base (func) {} - - public TR Invoke (T1 arg1, T2 arg2) - { - if (runtimeDelegate == null) - runtimeDelegate = DeserializeToDelegate () as Func; - if (runtimeDelegate != null) - return runtimeDelegate.Invoke (arg1, arg2); - return default(TR); - } -} - -/// -/// UnityFunc with one paramteter. Extend this and use that class to make it serializeable -/// -[Serializable] -public class UnityFunc : UnityFuncBase -{ - [NonSerialized] - private Func runtimeDelegate; - - // Retarget constructors to base - public UnityFunc (Object targetObject, MethodInfo methodInfo) : base (targetObject, methodInfo) {} - public UnityFunc (Delegate func) : base (func) {} - - public TR Invoke (T1 arg) - { - if (runtimeDelegate == null) - runtimeDelegate = DeserializeToDelegate () as Func; - if (runtimeDelegate != null) - return runtimeDelegate.Invoke (arg); - return default(TR); - } -} - -/// -/// UnityFunc with no paramteters. Extend this and use that class to make it serializeable -/// -[Serializable] -public class UnityFunc : UnityFuncBase -{ - [NonSerialized] - private Func runtimeDelegate; - - // Retarget constructors to base - public UnityFunc (Object targetObject, MethodInfo methodInfo) : base (targetObject, methodInfo) {} - public UnityFunc (Delegate func) : base (func) {} - - public TR Invoke () - { - if (runtimeDelegate == null) - runtimeDelegate = DeserializeToDelegate () as Func; - if (runtimeDelegate != null) - return runtimeDelegate.Invoke (); - return default(TR); - } -} - -#endregion \ No newline at end of file diff --git a/Node_Editor/Utilities/UnityFunc.cs.meta b/Node_Editor/Utilities/UnityFunc.cs.meta deleted file mode 100644 index 0eabac69..00000000 --- a/Node_Editor/Utilities/UnityFunc.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: c58396e6fac6f1c43b82347ac5531136 -timeCreated: 1454962570 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: