Package info.ata4.unity.util

Examples of info.ata4.unity.util.UnityVersion


        this.cf = cf;
    }

    public void extract(boolean raw) throws IOException {
        List<ObjectPath> paths = asset.getPaths();
        Deserializer deser = new Deserializer(asset);

        for (AssetExtractHandler extractHandler : extractHandlerMap.values()) {
            extractHandler.setAssetFile(asset);
            extractHandler.setOutputDir(outputDir);
        }
       
        for (ObjectPath path : paths) {
            // skip filtered classes
            if (cf != null && !cf.accept(path)) {
                continue;
            }
           
            String className = ClassID.getNameForID(path.getClassID(), true);

            // write just the serialized object data or parsed and extracted content?
            if (raw) {
                String assetFileName = String.format("%06d.bin", path.getPathID());
                Path classDir = outputDir.resolve(className);
                if (Files.notExists(classDir)) {
                    Files.createDirectories(classDir);
                }
               
                Path assetFile = classDir.resolve(assetFileName);
               
                L.log(Level.INFO, "Writing {0} {1}", new Object[] {className, assetFileName});
               
                ByteBuffer bbAsset = asset.getPathBuffer(path);
               
                try {
                    ByteBufferUtils.save(assetFile, bbAsset);
                } catch (Exception ex) {
                    L.log(Level.WARNING, "Can't write " + path + " to " + assetFile, ex);
                }
            } else {
                AssetExtractHandler handler = getHandler(className);
               
                if (handler != null) {
                    UnityObject obj;
                   
                    try {
                        obj = deser.deserialize(path);
                    } catch (Exception ex) {
                        L.log(Level.WARNING, "Can't deserialize " + path, ex);
                        continue;
                    }
                   
View Full Code Here


    public void setClassFilter(ClassFilter cf) {
        this.cf = cf;
    }
   
    public void dumpData() throws IOException {
        Deserializer deser = new Deserializer(asset);

        for (ObjectPath path : asset.getPaths()) {
            // skip MonoBehaviours
            if (path.isScript()) {
                continue;
            }

            // skip filtered classes
            if (cf != null && !cf.accept(path)) {
                continue;
            }

            UnityObject obj;
           
            try {
                obj = deser.deserialize(path);
            } catch (Exception ex) {
                L.log(Level.SEVERE, "Deserialization failed for " + path, ex);
                continue;
            }
           
View Full Code Here

    public static String getObjectName(AssetFile asset, ObjectPath path) {
        Deserializer deser = new Deserializer(asset);
        String name = null;
       
        try {
            UnityObject obj = deser.deserialize(path);
            name = obj.getValue("m_Name");
        } catch (OutOfMemoryError ex) {
            // Deserializer choked on an array size and clogged the heap, try
            // to clean up this mess
            deser = null;
            System.gc();
View Full Code Here

                }
            } else {
                AssetExtractHandler handler = getHandler(className);
               
                if (handler != null) {
                    UnityObject obj;
                   
                    try {
                        obj = deser.deserialize(path);
                    } catch (Exception ex) {
                        L.log(Level.WARNING, "Can't deserialize " + path, ex);
View Full Code Here

            // skip filtered classes
            if (cf != null && !cf.accept(path)) {
                continue;
            }

            UnityObject obj;
           
            try {
                obj = deser.deserialize(path);
            } catch (Exception ex) {
                L.log(Level.SEVERE, "Deserialization failed for " + path, ex);
View Full Code Here

        dumpValue(value.get());
    }
   
    private void dumpValue(Object value) {
        if (value instanceof UnityObject) {
            UnityObject obj = (UnityObject) value;
            dumpObject(obj);
        } else if (value instanceof UnityTag) {
            UnityTag val = (UnityTag) value;
            Object valObj = val.get();
           
View Full Code Here

    }

    @Override
    public void extract(UnityObject obj) throws IOException {
        String name = obj.getValue("m_Name");
        UnityString script = obj.getValue("m_Script", false);
       
        setOutputFileName(name);
        writeData(script.getRaw());
    }
View Full Code Here

    private void dumpValue(Object value) {
        if (value instanceof UnityObject) {
            UnityObject obj = (UnityObject) value;
            dumpObject(obj);
        } else if (value instanceof UnityTag) {
            UnityTag val = (UnityTag) value;
            Object valObj = val.get();
           
            if (valObj instanceof List) {
                dumpList(val, valObj);
            } else {
                dumpValue(valObj);
View Full Code Here

   
    private static final Logger L = LogUtils.getLogger();

    @Override
    public void run() {
        FieldTypeMap ftm = StructDatabase.getInstance().getFieldTypeMap();
        Set<TypeField> fieldNodes = new HashSet<>();
        Set<UnityVersion> versions = new TreeSet<>();
        Set<Integer> classIDs = new TreeSet<>();

        for (Map.Entry<Pair<Integer, UnityVersion>, TypeField> entry : ftm.entrySet()) {
            versions.add(entry.getKey().getRight());
            classIDs.add(entry.getKey().getLeft());
            fieldNodes.add(entry.getValue());
        }
       
        L.log(Level.INFO, "Class IDs: {0}", classIDs.size());
        L.log(Level.INFO, "Versions: {0}", versions.size());
        L.log(Level.INFO, "Fields: {0}", fieldNodes.size());
       
        System.out.println();
        System.out.print("        |");
       
        for (Integer classID : classIDs) {
            System.out.print(StringUtils.leftPad(String.valueOf(classID), 4));
            System.out.print(" |");
        }
       
        System.out.println();
        System.out.print("--------|");
        System.out.print(StringUtils.repeat("-----|", classIDs.size()));
        System.out.println();
       
        for (UnityVersion rev : versions) {
            System.out.print(rev);
            System.out.print(" |");
           
            for (Integer classID : classIDs) {
                System.out.print("  ");
                if (ftm.containsKey(new ImmutablePair(classID, rev))) {
                    System.out.print("x");
                } else {
                    System.out.print(" ");
                }
                System.out.print("  |");
View Full Code Here

        if (fieldNode != null || strict) {
            return fieldNode;
        }

        TypeField fieldNodeB = null;
        UnityVersion versionB = null;

        TypeField fieldNodeC = null;
        UnityVersion versionC = null;

        for (Map.Entry<Pair<Integer, UnityVersion>, TypeField> entry : entrySet()) {
            Pair<Integer, UnityVersion> fieldNodeKey = entry.getKey();
            if (fieldNodeKey.getLeft() == classID) {
                TypeField fieldNodeEntry = entry.getValue();
                UnityVersion revisionEntry = fieldNodeKey.getRight();

                if (revisionEntry.getMajor() == version.getMajor()) {
                    if (revisionEntry.getMinor() == version.getMinor()) {
                        // if major and minor versions match, it will probably work
                        return fieldNodeEntry;
                    } else {
                        // suboptimal choice
                        fieldNodeB = fieldNodeEntry;
View Full Code Here

TOP

Related Classes of info.ata4.unity.util.UnityVersion

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.