Exemplo n.º 1
0
        static public FilteredMsgTypeList All()
        {
            Initialize();

            if (s_ListAll == null)
            {
                List <Metadata> types = null;
                Manager.Get().Database.FindAll(ref types);
                s_ListAll = new FilteredMsgTypeList(types);
            }
            return(s_ListAll);
        }
Exemplo n.º 2
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            position.height = EditorGUIUtility.singleLineHeight;

            EditorGUI.LabelField(position, label);

            MsgEditorGUIUtility.AdvanceLine(ref position);
            MsgEditorGUIUtility.BeginIndent(ref position);

            SerializedProperty targetProp = property.FindPropertyRelative("Target");

            MsgEditorGUI.MsgTargetField(position, targetProp, new GUIContent("Target"));

            MsgEditorGUIUtility.AdvanceLine(ref position);

            FilteredMsgTypeList list;
            int targetType = targetProp.FindPropertyRelative("Target").intValue;

            if (targetType == (int)MsgTarget.Mode.All)
            {
                list = FilteredMsgTypeList.Filtered(s_AllAttr);
            }
            else if (targetType == (int)MsgTarget.Mode.Other)
            {
                GameObject obj = targetProp.FindPropertyRelative("Object").objectReferenceValue as GameObject;
                if (obj == null)
                {
                    list = FilteredMsgTypeList.None();
                }
                else
                {
                    list = FilteredMsgTypeList.Filtered(obj, s_SingleAttr);
                }
            }
            else
            {
                Component component = property.serializedObject.targetObject as Component;
                if (component == null)
                {
                    list = FilteredMsgTypeList.Filtered(s_SingleAttr);
                }
                else
                {
                    list = FilteredMsgTypeList.Filtered(component.gameObject, s_SingleAttr);
                }
            }

            SerializedProperty callProp = property.FindPropertyRelative("Call");

            MsgEditorGUI.MsgCallField(position, callProp, new GUIContent("Message"), list);

            MsgEditorGUIUtility.EndIndent(ref position);
        }
Exemplo n.º 3
0
        static public FilteredMsgTypeList None()
        {
            Initialize();

            if (s_ListNone == null)
            {
                List <Metadata> types = new List <Metadata>();
                s_ListNone = new FilteredMsgTypeList(types);
            }

            return(s_ListNone);
        }
Exemplo n.º 4
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            FilterByFlag        attr = attribute as FilterByFlag;
            FilteredMsgTypeList list = null;

            if (LimitToSelf.IsDefined(fieldInfo, typeof(LimitToSelf), true))
            {
                Component c = property.serializedObject.targetObject as Component;
                if (c != null)
                {
                    list = FilteredMsgTypeList.Filtered(c.gameObject, attr);
                }
            }

            if (list == null)
            {
                list = FilteredMsgTypeList.Filtered(attr);
            }

            MsgEditorGUI.MsgTypeField(position, property, label, list);
        }
Exemplo n.º 5
0
        static public FilteredMsgTypeList Filtered(FilterByFlag inAttribute)
        {
            if (inAttribute == null || (inAttribute.FilterAll == MsgFlags.None && inAttribute.FilterAny == MsgFlags.None))
            {
                return(All());
            }

            Initialize();

            FilteredMsgTypeList list;

            if (!s_Lists.TryGetValue(inAttribute, out list))
            {
                List <Metadata> types = null;
                Manager.Get().Database.FindAll(inAttribute.FilterAll, inAttribute.FilterAny, ref types);
                list = new FilteredMsgTypeList(types);
                s_Lists.Add(inAttribute, list);
            }

            return(list);
        }
Exemplo n.º 6
0
        static public void MsgCallField(Rect position, SerializedProperty property, GUIContent label, FilteredMsgTypeList msgTypes)
        {
            position.height = EditorGUIUtility.singleLineHeight;

            SerializedProperty msgTypeProp  = property.FindPropertyRelative("m_MsgType");
            SerializedProperty argTypeProp  = property.FindPropertyRelative("m_ArgType");
            SerializedProperty sendArgsProp = property.FindPropertyRelative("m_SendArg");

            ArgState argState = ArgState.MissingType;

            MsgCall.ArgType argType = (MsgCall.ArgType)argTypeProp.intValue;
            MsgType         msgType = MsgType.Null;

            // If a message type has been selected, make sure to assign our argument type
            int msgTypeValueInt = msgTypeProp.FindPropertyRelative("m_Value").intValue;

            if (msgTypeValueInt != 0)
            {
                msgType = (MsgType)msgTypeValueInt;
                argType = MsgCallGetArgType(msgType, out argState);
            }
            else
            {
                argType = MsgCall.ArgType.Null;
            }

            // If the argument type changes, clear args
            if (argTypeProp.intValue != (int)argType)
            {
                argTypeProp.intValue = (int)argType;

                if (argState != ArgState.MissingType)
                {
                    MsgCallResetArgs(property);
                }
            }

            MsgTypeField(position, msgTypeProp, label, msgTypes);

            if (argType != MsgCall.ArgType.Null)
            {
                MsgEditorGUIUtility.AdvanceLine(ref position);
                MsgEditorGUIUtility.BeginIndent(ref position);

                Rect argsRect = position;

                if (argState == ArgState.Optional)
                {
                    argsRect.width -= 24;
                    Rect toggleRect = new Rect(position.x + argsRect.width + 4, position.y, 20, position.height);
                    sendArgsProp.boolValue = EditorGUI.Toggle(toggleRect, sendArgsProp.boolValue);
                }
                else
                {
                    sendArgsProp.boolValue = true;
                }

                GUI.enabled = sendArgsProp.boolValue;
                MsgCallArgsField(argsRect, property, msgType, argType);
                MsgEditorGUIUtility.EndIndent(ref position);
                GUI.enabled = true;
            }
        }
Exemplo n.º 7
0
        static public void MsgTypeField(Rect position, SerializedProperty property, GUIContent label, FilteredMsgTypeList msgTypes)
        {
            var valueProp   = property.FindPropertyRelative("m_Value");
            int currentHash = valueProp.intValue;

            EditorGUI.BeginChangeCheck();
            int currentIndex = msgTypes.FindIndexByHash(currentHash);
            int newIndex     = EditorGUI.Popup(position, label, currentIndex, msgTypes.PopupContent, EditorStyles.popup);

            if (EditorGUI.EndChangeCheck() && newIndex != currentIndex)
            {
                valueProp.intValue = msgTypes.FindHashByIndex(newIndex);
            }
        }
Exemplo n.º 8
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            FilteredMsgTypeList list = FilteredMsgTypeList.Filtered(s_CachedAttr);

            MsgEditorGUI.MsgCallField(position, property, label, list);
        }