Esempio n. 1
0
        // File serialization
        public Mesh saveMesh(Mesh mesh, string objectName = "Scene")
        {
            string baseName        = GLTFUtils.cleanName(objectName + ".asset");
            string fullPath        = Path.Combine(_importMeshesDirectory, baseName);
            string meshProjectPath = GLTFUtils.getPathProjectFromAbsolute(fullPath);

            serializeAsset(mesh, meshProjectPath, fullPath, true);
            return(AssetDatabase.LoadAssetAtPath(meshProjectPath, typeof(Mesh)) as Mesh);
        }
Esempio n. 2
0
        public Texture2D saveTexture(Texture2D texture, int index = -1, string imageName = "")
        {
            string basename = GLTFUtils.cleanName(texture.name + (index >= 0 ? "_" + index.ToString() : "") + ".png"); // Extension will be overridden
            string fullPath = Path.Combine(_importTexturesDirectory, basename);

            // Write texture
            string newAssetPath = GLTFTextureUtils.writeTextureOnDisk(texture, fullPath, true);

            // Reload as asset
            string    projectPath = GLTFUtils.getPathProjectFromAbsolute(newAssetPath);
            Texture2D tex         = (Texture2D)AssetDatabase.LoadAssetAtPath(projectPath, typeof(Texture2D));

            _parsedImages.Add(tex);
            return(tex);
        }
Esempio n. 3
0
 public string getPrefabName(string sceneObjectName)
 {
     return(GLTFUtils.cleanName(sceneObjectName.Length > 0 ? sceneObjectName : "GlTF"));
 }
Esempio n. 4
0
 public string generateName(string name, int index)
 {
     return(GLTFUtils.cleanName(name + "_" + index).Replace(":", "_"));
 }