public static RandomnessDescriptor OnInspectorGUI(GUIContent label, RandomnessDescriptor randomness) { var priorIndentLevel = EditorGUI.indentLevel; if (!string.IsNullOrEmpty(label.text)) { EditorGUILayout.LabelField(label); EditorGUI.indentLevel += 1; } randomness.randomType = (RandomnessDescriptor.RandomType)EditorGUILayout.EnumPopup("RNG Type", randomness.randomType); var priorSeedSource = randomness.seedSource; randomness.seedSource = (RandomnessDescriptor.SeedSource)EditorGUILayout.EnumPopup("Seed Source", randomness.seedSource); switch (priorSeedSource) { case RandomnessDescriptor.SeedSource.Random: case RandomnessDescriptor.SeedSource.RandomAndSystemTime: case RandomnessDescriptor.SeedSource.RandomAndNumerical: case RandomnessDescriptor.SeedSource.RandomAndTextual: InputSlotEditor.OnInspectorGUI(new GUIContent("Seeder"), randomness.randomSeedInputSlot, InputSlot.ShouldAutoSelect(randomness, "randomSeedInputSlot")); break; } switch (priorSeedSource) { case RandomnessDescriptor.SeedSource.Numerical: case RandomnessDescriptor.SeedSource.RandomAndNumerical: randomness.seedNumber = EditorGUILayout.IntField("Seed Number", randomness.seedNumber); break; case RandomnessDescriptor.SeedSource.Textual: case RandomnessDescriptor.SeedSource.RandomAndTextual: randomness.seedText = EditorGUILayout.TextField("Seed Text", randomness.seedText); break; } EditorGUI.indentLevel = priorIndentLevel; return(randomness); }
protected virtual void OnPropertiesGUI() { var generatorType = _generator.GetType(); var property = _serializedGenerator.GetIterator(); if (property.NextVisible(true)) { do { var field = generatorType.GetField(property.name); if (field == null) { continue; } if (field.FieldType == typeof(OutputSlot)) { continue; } if (field.FieldType == typeof(OutputSlot[])) { continue; } if (field.FieldType == typeof(List <OutputSlot>)) { continue; } if (!IsInAssetGeneratorSubclass(field)) { continue; } var labelAttribute = GeneralUtility.GetAttribute <LabelAttribute>(field); var labelContent = new GUIContent( labelAttribute != null ? labelAttribute.text : property.displayName, property.tooltip); if (field.FieldType == typeof(InputSlot)) { var input = (InputSlot)field.GetValue(property.serializedObject.targetObject); if (input.isActive) { InputSlotEditor.OnInspectorGUI(labelContent, input, InputSlot.ShouldAutoSelect(field)); } } else if (field.FieldType == typeof(RandomnessDescriptor)) { var randomness = (RandomnessDescriptor)field.GetValue(property.serializedObject.targetObject); randomness = RandomnessDescriptorEditor.OnInspectorGUI(labelContent, randomness); field.SetValue(property.serializedObject.targetObject, randomness); } else if (typeof(Component).IsAssignableFrom(field.FieldType)) { field.SetValue(property.serializedObject.targetObject, EditorGUILayoutExtensions.ObjectField(labelContent, property.objectReferenceValue, field.FieldType, false)); } else { EditorGUILayout.PropertyField(property, labelContent, true); } } while (property.NextVisible(false)); } }