/// <summary> /// Create the event and setup the values from the inspector /// </summary> /// <param name="iEvent"></param> /// <param name="lists"></param> /// <returns></returns> public static ReceiverBase GetReceiver(InteractableEvent iEvent, EventLists lists) { int index = InspectorField.ReverseLookup(iEvent.ClassName, lists.EventNames.ToArray()); Type eventType = lists.EventTypes[index]; // apply the settings? ReceiverBase newEvent = (ReceiverBase)Activator.CreateInstance(eventType, iEvent.Event); InspectorGenericFields <ReceiverBase> .LoadSettings(newEvent, iEvent.Settings); return(newEvent); }
/// <summary> /// Create the event and setup the values from the inspector /// </summary> public static ReceiverBase GetReceiver(InteractableEvent iEvent, InteractableTypesContainer interactableTypes) { #if UNITY_EDITOR int index = InspectorField.ReverseLookup(iEvent.ClassName, interactableTypes.ClassNames); Type eventType = interactableTypes.Types[index]; #else Type eventType = Type.GetType(iEvent.AssemblyQualifiedName); #endif // apply the settings? ReceiverBase newEvent = (ReceiverBase)Activator.CreateInstance(eventType, iEvent.Event); InspectorGenericFields <ReceiverBase> .LoadSettings(newEvent, iEvent.Settings); return(newEvent); }
/// <summary> /// Create the event and setup the values from the inspector /// </summary> public static ReceiverBase CreateReceiver(InteractableEvent iEvent) { // Temporary workaround // This is to fix a bug in GA where the AssemblyQualifiedName was never actually saved. Functionality would work in editor...but never on device player if (iEvent.ReceiverType == null) { var correctType = TypeCacheUtility.GetSubClasses <ReceiverBase>().Where(s => s?.Name == iEvent.ClassName).First(); iEvent.ReceiverType = correctType; } ReceiverBase newEvent = (ReceiverBase)Activator.CreateInstance(iEvent.ReceiverType, iEvent.Event); InspectorGenericFields <ReceiverBase> .LoadSettings(newEvent, iEvent.Settings); return(newEvent); }
public override void OnInspectorGUI() { serializedObject.Update(); // display the fields virtually as a custom inspector for (int i = 0; i < settings.arraySize; i++) { SerializedProperty prop = settings.GetArrayElementAtIndex(i); InspectorFieldsUtility.DisplayPropertyField(prop); } serializedObject.ApplyModifiedProperties(); // to apply during runtime - only needed for MonoBehaviours InspectorGenericFields <InspectorFieldsExample> .LoadSettings(example, example.Settings); }