private static bool OkToAdd(List <ScriptableObject> items, ScriptableObject item) { if (!item) { Debug.LogError("Can't set item to none."); return(false); } if (!(item is IInputBuildProcessor)) { Debug.LogError(string.Format("{0} does not implement {1}." , item.name, typeof(IInputBuildProcessor).Name)); return(false); } if (items.Contains(item)) { Debug.LogError(item.name + " already in the processor list."); return(false); } IInputBuildProcessor pa = (IInputBuildProcessor)item; if (pa.DuplicatesAllowed) { return(true); } foreach (ScriptableObject itemB in items) { IInputBuildProcessor pb = (IInputBuildProcessor)itemB; if (pb.DuplicatesAllowed) { continue; } System.Type ta = pb.GetType(); System.Type tb = pa.GetType(); if (ta.IsAssignableFrom(tb) || tb.IsAssignableFrom(ta)) { Debug.LogError(string.Format( "Disallowed dulicate detected. {0} and {1} are same type." , pa.Name, pb.Name)); return(false); } } return(true); }
public static InputBuilder Create(ISceneQuery filter , IInputBuildProcessor[] processors , InputBuildOption options) { IInputBuildProcessor[] lprocessors = ArrayUtil.Compress(processors); if (lprocessors == null || lprocessors.Length == 0) { return(null); } for (int i = lprocessors.Length - 1; i >= 0; i--) { IInputBuildProcessor processor = lprocessors[i]; if (processor.DuplicatesAllowed) { continue; } System.Type ta = processor.GetType(); for (int j = i - 1; j >= 0; j--) { System.Type tb = lprocessors[j].GetType(); if (ta.IsAssignableFrom(tb) || tb.IsAssignableFrom(ta)) { return(null); } } } if (lprocessors == processors) { lprocessors = (IInputBuildProcessor[])lprocessors.Clone(); } InputBuildContext context = new InputBuildContext(filter, options); return(new InputBuilder(context, lprocessors)); }