Exemplo n.º 1
0
 public static void SetSettings(ModelImporter importer, SoModelPostprocessor so)
 {
     SetSceneSettings(importer, so);
     SetMeshSettings(importer, so);
     SetMaterialSettings(importer, so);
     SetAnimationSettings(importer, so);
 }
Exemplo n.º 2
0
        private static void SetAnimationSettings(ModelImporter importer, SoModelPostprocessor so)
        {
            importer.animationType   = so.AnimationType;
            importer.importAnimation = so.ImportAnimation;
            if (importer.importAnimation)
            {
                importer.animationCompression = so.AnimationCompression;

                if (so.IsRoleAnimation)
                {
                    var avatarPath   = AssetDatabase.GUIDToAssetPath(so.SourceAvatarGuid);
                    var sourceAvatar = AssetDatabase.LoadAssetAtPath <Avatar>(avatarPath);
                    if (sourceAvatar == null)
                    {
                        throw new Exception("未指定 Source Avatar,请检查配置:" + AssetDatabase.GetAssetPath(so));
                    }

                    importer.sourceAvatar = sourceAvatar;

                    ModelImporterClipAnimation[] anim = new ModelImporterClipAnimation[1];
                    anim[0]                         = new ModelImporterClipAnimation();
                    anim[0].name                    = importer.defaultClipAnimations[0].name;
                    anim[0].firstFrame              = importer.defaultClipAnimations[0].firstFrame;
                    anim[0].lastFrame               = importer.defaultClipAnimations[0].lastFrame;
                    anim[0].lockRootHeightY         = true;
                    anim[0].lockRootPositionXZ      = true;
                    anim[0].lockRootRotation        = true;
                    anim[0].keepOriginalOrientation = true;
                    anim[0].keepOriginalPositionXZ  = true;
                    anim[0].keepOriginalPositionY   = true;

                    importer.clipAnimations = anim;
                }
            }
        }
Exemplo n.º 3
0
 private static void SetSceneSettings(ModelImporter importer, SoModelPostprocessor so)
 {
     importer.globalScale       = so.GlobalScale;
     importer.importBlendShapes = so.ImportBlendShapes;
     importer.importVisibility  = so.ImportVisibility;
     importer.importCameras     = so.ImportCameras;
     importer.importLights      = so.ImportLights;
 }
Exemplo n.º 4
0
        public ModelPostprocessorWidget(string guid, bool allowEdit) : this()
        {
            var path = AssetDatabase.GUIDToAssetPath(guid);

            this.so        = AssetDatabase.LoadAssetAtPath <SoModelPostprocessor>(path);
            this.allowEdit = allowEdit;
            Initialize();
        }
Exemplo n.º 5
0
 private static void SetMaterialSettings(ModelImporter importer, SoModelPostprocessor so)
 {
     importer.importMaterials  = so.ImportMaterials;
     importer.materialLocation = so.MaterialLocation;
     if (importer.importMaterials && so.RemoveStandardMaterial && importer.materialLocation == ModelImporterMaterialLocation.InPrefab)
     {
         RemoveStandardMaterial(importer);
     }
 }
Exemplo n.º 6
0
        public static bool CompareSettings(ModelImporter importer, SoModelPostprocessor so, out string message)
        {
            var same = true;

            message = string.Empty;
            same   &= CompareSceneSetting(importer, so, ref message);
            same   &= CompareMeshSetting(importer, so, ref message);
            same   &= CompareMaterialSetting(importer, so, ref message);
            same   &= CompareAnimationSetting(importer, so, ref message);
            return(same);
        }
Exemplo n.º 7
0
        static bool CompareAnimationSetting(ModelImporter importer, SoModelPostprocessor so, ref string message)
        {
            var same     = true;
            var sameInfo = string.Empty;

            if (importer.importAnimation != so.ImportAnimation)
            {
                same     = false;
                sameInfo = StringUtil.Contact(sameInfo, "\n", "ImportAnimation");
            }

            if (importer.animationType != so.AnimationType)
            {
                same     = false;
                sameInfo = StringUtil.Contact(sameInfo, "\n", "AnimationType");
            }

            if (importer.importAnimation && so.ImportAnimation)
            {
                if (importer.animationCompression != so.AnimationCompression)
                {
                    same     = false;
                    sameInfo = StringUtil.Contact(sameInfo, "\n", "AnimationCompression");
                }

                if (so.IsRoleAnimation)
                {
                    if (importer.sourceAvatar == null)
                    {
                        same     = false;
                        sameInfo = StringUtil.Contact(sameInfo, "\n", "Source Avatar is null");
                    }
                    else
                    {
                        var avatarAssetPath = AssetDatabase.GetAssetPath(importer.sourceAvatar);
                        var avatarGuid      = AssetDatabase.AssetPathToGUID(avatarAssetPath);
                        if (avatarGuid != so.SourceAvatarGuid)
                        {
                            same     = false;
                            sameInfo = StringUtil.Contact(sameInfo, "\n", "SourceAvatar");
                        }
                    }
                }
            }

            if (!same)
            {
                message = StringUtil.Contact(message, "\n", "<b>Animation</b>", sameInfo);
            }

            return(same);
        }
