private void OnComponentAdded(ReorderableList list) { // Create the generic menu GenericMenu componentMenu = new GenericMenu(); // Get all the types that inherit from Weaver Component IList <Type> componentTypes = AssemblyUtility.GetInheirtingTypesFromUserAssemblies <WeaverComponent>(); // Loop over them all for (int i = 0; i < componentTypes.Count; i++) { Type type = componentTypes[i]; // Check if we already have that type if (m_HasInstanceOfTypeMethod.Invoke(type).AreEqual(false)) { GUIContent menuLabel = new GUIContent(type.Assembly.GetName().Name + "/" + type.Name); componentMenu.AddItem(menuLabel, false, OnTypeAdded, type); } } if (componentMenu.GetItemCount() == 0) { componentMenu.AddDisabledItem(new GUIContent("[All Components Added]")); } // We are just trying to align the menu to the plus box. Rect menuDisplayRect = m_Position; menuDisplayRect.height = EditorGUIUtility.singleLineHeight; menuDisplayRect.y += m_Position.height - EditorGUIUtility.singleLineHeight; menuDisplayRect.x += EditorGUIUtility.currentViewWidth - 100; componentMenu.DropDown(menuDisplayRect); }
private void OnComponentRemoved(ReorderableList list) { Object removedObject = m_SubObjects.GetArrayElementAtIndex(list.index).objectReferenceValue; if (removedObject != null) { string removedElementType = removedObject.GetType().FullName; } m_RemoveItemMethod.Invoke(list.index); OnComponentAddedOrRemoved(); }
private void OnTypeAdded(object argument) { WeaverAnalytics.SendEvent("Components", "Added", ((Type)argument).FullName); m_AddItemMethod.Invoke(argument); OnComponentAddedOrRemoved(); }
private void OnTypeAdded(object argument) { m_AddItemMethod.Invoke(argument); OnComponentAddedOrRemoved(); }