private void UpdateObject(GameObject gameObj, ModelImportInfo importInfo)
 {
     gameObj.name = importInfo.name;
     //game_object.transform.localScale = scale;
     if (importInfo.loaderOptions != null)
     {
         gameObj.transform.localPosition = importInfo.loaderOptions.localPosition;
         gameObj.transform.localRotation = Quaternion.Euler(importInfo.loaderOptions.localEulerAngles);
         gameObj.transform.localScale    = importInfo.loaderOptions.localScale;
     }
 }
 private void UpdateObjectList()
 {
     for (int i = 0; i < transform.childCount; i++)
     {
         Transform       tr   = transform.GetChild(i);
         ModelImportInfo info = objectsList.Find(obj => obj.name == tr.name);
         if (info != null)
         {
             UpdateImportInfo(info, tr.gameObject);
         }
     }
 }
        private void UpdateImportInfo(ModelImportInfo importInfo, GameObject gameObj)
        {
            importInfo.name = gameObj.name;
            if (importInfo.loaderOptions == null)
            {
                importInfo.loaderOptions = new ImportOptions();
            }

            importInfo.loaderOptions.localPosition    = gameObj.transform.localPosition;
            importInfo.loaderOptions.localEulerAngles = gameObj.transform.localRotation.eulerAngles;
            importInfo.loaderOptions.localScale       = gameObj.transform.localScale;
        }
Esempio n. 4
0
        /// <summary>
        /// Import the list of objects in objectList.
        /// </summary>
        protected virtual void Start()
        {
            string texto;
            string arquivo;

            if (autoLoadOnStart)
            {
                //variaveis
                arquivo = "Models.txt";
                Debug.Log(arquivo);
                BetterStreamingAssets.Initialize();
                texto = BetterStreamingAssets.ReadAllText(arquivo);
                int[] separacoes = new int[2];
                int   i = 0, cont = 0;
                //carregar a lista de objectos a importar
                do
                {
                    separacoes[0] = i;
                    Debug.Log("Entrou com cont = " + cont);
                    //pega o endereco do modelo
                    for (int j = 0; i < texto.Length && j < 8; i++)
                    {
                        if (texto[i] == '\n' || texto[i] == ' ')
                        {
                            if (j < 1)
                            {
                                separacoes[1] = i;
                            }
                            //Debug.Log(separacoes[j]);
                            j++;
                        }
                    }

                    //configura para carregar o modelo
                    ModelImportInfo mii = new ModelImportInfo();
                    mii.name = "object" + cont;
                    this.objectsList.Add(mii);
                    this.objectsList[cont].path = texto.Substring(separacoes[0], separacoes[1] - separacoes[0] - 1);
                    if (objectsList[cont].path[objectsList[cont].path.Length - 1] == 10)
                    {
                        objectsList[cont].path = objectsList[cont].path.Substring(0, objectsList[cont].path.Length - 2);
                    }
                    cont++;
                } while (i < texto.Length);

                //importar os  modelos
                ImportModelListAsync(objectsList.ToArray());
            }
        }
Esempio n. 5
0
        public void ImportModelListAsync(ModelImportInfo modelsInfo)
        {
            if (modelsInfo == null & modelsInfo.skip)
            {
                return;
            }
            string objName  = modelsInfo.name;
            string filePath = modelsInfo.path;

            if (string.IsNullOrEmpty(filePath))
            {
                return;
            }
            filePath = RootPath + filePath;
            ImportOptions options = modelsInfo.loaderOptions;

            if (options == null || options.modelScaling == 0)
            {
                options = defaultImportOptions;
            }
            ImportModelAsync(objName, filePath, transform, options);
        }