Example #1
0
    protected static List <BundleTextures> ParseBundleTextures(string raceName)
    {
        var loader = new TextureLoader();

        var bundleTextures = new List <BundleTextures>();
        var textureTypes   = new Dictionary <TextureType, string>
        {
            { TextureType.Skin, Textures.Skin.GetFolderPath(raceName) },
            { TextureType.Eyebrow, Textures.Eyebrow.GetFolderPath(raceName) },
            { TextureType.Scar, Textures.Scar.GetFolderPath(raceName) },
            { TextureType.Beard, Textures.Beard.GetFolderPath(raceName) },
            { TextureType.FaceFeature, Textures.FaceFeature.GetFolderPath(raceName) },
            { TextureType.Hair, Textures.Hair.GetFolderPath(raceName) },
            { TextureType.Eye, Textures.Eye.GetFolderPath(raceName) },
            { TextureType.Head, Textures.Head.GetFolderPath(raceName) },
            { TextureType.Pants, Textures.Pants.GetFolderPath(raceName) },
            { TextureType.Torso, Textures.Torso.GetFolderPath(raceName) },
            { TextureType.Shoe, Textures.Shoes.GetFolderPath(raceName) },
            { TextureType.Glove, Textures.Gloves.GetFolderPath(raceName) },
            { TextureType.RobeLong, Textures.RobeLong.GetFolderPath(raceName) },
            { TextureType.RobeShort, Textures.RobeShort.GetFolderPath(raceName) },
            { TextureType.Belt, Textures.Belt.GetFolderPath(raceName) },
            { TextureType.Cloak, Textures.Cloak.GetFolderPath(raceName) },
        };

        foreach (var path in textureTypes)
        {
            BundleTextures textures = new BundleTextures();
            textures.type = path.Key;
            var paths = loader.ParseTextures(null, path.Value);
            foreach (string[] texturePaths in paths)
            {
                var texture = new BundleTexture();
                foreach (string colorPath in texturePaths)
                {
                    string bundleName, assetPath;

                    var bundlePath = colorPath.Substring("Assets/Character_Editor/Textures/Character/".Length);
                    ParsePathToBundle(bundlePath, out bundleName, out assetPath);

                    AssetImporter.GetAtPath(colorPath).SetAssetBundleNameAndVariant(bundleName, "");

                    var color = new BundleColor();
                    color.path = assetPath;

                    texture.colors.Add(color);
                }
                textures.texturePaths.Add(texture);
            }
            bundleTextures.Add(textures);
        }
        return(bundleTextures);
    }
Example #2
0
    protected static List <BundleFxMeshes> ParseBundleFXMeshes(string raceName)
    {
        var bundleMeshList  = new List <BundleFxMeshes>();
        int substringLength = "Assets/Character_Editor/Prefabs/".Length;

        var meshTypes = new Dictionary <FXType, string>
        {
            { FXType.Torso, FX.TorsoFX.GetFolderPath(raceName) },
            { FXType.Eye, FX.EyeFX.GetFolderPath(raceName) },
        };

        foreach (var path in meshTypes)
        {
            var bundleMeshes = new BundleFxMeshes();
            bundleMeshes.type = path.Key;

            if (!Directory.Exists(path.Value))
            {
                continue;
            }

            var meshGUIDs = AssetDatabase.FindAssets("t:GameObject", new string[]
            {
                path.Value
            }
                                                     );
            for (int i = 0; i < meshGUIDs.Length; i++)
            {
                var    bundleMesh = new BundleColor();
                var    bundleModelPath = AssetDatabase.GUIDToAssetPath(meshGUIDs[i]);
                string bundleName, assetPath;

                ParsePathToBundle(bundleModelPath.Substring(substringLength), out bundleName, out assetPath);
                AssetImporter.GetAtPath(bundleModelPath).SetAssetBundleNameAndVariant(bundleName, "");

                bundleMesh.path = assetPath;
                bundleMeshes.meshPaths.Add(bundleMesh);
            }
            bundleMeshList.Add(bundleMeshes);
        }

        return(bundleMeshList);
    }
