Esempio n. 1
0
 /// <summary>
 /// Gets the name of a given node.
 /// </summary>
 /// <param name="node">The node to get the name of.</param>
 /// <returns>The name of the node.</returns>
 public string GetNodeName(SerializedNode node)
 {
     return(_tree.GetNodeName(node));
 }
Esempio n. 2
0
        public GraphNode(string titleLabel, string uxmlPath, string ussPath, Type runtimeType, EdgeConnectorListener edgeConnectorListener, SerializedNode serializedNode)
        {
            styleSheets.Remove(EditorGUIUtility.Load("StyleSheets/GraphView/Node.uss") as StyleSheet);
            m_serializedNode        = serializedNode;
            m_runtimeType           = runtimeType;
            m_runtimeInstance       = Activator.CreateInstance(m_runtimeType);
            m_edgeConnectorListener = edgeConnectorListener;

            if (m_serializedNode == null)
            {
                m_serializedNode = new SerializedNode
                {
                    Guid                  = System.Guid.NewGuid().ToString(),
                    IsExpanded            = true,
                    EditorPosition        = this.GetPosition().position,
                    NodeRuntimeTypeString = m_runtimeType.AssemblyQualifiedName,
                    SerializedPorts       = new List <SerializedPort>()
                };
            }
            else
            {
                SynchronizeFromSerializedNode();
            }
            //  Clear all default visual elements from the GraphView node.
            this.Clear();
            //  Load and bind our custom visual elements.
            LoadStyleSheet(ussPath);
            LoadUXML(uxmlPath);
            BindUXML();
            //  Run default node bootstrap
            BindGUIInternal();
            //  Run custom node boostrap
            OnBindGUI();

            title = titleLabel;
        }
 public void UpdateNodeDataPosition()
 {
     SerializedNode.FindPropertyRelative(ANode.PositionVarName).vector2Value = this.GetPosition().position;
     SerializedNode.serializedObject.ApplyModifiedProperties();
 }
Esempio n. 4
0
        /// <summary>
        /// Show the specified space, clip, node and position.
        /// </summary>
        /// <param name="space">Space.</param>
        /// <param name="clip">Clip.</param>
        /// <param name="node">Node.</param>
        /// <param name="position">Position.</param>
        public static void Show(GameObject space, AnimationClip clip, SerializedNode node, Rect?position)
        {
            MecanimNodeEditorWindow.__spaceGameObject = space;                                    //in this case is character
            MecanimNodeEditorWindow.__spaceGameObjectAnimationClip = clip;
            MecanimNodeEditorWindow.__serializedNode = node;



            ///////   ACCESS SERIALIZED DATA /////////
            NodePropertyIterator iterator = node.GetIterator();

            __isPlaying            = false;
            __isRecording          = false;
            __variableSelected     = null;
            __timeNormalized       = 0f;
            __timeNormalizedUpdate = false;
            __timeCurrent          = 0f;

            AnimationMode.StopAnimationMode();
            Undo.postprocessModifications -= PostprocessAnimationRecordingModifications;

            SceneView.onSceneGUIDelegate += OnSceneGUI;



            if (iterator.Find("clipBindings"))
            {
                clipBindingsSerialized = iterator.current;
            }



            if (__mecanimNodeClipBinding == null)
            {
                __mecanimNodeClipBinding = ScriptableObject.CreateInstance <EditorClipBinding> ();
            }

            __mecanimNodeClipBinding.gameObject = __spaceGameObject;
            __mecanimNodeClipBinding.clip       = __spaceGameObjectAnimationClip;



            /////// INIT SERIALIZED NODE PROPERTIES - CURVES, COLORS, VARIABLES //////


            if (iterator.Find("curves"))
            {
                curvesSerialized = iterator.current;
            }
            else
            {
                Debug.LogError("MecananimNode should have public field 'curves'");
            }

            if (iterator.Find("curvesColors"))
            {
                curvesColorsSerialized = iterator.current;
            }
            else
            {
                Debug.LogError("MecananimNode should have public field 'curvesColors'");
            }

            if (iterator.Find("variablesBindedToCurves"))
            {
                variablesBindedToCurvesSerialized = iterator.current;
            }
            else
            {
                Debug.LogError("MecananimNode should have public field 'variablesBindedToCurves'");
            }



            curves                  = (AnimationCurve[])curvesSerialized.value;
            curveColors             = (Color[])curvesColorsSerialized.value;
            variablesBindedToCurves = (UnityVariable[])variablesBindedToCurvesSerialized.value;

            AnimationModeUtility.ResetBindingsTransformPropertyModification(clipBindingsSerialized.value as EditorClipBinding[]);
            AnimationModeUtility.ResetBindingTransformPropertyModification(__mecanimNodeClipBinding);



            keyframeTimeValues  = new float[0];
            eventTimeValuesPrev = new float[0];

            keyframeTimeValuesSelected = new bool[0];
            keyframesDisplayNames      = new string[0];


            ///////////// create Reordable list of gameObject-animationClip //////////////////

            __gameObjectClipList = new ReorderableList(clipBindingsSerialized.value as IList, typeof(EditorClipBinding), true, true, true, true);
            __gameObjectClipList.drawElementCallback = onDrawElement;



            __gameObjectClipList.drawHeaderCallback = onDrawHeaderElement;

            __gameObjectClipList.onRemoveCallback = onRemoveCallback;
            __gameObjectClipList.onAddCallback    = onAddCallback;
            __gameObjectClipList.onSelectCallback = onSelectCallback;


            //__gameObjectClipList.elementHeight = 32f;


            if (MecanimNodeEditorWindow.__window != null)                                    //restore last
            {
                position = __window.position;
            }


            MecanimNodeEditorWindow.__window = (MecanimNodeEditorWindow)EditorWindow.GetWindow(typeof(MecanimNodeEditorWindow));



            if (position.HasValue)
            {
                MecanimNodeEditorWindow.__window.position = position.Value;
            }

            MecanimNodeEditorWindow.__window.Show();
        }
 public bool OutportHasEdge(int outportIndex)
 {
     return(OutportEdge.IsValid(SerializedNode.FindPropertyRelative(ANode.OutportsVarName).GetArrayElementAtIndex(outportIndex)));
 }