Example #1
0
 internal void SetMesh(UnityEngine.Config.FileMap fms)
 {
     this.fms = fms;
     if (IsValid())
     {
         mesh_raw = Resources.GetMeshImport(fms);
     }
 }
Example #2
0
        internal static MeshImport GetMeshImport(string guid)
        {
            if (meshImports.ContainsKey(guid))
            {
                return(meshImports[guid]);
            }
            MeshImport mi   = new MeshImport();
            var        info = rmManager.GetFromGuid(guid);

            if (info == null)
            {
                mi.guid = guid;
            }
            else
            {
                mi.rawJson = LoadInternalRaw(guid);
                mi.guid    = info.guid;
                var json = LoadInternalFile(guid);
                mi.config = UnityEngine.Config.ModelImporter.FromJson(json[0] as Dictionary <string, System.Object>);
            }
            meshImports[guid] = mi;
            return(mi);
        }
Example #3
0
        internal static AnimationClip GetAnimationClip(UnityEngine.Config.FileMap fms)
        {
            if (fms.IsEmpty())
            {
                return(null);
            }
            MeshImport mi = GetMeshImport(fms);

            if (mi == null || mi.config == null || mi.config.importAnimation == 0)
            {
                return(null);
            }
            var key = fms.Key();

            if (animationClips.ContainsKey(key))
            {
                return(animationClips[key]);
            }
            // find name from fileID
            var name = mi.config.fileIDToRecycleName.GetValueFromKey(fms.fileID);

            if (String.IsNullOrEmpty(name))
            {
                return(null);
            }
            foreach (var c in mi.config.animations.clipAnimations)
            {
                if (c.name == name)
                {
                    var clip = new AnimationClip();
                    clip.SetFromRaw(c);
                    animationClips[key] = clip;
                    return(clip);
                }
            }
            // if the name is not found in the file. it is the default.
            var rm = rmManager.GetFromInfo(fms);

            if (rm == null)
            {
                return(null);
            }
            var rawclip = new UnityEngine.Config.ModelImporterAnimationClip();

            rawclip.firstFrame = 0;
            rawclip.lastFrame  = 30;
            rawclip.wrapMode   = 1;
            var antStarts = rm.name.IndexOf("@");

            if (antStarts != -1)
            {
                rawclip.name = rm.name.Substring(antStarts + 1);
            }
            else
            {
                rawclip.name = name;
            }
            var aclip = new AnimationClip();

            aclip.SetFromRaw(rawclip);
            animationClips[key] = aclip;
            return(aclip);
        }