Пример #1
0
        private void loadObjectType(ObjectData data)
        {
            TypeNode         typeNode     = null;
            EmbeddedTypeInfo embeddedtype = null;

            if (typeTreeStruct.embeddedTypeMap.ContainsKey(data.typeID))
            {
                embeddedtype = typeTreeStruct.embeddedTypeMap[data.typeID];
                if (embeddedtype != null)
                {
                    typeNode = embeddedtype.typeTree;
                }
            }

            // get type from database if the embedded one is missing
            if (typeNode == null)
            {
                typeNode = TypeTreeUtils.getTypeNode(data.unityClass(),
                                                     versionInfo.unityRevision, false);
            }

            data.typeTree = typeNode;

            //// Add typeless objects to an internal list. They can't be
            //// (de)serialized, but can still be written to the file.
            //if (typeNode == null)
            //{
            //    // log warning if it's not a MonoBehaviour
            //    if (info.classID != 114)
            //    {
            //        //Logger.Log("{0} has no type information!" + data.ToString());
            //    }
            //    objectListBroken.Add(data);
            //}
            //else
            //{
            //    objectList.Add(data);
            //}
        }
Пример #2
0
        public static int learnTypes(AssetFileEx asset)
        {
            if (asset.isStandalone())
            {
                Logger.Log("File doesn't contain type information");
                return(0);
            }

            Dictionary <int, EmbeddedTypeInfo> typemap = asset.embeddedTypeMap;

            UnityVersion unityRevision = asset.versionInfo.unityRevision;

            if (unityRevision == null)
            {
                Logger.Log("unityRevision = null");
                return(0);
            }

            int learned = 0;

            // merge the TypeTree map with the database field map
            foreach (KeyValuePair <int, EmbeddedTypeInfo> typeTreeEntry in typemap)
            {
                int      typeID   = typeTreeEntry.Key;
                TypeNode typeNode = typeTreeEntry.Value.typeTree;

                // skip MonoBehaviour types
                if (typeID < 1)
                {
                    continue;
                }

                UnityClass unityClass = new UnityClass(typeID);
                TypeNode   typeNodeDB = TypeTreeUtils.getTypeNode(unityClass, unityRevision, true);

                if (typeNodeDB == null)
                {
                    Logger.Log("New: {0}" + unityClass);
                    TypeTreeDatabase.Instance.addEntry(unityClass, unityRevision, typeNode);
                    typeNodeDB = typeNode;
                    learned++;
                }

                // check the hashes, they must be identical at this point
                //int hash1 = typeNode.hashCode();
                //int hash2 = typeNodeDB.hashCode();

                //if (hash1 != hash2)
                //{
                //    Logger.Log("Database hash mismatch for {0}: {1} != {2}"+
                //            new Object[] {typeNodeDB.type.typeName(), hash1, hash2});
                //}

                // check if the class name is known and suggest the type base name if not
                if (unityClass.name() == null)
                {
                    Logger.Log("Unknown ClassID {0}, suggested name: {1}" +
                               new Object[] { unityClass.ID(), typeNode.type });
                }
            }

            return(learned);
        }
Пример #3
0
 public static TypeNode getTypeNode(ObjectData obj, bool strict)
 {
     return(TypeTreeUtils.getTypeNode(obj.unityClass(), obj.versionInfo.unityRevision, strict));
 }