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); }
/// <summary> /// Create the event and setup the values from the inspector. If the asset is invalid, /// returns null. /// </summary> public static ReceiverBase CreateReceiver(InteractableEvent iEvent) { if (string.IsNullOrEmpty(iEvent.ClassName)) { // If the class name of this event is empty, the asset is invalid and loading types will throw errors. Return null. return(null); } // 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); }