public static IEnumerator ImportDTURoutine(string path, Action <DTU> dtuOut, float progressLimit)
        {
            Debug.Log("ImportDTU for " + path);

            FoldAll();

            ImportEventRecord record = new ImportEventRecord();

            EventQueue.Enqueue(record);

            var dtu = DTUConverter.ParseDTUFile(path);

            dtuOut(dtu);

            var dtuObject = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(path);

            record.AddToken("Imported DTU file: " + path);
            record.AddToken(dtuObject.name, dtuObject, ENDLINE);

            //UnityEngine.Debug.Log("DTU: " + dtu.AssetName + " contains: " + dtu.Materials.Count + " materials");


            record.AddToken("Generated materials: ");
            float progressIncrement = (progressLimit - Daz3DBridge.Progress) / dtu.Materials.Count;

            for (int i = 0; i < dtu.Materials.Count; i++)
            {
                var dtuMat   = dtu.Materials[i];
                var material = dtu.ConvertToUnity(dtuMat);
                _map.AddMaterial(material);

                record.AddToken(material.name, material);

                Daz3DBridge.Progress = Mathf.MoveTowards(Daz3DBridge.Progress, progressLimit, progressIncrement);

                yield return(new WaitForEndOfFrame());
            }
            record.AddToken(" based on DTU file.", null, ENDLINE);


            Daz3DBridge bridge = EditorWindow.GetWindow(typeof(Daz3DBridge)) as Daz3DBridge;

            if (bridge == null)
            {
                var consoleType = Type.GetType("ConsoleWindow,UnityEditor.dll");
                bridge = EditorWindow.CreateWindow <Daz3DBridge>(new[] { consoleType });
            }

            bridge?.Focus();

            //just a safeguard to keep the history data at a managable size (100 records)
            while (EventQueue.Count > 100)
            {
                EventQueue.Dequeue();
            }

            yield break;
        }
        public static void ImportDTU(string path)
        {
            Debug.Log("ImportDTU for " + path);

            FoldAll();

            ImportEventRecord record = new ImportEventRecord();

            EventQueue.Enqueue(record);

            var dtu = DTUConverter.ParseDTUFile(path);

            var dtuObject = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(path);

            record.AddToken("Imported DTU file: " + path);
            record.AddToken(dtuObject.name, dtuObject, ENDLINE);

            //UnityEngine.Debug.Log("DTU: " + dtu.AssetName + " contains: " + dtu.Materials.Count + " materials");

            record.AddToken("Generated materials: ");
            foreach (var dtuMat in dtu.Materials)
            {
                var material = dtu.ConvertToUnity(dtuMat);
                _map.AddMaterial(material);

                record.AddToken(material.name, material);
            }
            record.AddToken(" based on DTU file.", null, ENDLINE);


            Daz3DBridge bridge = EditorWindow.GetWindow(typeof(Daz3DBridge)) as Daz3DBridge;

            if (bridge == null)
            {
                var consoleType = Type.GetType("ConsoleWindow,UnityEditor.dll");
                bridge = EditorWindow.CreateWindow <Daz3DBridge>(new[] { consoleType });
            }

            bridge?.Focus();

            //just a safeguard to keep the history data at a managable size (100 records)
            while (EventQueue.Count > 100)
            {
                EventQueue.Dequeue();
            }
        }
Esempio n. 3
0
 private static void ObtainInstance()
 {
     _instance = (Daz3DBridge)GetWindow(typeof(Daz3DBridge));
     _instance.titleContent = new GUIContent("Daz to Unity Bridge");
 }