Exemplo n.º 8
0
        static bool CompareMaterialSetting(ModelImporter importer, SoModelPostprocessor so, ref string message)
        {
            var same     = true;
            var sameInfo = string.Empty;

            if (importer.importMaterials != so.ImportMaterials)
            {
                same     = false;
                sameInfo = StringUtil.Contact(sameInfo, "\n", "ImportMaterials");
            }

            if (importer.materialLocation != so.MaterialLocation)
            {
                same     = false;
                sameInfo = StringUtil.Contact(sameInfo, "\n", "MaterialLocation");
            }

            if (importer.importMaterials && importer.materialLocation == ModelImporterMaterialLocation.InPrefab)
            {
                var objects = AssetDatabase.LoadAllAssetsAtPath(importer.assetPath);
                if (objects != null && objects.Length > 0)
                {
                    for (int i = 0; i < objects.Length; i++)
                    {
                        if (objects[i] is Material)
                        {
                            var mat = objects[i] as Material;
                            postprocessorUtils = postprocessorUtils ? postprocessorUtils : SoAssetPostprocessorUtils.GetSoAssetPostprocessorUtils();
                            if (postprocessorUtils.ContainsStandardShader(mat.shader.name))
                            {
                                same     = false;
                                sameInfo = StringUtil.Contact(sameInfo, "\n", "Using Standard Shader");
                                break;
                            }
                        }
                    }
                }
            }

            if (!same)
            {
                message = StringUtil.Contact(message, "\n", "<b>Material</b>", sameInfo);
            }

            return(same);
        }
Exemplo n.º 9
0
        public static SoAssetPostprocessor Create(PostprocessorAssetType assetType)
        {
            switch (assetType)
            {
            case PostprocessorAssetType.SpriteAtlas:
                return(SoSpriteAtlasPostprocessor.Create());

            case PostprocessorAssetType.Sprite:
                return(SoSpritePostprocessor.Create());

            case PostprocessorAssetType.Texture:
                return(SoTexturePostprocessor.Create());

            case PostprocessorAssetType.Model:
                return(SoModelPostprocessor.Create());
            }

            return(null);
        }
Exemplo n.º 10
0
        public static SoAssetPostprocessor GetDefault(PostprocessorAssetType assetType)
        {
            switch (assetType)
            {
            case PostprocessorAssetType.SpriteAtlas:
                return(SoSpriteAtlasPostprocessor.GetDefaultSoPostprocessor());

            case PostprocessorAssetType.Sprite:
                return(SoSpritePostprocessor.GetDefaultSoPostprocessor());

            case PostprocessorAssetType.Texture:
                return(SoTexturePostprocessor.GetDefaultSoPostprocessor());

            case PostprocessorAssetType.Model:
                return(SoModelPostprocessor.GetDefaultSoPostprocessor());
            }

            return(null);
        }
Exemplo n.º 11
0
        static bool CompareSceneSetting(ModelImporter importer, SoModelPostprocessor so, ref string message)
        {
            var same     = true;
            var sameInfo = string.Empty;

            if (importer.globalScale != so.GlobalScale)
            {
                same     = false;
                sameInfo = StringUtil.Contact(sameInfo, "\n", "GlobalScale");
            }

            if (importer.importBlendShapes != so.ImportBlendShapes)
            {
                same     = false;
                sameInfo = StringUtil.Contact(sameInfo, "\n", "ImportBlendShapes");
            }

            if (importer.importVisibility != so.ImportVisibility)
            {
                same     = false;
                sameInfo = StringUtil.Contact(sameInfo, "\n", "ImportVisibility");
            }

            if (importer.importCameras != so.ImportCameras)
            {
                same     = false;
                sameInfo = StringUtil.Contact(sameInfo, "\n", "ImportCameras");
            }

            if (importer.importLights != so.ImportLights)
            {
                same     = false;
                sameInfo = StringUtil.Contact(sameInfo, "\n", "ImportLights");
            }

            if (!same)
            {
                message = StringUtil.Contact(message, "\n", "<b>Scene</b>", sameInfo);
            }

            return(same);
        }
Exemplo n.º 12
0
        static bool CompareMeshSetting(ModelImporter importer, SoModelPostprocessor so, ref string message)
        {
            var same     = true;
            var sameInfo = string.Empty;

            if (importer.meshCompression != so.MeshCompression)
            {
                same     = false;
                sameInfo = StringUtil.Contact(sameInfo, "\n", "MeshCompression");
            }

            if (importer.isReadable != so.IsReadable)
            {
                same     = false;
                sameInfo = StringUtil.Contact(sameInfo, "\n", "Read/Write");
            }

            if (!same)
            {
                message = StringUtil.Contact(message, "\n", "<b>Mesh</b>", sameInfo);
            }

            return(same);
        }
Exemplo n.º 13
0
 private static void SetMeshSettings(ModelImporter importer, SoModelPostprocessor so)
 {
     importer.meshCompression = so.MeshCompression;
     importer.isReadable      = so.IsReadable;
 }
Exemplo n.º 14
0
        static async Task Reimport(ModelImporter importer, SoModelPostprocessor so)
        {
            await Task.Delay(1);

            importer.SaveAndReimport();
        }
Exemplo n.º 15
0
 public ModelPostprocessorWidget(SoModelPostprocessor so, bool allowEdit) : this()
 {
     this.so        = so;
     this.allowEdit = allowEdit;
     Initialize();
 }