예제 #1
0
        private void SelectMatInfo(SerializedProperty property, AI_DecisionBase stateNode, object target)
        {
            NodeAIDececisionAttribute nodeFilter = (NodeAIDececisionAttribute)attribute;

            property.objectReferenceValue = stateNode;
            FieldInfo fi       = ReflectionUtility.GetField(target, property.name);
            object    oldValue = fi.GetValue(target);

            property.serializedObject.ApplyModifiedProperties(); // We must apply modifications so that the new value is updated in the serialized object
            object newValue = fi.GetValue(target);

            property.serializedObject.Update();

            MethodInfo callbackMethod = ReflectionUtility.GetMethod(target, nodeFilter.CallbackName);

            PropertyUtility.InvoKeCallback(callbackMethod, property, target, fieldInfo, oldValue, newValue);
        }
예제 #2
0
        private void ContextPopUp(Rect position, SerializedProperty property, GUIContent label)
        {
            // Throw error on wrong type
            if (property.propertyType != SerializedPropertyType.ObjectReference)
            {
                throw new ArgumentException("Parameter selected must be of type System.Enum");
            }

            EditorGUI.BeginChangeCheck();
            position = EditorGUI.PrefixLabel(position, label);

            Rect buttonRect = position;
            Rect buttonGo   = position;

            string          buttonLabel         = "Select";
            AI_DecisionBase currentAiActionBase = property.objectReferenceValue as AI_DecisionBase;


            if (currentAiActionBase != null)
            {
                buttonLabel = currentAiActionBase.name;
            }

            if (GUI.Button(buttonRect, buttonLabel, EditorStyles.miniButton))
            {
                NodeAIDececisionAttribute attr = (NodeAIDececisionAttribute)attribute;

                if (attr.UseNodeEnum)
                {
                    NodeEditorWindow.current.onLateGUI += () => ShowContextMenuAtMouse(property, currentAiActionBase);
                }
                else
                {
                    ShowContextMenuAtMouse(property, currentAiActionBase);
                }
            }

            if (EditorGUI.EndChangeCheck())
            {
                property.serializedObject.ApplyModifiedProperties();
            }
        }