Example #3
0
    protected static List <BundleMeshes> ParseBundleMeshes(string raceName)
    {
        var textureLoader  = new TextureLoader();
        var bundleMeshList = new List <BundleMeshes>();

        int substringLength = "Assets/Character_Editor/Prefabs/".Length;

        var meshTypes = new Dictionary <MeshType, string>
        {
            { MeshType.Torso, Meshes.Torso.GetFolderPath(raceName) },
            { MeshType.Beard, Meshes.Beard.GetFolderPath(raceName) },
            { MeshType.FaceFeature, Meshes.FaceFeature.GetFolderPath(raceName) },
            { MeshType.Hair, Meshes.Hair.GetFolderPath(raceName) },
            { MeshType.Helm, Meshes.Helm.GetFolderPath(raceName) },
            { MeshType.TorsoAdd, Meshes.TorsoAdd.GetFolderPath(raceName) },
            { MeshType.LegRight, Meshes.Leg.GetFolderPath(raceName, MeshType.LegRight) },
            { MeshType.LegLeft, Meshes.Leg.GetFolderPath(raceName, MeshType.LegLeft) },
            { MeshType.ShoulderLeft, Meshes.Shoulder.GetFolderPath(raceName, MeshType.ShoulderLeft) },
            { MeshType.ShoulderRight, Meshes.Shoulder.GetFolderPath(raceName, MeshType.ShoulderRight) },
            { MeshType.ArmLeft, Meshes.Arm.GetFolderPath(raceName, MeshType.ArmLeft) },
            { MeshType.ArmRight, Meshes.Arm.GetFolderPath(raceName, MeshType.ArmRight) },
            { MeshType.Belt, Meshes.Belt.GetFolderPath(raceName) },
            { MeshType.BeltAdd, Meshes.BeltAdd.GetFolderPath(raceName) },
            { MeshType.HandLeft, Meshes.Hand.GetFolderPath(raceName, MeshType.HandLeft) },
            { MeshType.HandRight, Meshes.Hand.GetFolderPath(raceName, MeshType.HandRight) },
        };

        foreach (var path in meshTypes)
        {
            var bundleMeshes = new BundleMeshes();
            bundleMeshes.type = path.Key;

            var dirPath = Path.Combine(Application.dataPath, path.Value.Substring(7));
            if (!Directory.Exists(dirPath))
            {
                continue;
            }

            var folders = Directory.GetDirectories(dirPath);

            for (int i = 0; i < folders.Length; i++)
            {
                var bundleMesh = new BundleMesh();

                string gameObjectsPath = folders[i].Substring(Application.dataPath.Length - 6);
                var    meshGUIDs       = AssetDatabase.FindAssets("t:GameObject", new string[]
                {
                    gameObjectsPath + "/StaticModel"
                }
                                                                  );
                if (meshGUIDs.Length == 0)
                {
                    continue;
                }
                var bundleModelPath = AssetDatabase.GUIDToAssetPath(meshGUIDs[0]);

                string bundleName, assetPath;
                ParsePathToBundle(bundleModelPath.Substring(substringLength), out bundleName, out assetPath, 2);
                AssetImporter.GetAtPath(bundleModelPath).SetAssetBundleNameAndVariant(bundleName, "");

                bundleMesh.modelPath = assetPath;

                foreach (var texturePath in textureLoader.ParseTextures(null, gameObjectsPath + "/Textures"))
                {
                    var bundleTexture = new BundleTexture();

                    foreach (var colorPath in texturePath)
                    {
                        ParsePathToBundle(colorPath.Substring(substringLength), out bundleName, out assetPath, 2);
                        AssetImporter.GetAtPath(colorPath).SetAssetBundleNameAndVariant(bundleName, "");

                        var bundleColor = new BundleColor();
                        bundleColor.path = assetPath;
                        bundleTexture.colors.Add(bundleColor);
                    }

                    bundleMesh.textures.Add(bundleTexture);
                }
                bundleMeshes.meshPaths.Add(bundleMesh);
            }
            bundleMeshList.Add(bundleMeshes);
        }
        return(bundleMeshList);
    }