Example #1
0
        public void ConvertAvatarToObjFormat()
        {
            var    haircutRecoloring = GetComponent <HaircutRecoloring>();
            string haircutName       = string.Empty;

            if (avatarHaircuts != null && string.Compare(avatarHaircuts[currentHaircut], BALD_HAIRCUT_NAME) != 0)
            {
                haircutName = avatarHaircuts[currentHaircut];
            }

            var outputObjDir  = AvatarSdkMgr.Storage().GetAvatarSubdirectory(currentAvatarCode, AvatarSubdirectory.OBJ_EXPORT);
            var outputObjFile = Utils.CombinePaths(outputObjDir, "model.obj");

            CoreTools.AvatarPlyToObj(currentAvatarCode, AvatarFile.MESH_PLY, AvatarFile.TEXTURE, outputObjFile);

            if (!string.IsNullOrEmpty(haircutName))
            {
                var haircutObjFile = Path.Combine(Path.GetDirectoryName(outputObjFile), HaircutIdToFileName(haircutName, "obj"));
                CoreTools.HaircutPlyToObj(currentAvatarCode, haircutName, haircutObjFile, haircutRecoloring.CurrentColor, haircutRecoloring.CurrentTint);
            }

#if UNITY_EDITOR || UNITY_STANDALONE_WIN
            System.Diagnostics.Process.Start(outputObjDir);
#else
            progressText.text = string.Format("OBJ file was saved to avatar directory");
#endif
        }