Exemplo n.º 1
0
        void OnPostprocessTexture(Texture2D texture)
        {
            string path = Util.RelativePath(assetPath);

            if (PathQueue.Contains(path))
            {
                PathQueue.Remove(path);
                TextureImporter ti = assetImporter as TextureImporter;
                ti.alphaIsTransparency = true;
                ti.filterMode          = FilterMode.Point;
                ti.mipmapEnabled       = false;
                ti.wrapMode            = TextureWrapMode.Clamp;
                ti.isReadable          = true;
#if UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_4 || UNITY_4
                ti.textureFormat = TextureImporterFormat.AutomaticTruecolor;
                ti.textureType   = TextureImporterType.Advanced;
#else
                ti.textureType        = TextureImporterType.Default;
                ti.textureCompression = TextureImporterCompression.Uncompressed;
#endif
                ti.npotScale      = TextureImporterNPOTScale.None;
                ti.maxTextureSize = 8192;
                AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceSynchronousImport);
            }
        }
Exemplo n.º 2
0
        public void OnPreprocessModel()
        {
            string path = Util.RelativePath(assetPath);

            if (PathQueue.Contains(path))
            {
                PathQueue.Remove(path);

                if (assetImporter)
                {
                    ModelImporter mi = assetImporter as ModelImporter;
                    mi.importMaterials   = true;
                    mi.materialSearch    = ModelImporterMaterialSearch.Local;
                    mi.importAnimation   = false;
                    mi.importBlendShapes = false;

#if UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_4
                    mi.normalImportMode = ModelImporterTangentSpaceMode.Calculate;
#elif UNITY_2017_1 || UNITY_2017_2
                    mi.importNormals = ModelImporterNormals.Calculate;
#elif !UNITY_5
                    mi.materialLocation = ModelImporterMaterialLocation.External;
                    mi.importNormals    = ModelImporterNormals.Calculate;
#endif
                    mi.normalSmoothingAngle = 0f;

                    string fileName = Util.GetName(path);
                    EditorApplication.delayCall += () => {
                        string     parentPath = Util.RelativePath(new FileInfo(path).Directory.FullName);
                        FileInfo[] infos      = new DirectoryInfo(parentPath + "/Materials").GetFiles("*.mat");
                        for (int i = 0; i < infos.Length; i++)
                        {
                            Material mat = AssetDatabase.LoadAssetAtPath <Material>(Util.RelativePath(infos[i].FullName));
                            if (
                                mat &&
                                (mat.name.StartsWith(fileName.Replace(' ', '_')) ||
                                 mat.name.StartsWith(fileName))
                                )
                            {
                                Texture2D texture = AssetDatabase.LoadAssetAtPath <Texture2D>(parentPath + "/" + fileName + ".png");
                                if (texture)
                                {
                                    mat.mainTexture = texture;
                                    Shader shader = VoxelToUnityWindow.TheShader;
                                    if (shader)
                                    {
                                        mat.shader = shader;
                                    }
                                }
                            }
                        }
                    };
                }
            }
        }
Exemplo n.º 3
0
        void OnPostprocessTexture(Texture2D texture)
        {
            string path  = Util.RelativePath(assetPath);
            int    index = IndexFor(path);

            if (index >= 0)
            {
                // Impoert
                TextureImporter ti = assetImporter as TextureImporter;
                ti.isReadable          = true;
                ti.alphaIsTransparency = true;
                ti.filterMode          = FilterMode.Point;
                ti.mipmapEnabled       = false;
                ti.textureType         = TextureImporterType.Sprite;
                ti.spriteImportMode    = SpriteImportMode.Multiple;
                ti.maxTextureSize      = 8192;

#if UNITY_4 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_4
                ti.textureFormat = TextureImporterFormat.AutomaticTruecolor;
#else
                ti.textureCompression = TextureImporterCompression.Uncompressed;
#endif

                // Sprites
                Rect[] rects = PathQueue[index].spriteRects;

                List <SpriteMetaData> newData = new List <SpriteMetaData>();

                for (int i = 0; i < rects.Length; i++)
                {
                    SpriteMetaData smd = new SpriteMetaData()
                    {
                        pivot     = PathQueue[index].Pivots[i],
                        alignment = 9,
                        name      = Util.GetName(path) + "_" + _25DSprite.SPRITE_ANGLE[i].ToString("0"),
                        rect      = rects[i]
                    };
                    newData.Add(smd);
                }

                ti.spritesheet = newData.ToArray();

                // Final
                AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);
                PathQueue.RemoveAt(index);
            }
        }
Exemplo n.º 4
0
        void OnPostprocessTexture(Texture2D texture)
        {
            string path = Util.RelativePath(assetPath);

            if (PathQueue.Contains(path))
            {
                PathQueue.Remove(path);
                TextureImporter ti = assetImporter as TextureImporter;
                ti.alphaIsTransparency = true;
                ti.filterMode          = FilterMode.Point;
                ti.mipmapEnabled       = false;
                ti.wrapMode            = TextureWrapMode.Clamp;
                ti.textureFormat       = TextureImporterFormat.AutomaticTruecolor;
                ti.textureType         = TextureImporterType.Default;
                ti.npotScale           = TextureImporterNPOTScale.None;
                ti.maxTextureSize      = Mathf.Max(texture.width, texture.height);
                AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceSynchronousImport);
            }
        }
Exemplo n.º 5
0
 public static void AddToQueue(string path)
 {
     PathQueue.Add(Util.RelativePath(path));
 }