コード例 #1
0
    private IEnumerator ParseSpecificFiles()
    {
        //Read files list
        var info     = new DirectoryInfo(bag3DSourceFilesFolder);
        var fileInfo = info.GetFiles(filter);

        print("Found " + fileInfo.Length + " obj files.");
        //First create gameobjects for all the buildigns we parse
        int parsed = 0;

        for (int i = 0; i < fileInfo.Length; i++)
        {
            var file = fileInfo[i];
            print(parsed + "/" + fileInfo.Length + " " + file.Name);

            var objString = File.ReadAllText(file.FullName);

            //Start a new ObjLoader
            if (objLoader)
            {
                Destroy(objLoader);
            }
            objLoader = this.gameObject.AddComponent <ObjLoad>();
            objLoader.ObjectUsesRDCoordinates = true;
            objLoader.MaxSubMeshes            = 1;
            objLoader.SplitNestedObjects      = true;
            objLoader.FlipFaceDirection       = true;
            objLoader.SetGeometryData(ref objString);

            var objLinesToBeParsed = 100;
            while (objLinesToBeParsed > 0)
            {
                objLinesToBeParsed = objLoader.ParseNextObjLines(parsePerFrame);
                print(objLinesToBeParsed + " obj lines remaining");
                yield return(new WaitForEndOfFrame());
            }
            objLoader.Build(applyMaterial);

            yield return(new WaitForEndOfFrame());
        }

        RemapObjectNamesAndCleanUp();

        if (enableOnFinish)
        {
            enableOnFinish.SetActive(true);
        }
    }
コード例 #2
0
 private void Start()
 {
     objLoader = this.gameObject.AddComponent <ObjLoad>();
     StartCoroutine(ParseSpecificFiles());
 }