Пример #1
0
    public void RemoveConnection(EditorObject subject, EditorObject caller)
    {
        EditorObjectConnection connectionToRemove = ContainsConnection(subject, caller);

        if (connectionToRemove != null)
        {
            Registry.Remove(connectionToRemove);
        }
        else
        {
            Debug.LogWarning(string.Format("Attempted to remove a connection between {0} and {1}, but a connection does not exist", subject.ToString(), caller.ToString()), this);
        }
    }
Пример #2
0
    public EditorObjectConnection ContainsConnection(EditorObject subject, EditorObject caller)
    {
        EditorObjectConnection testConnection = null;

        foreach (EditorObjectConnection connection in Registry)
        {
            if (connection.Subject == subject && connection.Caller == caller)
            {
                testConnection = connection;
            }
        }

        return(testConnection);
    }
Пример #3
0
    void DrawConnectionBoxes()
    {
        //SerializedProperty infoScrollPos = serializedObject.FindProperty("InfoScrollPos");
        Target.InfoScrollPos = GUILayout.BeginScrollView(Target.InfoScrollPos, false, true, GUI.skin.horizontalScrollbar, GUI.skin.verticalScrollbar, GUI.skin.textArea, GUILayout.Width(kConnectionScrollAreaWidth));
        //serializedObject.ApplyModifiedProperties();

        //GUILayout.BeginHorizontal();

        //Vector3 origin = Vector3.zero;
        //origin.x += _editorWindowWidth;

        if (ConnectionRegistry.DesignInstance.Registry.Count <= 0)
        {
            //do nothing
        }
        else
        {
            for (int i = (ConnectionRegistry.DesignInstance.Registry.Count - 1); i >= 0; i--)
            {
                EditorObjectConnection connection = ConnectionRegistry.DesignInstance.Registry[i];

                if (connection == null || connection.Caller != Target)
                {
                    continue;
                }
//					else if(connection.OnEvent.ToString() != Target.AssociatedEvents[_toolbarInt].ToString())
//					{
//						continue;
//					}

                DrawConnectionBox(connection.MessageColor, connection, Vector3.zero);
                //origin.x += 192;
            }
        }

        GUI.color = Color.green;

        //_target.LookingForSubject = GUILayout.Toggle(_target.LookingForSubject, "Add", GrendelCustomStyles.CustomElement(GUI.skin.button, Color.green, Color.white, TextAnchor.MiddleCenter, FontStyle.Bold));

        //GUILayout.EndHorizontal();


        GUILayout.EndScrollView();
    }
Пример #4
0
    public void AddConnection(EditorObject subject, EditorObject caller, EditorObject.EditorObjectMessage message, EventTransceiver.Events onEvent)
    {
        if (ContainsConnection(subject, caller) == null)
        {
            EditorObjectConnection newConnection = EditorObjectConnection.CreateInstance <EditorObjectConnection>();

            newConnection.Message = message;
            newConnection.Caller  = caller;
            newConnection.Subject = subject;
            newConnection.OnEvent = onEvent;

            Registry.Add(newConnection);
            Registry.Sort(_comparer);
        }
        else
        {
            Debug.LogWarning(string.Format("Attempted to add a connection between {0} and {1}, but a connection already exists", subject.ToString(), caller.ToString()), this);
        }
    }
Пример #5
0
 public void AddCaller(EditorObjectConnection connection)
 {
     if (_callerRegistry.ContainsKey(connection.Caller))
     {
         _callerRegistry[connection.Caller] = connection.Message;
     }
     else
     {
         _callerRegistry.Add(connection.Caller, connection.Message);
     }
 }
Пример #6
0
    void DrawConnectionBox(Color color, EditorObjectConnection editorObjectConnection, Vector3 origin)
    {
        //int connectionWidth = 192;
        GUI.color = color;

        //Rect boxRect = new Rect(origin.x, origin.y, 192, 64);


        //Event e = Event.current;

//		if (boxRect.Contains(e.mousePosition))
//		{
//			editorObjectConnection.Subject.HighlightHighlight = true;
//		}

        if (editorObjectConnection.Subject.HighlightHighlight)
        {
            GUI.color = Color.cyan;
        }

        //GUILayout.BeginArea(boxRect, GrendelCustomStyles.CustomElement(GUI.skin.textArea, color, Color.white,TextAnchor.UpperCenter));

        GUILayout.BeginHorizontal(GUI.skin.textArea);

        //editorObjectConnection.Message = (EditorObject.EditorObjectMessage)EditorGUILayout.EnumPopup(editorObjectConnection.Message);
        SerializedObject   connectionSerialized = new SerializedObject(editorObjectConnection);
        SerializedProperty eventSerialized      = connectionSerialized.FindProperty("OnEvent");
        SerializedProperty messageSerialized    = connectionSerialized.FindProperty("Message");


        string[] eventChoices = new string[Target.AssociatedEvents.Length];
        foreach (EventTransceiver.Events evt in Target.AssociatedEvents)
        {
            eventChoices[(int)evt] = evt.ToString();
        }



        eventSerialized.enumValueIndex   = EditorGUILayout.Popup(eventSerialized.enumValueIndex, eventChoices, EditorStyles.toolbarPopup, GUILayout.Width(128));
        messageSerialized.enumValueIndex = EditorGUILayout.Popup(messageSerialized.enumValueIndex, messageSerialized.enumNames, EditorStyles.toolbarPopup, GUILayout.Width(128));



        //GUILayout.BeginHorizontal();
        //GUILayout.BeginVertical();
        //GUILayout.FlexibleSpace();
        if (GUILayout.Button(editorObjectConnection.Subject.ToString(), GrendelCustomStyles.CustomElement(GUI.skin.button, color, Color.white, TextAnchor.MiddleLeft), GUILayout.Width(256)))
        {
            Selection.activeGameObject = editorObjectConnection.Subject.gameObject;
        }
        //	GUILayout.Label(editorObjectConnection.Subject.name, GrendelCustomStyles.CustomElement(GUI.skin.label, color, Color.white,TextAnchor.MiddleLeft));
        //GUILayout.FlexibleSpace();
        //GUILayout.EndVertical();
        //GUILayout.FlexibleSpace();
        //GUILayout.BeginVertical();

        if (GUILayout.Button("Del", GrendelCustomStyles.CustomElement(GUI.skin.button, color, Color.white, TextAnchor.MiddleCenter), GUILayout.Width(32)))
        {
            //_target.RemoveConnection(editorObjectConnection);
            ConnectionRegistry.DesignInstance.Registry.Remove(editorObjectConnection);
            EditorUtility.SetDirty(ConnectionRegistry.DesignInstance);
        }

//				if( GUILayout.Button("Sel", GrendelCustomStyles.CustomElement(GUI.skin.button, Color.grey, Color.white, TextAnchor.MiddleCenter), GUILayout.Width(32)) )
//				{
//					Selection.activeGameObject = editorObjectConnection.Subject.gameObject;
//				}
        connectionSerialized.ApplyModifiedProperties();
        //GUILayout.EndVertical();

        //GUILayout.EndHorizontal();

        GUILayout.EndHorizontal();

        Rect boxRect = GUILayoutUtility.GetLastRect();

        Event e = Event.current;

        if (boxRect.Contains(e.mousePosition))
        {
            editorObjectConnection.Subject.HighlightHighlight = true;
        }
        else
        {
            //editorObjectConnection.Subject.HighlightHighlight = false;
        }
        //GUILayout.EndArea();

        GUI.color = Color.white;
    }