Exemplo n.º 1
0
        /// <summary>
        /// Creates a node link action and attaches it to this node
        /// </summary>
        /// <param name="rType">Type of action to create</param>
        /// <returns>NodeLinkAction that was created or null</returns>
        public virtual NodeLinkAction CreateLinkAction(Type rType)
        {
            if (Actions == null)
            {
                Actions = new List <NodeLinkAction>();
            }

            NodeLinkAction lAction = ScriptableObject.CreateInstance(rType) as NodeLinkAction;

            if (lAction != null)
            {
                lAction.name      = "z NodeCanvas.NodeLinkAction " + Actions.Count.ToString("D4");
                lAction.hideFlags = HideFlags.HideInHierarchy;

                Actions.Add(lAction);

#if UNITY_EDITOR
                UnityEditor.AssetDatabase.AddObjectToAsset(lAction, StartNode.Canvas.RootAsset);

                UnityEditor.EditorUtility.SetDirty(lAction);
                UnityEditor.EditorUtility.SetDirty(this);
                StartNode.Canvas.SetDirty();
#endif
            }

            return(lAction);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Removes the action from the list and destroys it
        /// </summary>
        /// <param name="rAction">Action to remove</param>
        public virtual void DestoryLinkAction(NodeLinkAction rAction)
        {
            if (rAction == null)
            {
                return;
            }

            if (Actions != null)
            {
                Actions.Remove(rAction);
            }

            UnityEngine.Object.DestroyImmediate(rAction, true);
            StartNode.Canvas.SetDirty();
        }