using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace BrainFailProductions.PolyFew.AsImpL { /// /// Load the objects in the given list with their parameters and positions. /// public class MultiObjectImporter : ObjectImporter { [Tooltip("Load models in the list on start")] public bool autoLoadOnStart = false; [Tooltip("Models to load on startup")] public List objectsList = new List(); [Tooltip("Default import options")] public ImportOptions defaultImportOptions = new ImportOptions(); [SerializeField] private PathSettings pathSettings = null; public string RootPath { get { return pathSettings != null ? pathSettings.RootPath : ""; } } /// /// Load a set of files with their own import options /// /// List of file import entries public void ImportModelListAsync(ModelImportInfo[] modelsInfo) { if (modelsInfo == null) { return; } for (int i = 0; i < modelsInfo.Length; i++) { if (modelsInfo[i].skip) continue; string objName = modelsInfo[i].name; string filePath = modelsInfo[i].path; if (string.IsNullOrEmpty(filePath)) { Debug.LogErrorFormat("File path missing for the model at position {0} in the list.", i); continue; } filePath = RootPath + filePath; ImportOptions options = modelsInfo[i].loaderOptions; if (options == null || options.modelScaling == 0) { options = defaultImportOptions; } #pragma warning disable ImportModelAsync(objName, filePath, transform, options); } } /// /// Import the list of objects in objectList. /// protected virtual void Start() { if (autoLoadOnStart) { ImportModelListAsync(objectsList.ToArray()); } } } }