private static void CacheDisplayTypes() { if (cachedTypeToDisplayName != null) { return; } cachedTypeToDisplayName = new Dictionary <Type, GUIContent>(); cachedTypeToInstance = new Dictionary <Type, GUIContent>(); typeToInstanceCache = new Dictionary <Type, DOTweenActionBase>(); List <Type> types = TypeUtility.GetAllSubclasses(typeof(DOTweenActionBase)); for (int i = 0; i < types.Count; i++) { Type type = types[i]; if (type.IsAbstract) { continue; } DOTweenActionBase doTweenActionBaseInstance = Activator.CreateInstance(type) as DOTweenActionBase; if (doTweenActionBaseInstance == null) { continue; } GUIContent guiContent = new GUIContent(doTweenActionBaseInstance.DisplayName); if (doTweenActionBaseInstance.TargetComponentType != null) { GUIContent targetComponentGUIContent = EditorGUIUtility.ObjectContent(null, doTweenActionBaseInstance.TargetComponentType); guiContent.image = targetComponentGUIContent.image; GUIContent parentGUIContent = new GUIContent(doTweenActionBaseInstance.TargetComponentType.Name) { image = targetComponentGUIContent.image }; cachedTypeToInstance.Add(type, parentGUIContent); } cachedTypeToDisplayName.Add(type, guiContent); typeToInstanceCache.Add(type, doTweenActionBaseInstance); } }
public List <DOTweenActionBase> GetDOTweenActionsThatUseComponent <T>() where T : Component { List <DOTweenAnimationStep> dotweenSteps = GetStepsOfType <DOTweenAnimationStep>(); List <DOTweenActionBase> results = new List <DOTweenActionBase>(); for (int i = 0; i < dotweenSteps.Count; i++) { DOTweenAnimationStep doTweenAnimationStep = dotweenSteps[i]; for (int j = 0; j < doTweenAnimationStep.Actions.Length; j++) { DOTweenActionBase actionBase = doTweenAnimationStep.Actions[j]; if (actionBase.TargetComponentType == typeof(T)) { results.Add(actionBase); } } } return(results); }