/// <summary> /// Method to clone a GameObject of MmRoutingTableItem. /// </summary> /// <returns>Handle to the new GameObject.</returns> public GameObject CloneGameObject() { GameObject cloneGameObject = UnityEngine.GameObject.Instantiate(Responder.gameObject); Responder = cloneGameObject.GetComponent <MmRelayNode>(); return(cloneGameObject); }
/// <summary> /// Create an MmRoutingTableItem. /// </summary> /// <param name="name">Name of the MmRoutingTableItem</param> /// <param name="responder">Reference to the MmResponder to be stored.</param> /// <param name="clone">Whether to clone the MmResponder & GameObject /// or to use the original.</param> /// <param name="tags">Tags to apply to the MmRoutingTableItem.</param> public MmRoutingTableItem(string name, MmResponder responder, bool clone, MmTag tags) { Name = name; Responder = responder; Clone = clone; Tags = tags; }
/// <summary> /// Add an MmResponder to the MmRoutingTable, with level designation. /// </summary> /// <param name="mmResponder">MmResponder to be added.</param> /// <param name="newName">Name of MmResponder as it will appear in list.</param> /// <returns>Reference to new MmRoutingTable item.</returns> public virtual MmRoutingTableItem MmAddToRoutingTable(MmResponder mmResponder, string newName) { var level = (mmResponder.gameObject == gameObject) ? MmLevelFilter.Self : MmLevelFilter.Child; var routingTableItem = MmAddToRoutingTable(mmResponder, level); if (mmResponder is MmRelayNode) { (mmResponder as MmRelayNode).AddParent(this); } return(routingTableItem); }
/// <summary> /// Add an MmResponder to the MmRoutingTable, with level designation. /// </summary> /// <param name="mmResponder">MmResponder to be added.</param> /// <param name="level">Level designation of responder.</param> /// <returns>Reference to new MmRoutingTable item.</returns> public virtual MmRoutingTableItem MmAddToRoutingTable(MmResponder mmResponder, MmLevelFilter level) { var routingTableItem = new MmRoutingTableItem(mmResponder.name, mmResponder) { Level = level }; if (RoutingTable.Contains(mmResponder)) { return(null); // Already in list } //If there is an MmInvoke executing, add it to the // MmRespondersToAdd queue. if (doNotModifyRoutingTable) { MmRespondersToAdd.Enqueue(routingTableItem); } else { RoutingTable.Add(routingTableItem); } return(routingTableItem); }
/// <summary> /// Create an MmRoutingTableItem. /// </summary> /// <param name="name">Name of the MmRoutingTableItem</param> /// <param name="responder">Reference to the MmResponder to be stored.</param> public MmRoutingTableItem(string name, MmResponder responder) { Name = name; Responder = responder; }
/// <summary> /// Create an MmRoutingTableItem. /// </summary> /// <param name="name">Name of the MmRoutingTableItem</param> /// <param name="responder">Reference to the MmResponder to be stored.</param> /// <param name="clone">Whether to clone the MmResponder & GameObject /// or to use the original.</param> public MmRoutingTableItem(string name, MmResponder responder, bool clone) { Name = name; Responder = responder; Clone = clone; }
/// <summary> /// Accessor for MmRoutingTableItems by MmResponder reference. /// </summary> /// <param name="responder">MmResponder for which to search.</param> /// <returns>MmRoutingTableItem with reference or NULL.</returns> public MmRoutingTableItem this[MmResponder responder] { get { return(_list.Find(item => item.Responder == responder)); } }
/// <summary> /// Checks whether the MmRoutingTable contains an item with the /// provided MmResponder reference. /// </summary> /// <param name="responder">MmResponder for which to search.</param> /// <returns>Whether the MmRoutingTable contains an item with the /// provided MmResponder reference.</returns> public bool Contains(MmResponder responder) { return(this[responder] != null); }
/// <summary> /// Draw method for MmBehaviorListItemDrawer. /// </summary> /// <param name="position"></param> /// <param name="property"></param> /// <param name="label"></param> public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { int oldIndentLevel = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; label = EditorGUI.BeginProperty(position, label, property); Rect contentPosition = EditorGUI.PrefixLabel(position, label); /* * if (position.height > 16f) { * position.height = 16f; * EditorGUI.indentLevel += 1; * contentPosition = EditorGUI.IndentedRect(position); * contentPosition.y += 18f; * } */ var originalWidth = contentPosition.width; var remainingWidth = originalWidth; /*---------------------------*/ contentPosition.width = (originalWidth - (FieldWidthClone + FieldWidthLevel + FieldWidthTags)) / 2f; SerializedProperty behaviorProperty = property.FindPropertyRelative("Responder"); var level = property.FindPropertyRelative("Level"); var listItemName = property.FindPropertyRelative("Name"); EditorGUI.BeginChangeCheck(); EditorGUI.PropertyField( contentPosition, behaviorProperty, GUIContent.none); if (EditorGUI.EndChangeCheck()) { MmResponder responderObj = behaviorProperty.objectReferenceValue as System.Object as MmResponder; if (responderObj != null) { MonoBehaviour containerObj = property.serializedObject.targetObject as MonoBehaviour; //Get Name & Tag from the assigned object and apply it as the name of the object. listItemName.stringValue = responderObj.gameObject.name; //Get the reference of the list owner's WFNode for comparison. //Then, assign the level based on whether this is the same object, or a different one. MmLevelFilter levelFilterValue = MmLevelFilter.Self; if (responderObj.gameObject == containerObj.gameObject) { levelFilterValue = MmLevelFilter.Self; } else { levelFilterValue = MmLevelFilter.Child; } level.enumValueIndex = Array.IndexOf(Enum.GetValues(typeof(MmLevelFilter)), levelFilterValue); } } remainingWidth -= contentPosition.width; contentPosition.x += contentPosition.width; /*---------------------------*/ contentPosition.width = (originalWidth - (FieldWidthClone + FieldWidthLevel + FieldWidthTags)) / 2f; // (Same as above) EditorGUI.PropertyField( contentPosition, listItemName, GUIContent.none); remainingWidth -= contentPosition.width; contentPosition.x += contentPosition.width; /*---------------------------*/ contentPosition.width = FieldWidthLevel; //Level EditorGUI.LabelField( contentPosition, new GUIContent(level.enumValueIndex != -1 ? level.enumNames[level.enumValueIndex] : "None"), EditorStyles.label); remainingWidth -= contentPosition.width; contentPosition.x += contentPosition.width; /*---------------------------*/ contentPosition.width = FieldWidthClone; EditorGUI.PropertyField( contentPosition, property.FindPropertyRelative("Clone"), GUIContent.none); remainingWidth -= contentPosition.width; contentPosition.x += contentPosition.width; /*---------------------------*/ contentPosition.width = FieldWidthTags; EditorGUI.PropertyField( contentPosition, property.FindPropertyRelative("Tags"), GUIContent.none); remainingWidth -= contentPosition.width; contentPosition.x += contentPosition.width; EditorGUI.EndProperty(); EditorGUI.indentLevel = oldIndentLevel; }