private InputBuilder(InputBuildContext context, IInputBuildProcessor[] processors) { mContext = context; mInputProcessors = processors; System.Array.Sort(mInputProcessors, new PriorityComparer<IInputBuildProcessor>(true)); mState = InputBuildState.LoadComponents; }
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)); }
internal IInputBuildProcessor[] GetInputProcessors() { // May contain nulls due to asset deletions. So clean things up. for (int i = inputProcessors.Count - 1; i >= 0; i--) { if (!inputProcessors[i]) { inputProcessors.RemoveAt(i); mIsDirty = true; } } IInputBuildProcessor[] result = new IInputBuildProcessor[inputProcessors.Count]; // Assumption: The editor is properly controlling additions to the list. for (int i = 0; i < result.Length; i++) { result[i] = (IInputBuildProcessor)inputProcessors[i]; } return(result); }
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); }