protected override IPromise <string> OnCreate() { Promise <string> result = Promise <string> .Create(); Type linkType = fieldInfo.GetChildValueType(); if (fieldInfo != null) { LinkFilterAttribute filter = fieldInfo.GetCustomAttribute <LinkFilterAttribute>(); if (filter != null) { if (filter.interfaceType.IsInterface) { TypeSelectorWindow.Open(filter.interfaceType, "Choose implementation").Done(selectedType => { result.Resolve(CreateAsset(selectedType, linkType, fieldInfo)); }); } else { result.Resolve(CreateAsset(filter.interfaceType, linkType, fieldInfo)); } } else { result.Resolve(CreateAsset(type, linkType, fieldInfo)); } } else { result.Resolve(CreateAsset(type, linkType, fieldInfo)); } return(result); }
protected override IPromise <string> OnCreate() { Promise <string> promise = Promise <string> .Create(); Type interfaceToImplement = fieldInfo != null ? fieldInfo.GetCustomAttribute <LinkFilterAttribute>()?.interfaceType : null; List <System.Type> typesToChoose = new List <System.Type>(Util.GetAllTypes(t => t.IsGenericType == false && t.IsAbstract == false && t != type && type.IsAssignableFrom(t) && typeof(Object).IsAssignableFrom(t))); if (interfaceToImplement != null) { typesToChoose.RemoveAll(t => interfaceToImplement.IsAssignableFrom(t) == false); } TypeSelectorWindow.Open(typesToChoose, $"Choose {type.Name} implementation").Done(selectedType => { promise.Resolve(CreateAsset(selectedType, fieldInfo.GetChildValueType(), fieldInfo)); }); return(promise); }