Object ValidateAvatarSource(Object[] references, Type objType, SerializedProperty property, EditorGUI.ObjectFieldValidatorOptions options) { if (references.Length == 0) { return(null); } string avatarPath = AssetDatabase.GetAssetPath(references[0]); foreach (AssetImporter importer in targets) { if (avatarPath == importer.assetPath) { return(null); } } return(references[0]); }
static Object ValidateObjectForPackableFieldAssignment(Object[] references, System.Type objType, SerializedProperty property, EditorGUI.ObjectFieldValidatorOptions options) { // We only validate and care about the first one as this is a object field assignment. if (references.Length > 0 && IsPackable(references[0])) { return(references[0]); } return(null); }
static Object MonoScriptValidatorCallback(Object[] references, System.Type objType, SerializedProperty property, EditorGUI.ObjectFieldValidatorOptions options) { foreach (Object i in references) { var monoScript = i as MonoScript; if (monoScript != null && IsValidScript(monoScript)) { return(monoScript); } } return(null); }
private static UnityEngineObject ValidateAudioSource(UnityEngineObject[] references, Type objtype, SerializedProperty property, EditorGUI.ObjectFieldValidatorOptions options) { foreach (var reference in references) { if (reference == null || IsPersistent(reference)) { continue; } if (reference is AudioSource) { return(reference); } if (reference is GameObject gameObject && gameObject.TryGetComponent <AudioSource>(out _)) { return(gameObject); } } return(null); }
Object PresetFieldDropValidator(Object[] references, Type objType, SerializedProperty property, EditorGUI.ObjectFieldValidatorOptions options) { if (references.Length == 1) { var preset = references[0] as Preset; string propertyPath = property.propertyPath; var numberStart = propertyPath.IndexOf("[") + 1; var numberLenght = propertyPath.IndexOf("]") - numberStart; var propertyPosition = int.Parse(propertyPath.Substring(numberStart, numberLenght)); if (preset != null && target.GetPresetTypeNameAtIndex(propertyPosition) == preset.GetTargetFullTypeName()) { return(references[0]); } } return(null); }
private UnityEngine.Object PresetFieldDropValidator(UnityEngine.Object[] references, Type objType, SerializedProperty property, EditorGUI.ObjectFieldValidatorOptions options) { UnityEngine.Object result; if (references.Length == 1) { Preset preset = references[0] as Preset; string propertyPath = property.propertyPath; int num = propertyPath.IndexOf("[") + 1; int length = propertyPath.IndexOf("]") - num; int index = int.Parse(propertyPath.Substring(num, length)); if (preset != null && this.target.GetPresetTypeNameAtIndex(index) == preset.GetTargetFullTypeName()) { result = references[0]; return(result); } } result = null; return(result); }
private static UnityEngine.Object MonoScriptValidatorCallback(UnityEngine.Object[] references, Type objType, SerializedProperty property, EditorGUI.ObjectFieldValidatorOptions options) { UnityEngine.Object result; for (int i = 0; i < references.Length; i++) { UnityEngine.Object @object = references[i]; MonoScript monoScript = @object as MonoScript; if (monoScript != null && ScriptExecutionOrderInspector.IsValidScript(monoScript)) { result = monoScript; return(result); } } result = null; return(result); }
private static UnityEngine.Object ValidateObjectForPackableFieldAssignment(UnityEngine.Object[] references, Type objType, SerializedProperty property, EditorGUI.ObjectFieldValidatorOptions options) { UnityEngine.Object result; if (references.Length > 0 && SpriteAtlasInspector.IsPackable(references[0])) { result = references[0]; } else { result = null; } return(result); }