コード例 #1
0
 public static void SetupButtons(Type type, object value, ReferenceChain refChain)
 {
     if (TypeUtil.IsTextureType(type) && value != null)
     {
         var texture = (Texture)value;
         if (GUILayout.Button("Preview"))
         {
             TextureViewer.CreateTextureViewer(refChain, texture);
         }
         if (GUILayout.Button("Dump .png"))
         {
             TextureUtil.DumpTextureToPNG(texture);
         }
     }
     else if (TypeUtil.IsMeshType(type) && value != null)
     {
         if (GUILayout.Button("Preview"))
         {
             MeshViewer.CreateMeshViewer(null, (Mesh)value, null);
         }
         if (((Mesh)value).isReadable)
         {
             if (GUILayout.Button("Dump .obj"))
             {
                 var outPath = refChain.ToString().Replace(' ', '_');
                 DumpUtil.DumpMeshAndTextures(outPath, value as Mesh);
             }
         }
     }
     if (GUILayout.Button("Copy"))
     {
         _buffer = value;
     }
 }
コード例 #2
0
    public void Dump(string baseDir, ISet <AssetType> types, AssetId[] dumpIds)
    {
        var applier = Resolve <IModApplier>();

        void Write(string name, string content)
        {
            var filename  = Path.Combine(baseDir, "data", "exported", "annotated", name);
            var directory = Path.GetDirectoryName(filename);

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }

            File.WriteAllText(filename, content);
        }

        foreach (var type in types)
        {
            foreach (var id in DumpUtil.All(type, dumpIds))
            {
                var notes = applier.LoadAssetAnnotated(id, Language.English);
                var name  = ConfigUtil.AssetName(id);
                Write($"{type}\\{id.Id}_{name}.txt", notes);
            }
        }
    }
コード例 #3
0
        private static void SetupSegmentButtons(ReferenceChain refChain, NetInfo.Segment segmentInfo)
        {
            try
            {
                Debug.Log("SetupSegmentButtons() called");
                if (segmentInfo.m_mesh != null && segmentInfo.m_mesh.isReadable && GUILayout.Button("Dump"))
                {
                    var outPath = refChain.ToString().Replace(' ', '_');
                    DumpUtil.DumpMeshAndTextures(
                        outPath,
                        segmentInfo.m_mesh,
                        segmentInfo.m_material);
                    DumpUtil.DumpMeshAndTextures(
                        outPath + "_lod",
                        segmentInfo.m_lodMesh,
                        segmentInfo.m_lodMaterial);
                }

                SetupMeshPreviewButtons(name: null, segmentInfo.m_mesh, segmentInfo.m_material, segmentInfo.m_lodMesh, segmentInfo.m_lodMaterial);
                Debug.Log("SetupSegmentButtons() successful");
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }
        }
コード例 #4
0
 private void DumpBuildingInfo(BuildingInfo pillar)
 {
     if (pillar != null)
     {
         if (previouspillarname != pillar.name.ToString())
         {
             DumpUtil.DumpMeshAndTextures(pillar.name, pillar.m_mesh, pillar.m_material);
             previouspillarname = pillar.name;
             pillarsDumped     += 1;
         }
     }
 }
コード例 #5
0
        private static void SetupMeshButtons(ReferenceChain refChain, Mesh mesh)
        {
            if (GUILayout.Button("Preview"))
            {
                MeshViewer.CreateMeshViewer(null, mesh, null);
            }

            if (mesh.isReadable && GUILayout.Button("Dump mesh"))
            {
                var outPath = refChain.ToString().Replace(' ', '_');
                DumpUtil.DumpMeshAndTextures(outPath, mesh);
            }
        }
コード例 #6
0
        void AddVehiclePanelControls(WorldInfoPanel infoPanel, out UILabel assetNameLabel, out UIButton showExplorerButton, out UIButton dumpMeshTextureButton)
        {
            infoPanel.component.Find <UILabel>("Type").isVisible = false;

            assetNameLabel = CreateLabel
                             (
                "AssetName: <>", 160, 24,
                infoPanel.component,
                new Vector3(8.0f, 48.0f, 0.0f),
                UIAlignAnchor.TopLeft
                             );

            showExplorerButton = CreateButton
                                 (
                "Find in SceneExplorer", 160, 24,
                infoPanel.component,
                new Vector3(-8.0f, -57.0f, 0.0f),
                UIAlignAnchor.BottomRight,
                (component, param) =>
            {
                InstanceID instance = ReflectionUtil.GetPrivate <InstanceID>(infoPanel, "m_InstanceID");

                if (instance.Vehicle == 0)
                {
                    sceneExplorer.ExpandFromRefChain(vehiclesParkedBufferRefChain.Add(instance.ParkedVehicle));
                }
                else
                {
                    sceneExplorer.ExpandFromRefChain(vehiclesBufferRefChain.Add(instance.Vehicle));
                }

                sceneExplorer.visible = true;
            }
                                 );

            dumpMeshTextureButton = CreateButton
                                    (
                "Dump asset", 160, 24,
                infoPanel.component,
                new Vector3(-8.0f, -25.0f, 0.0f),
                UIAlignAnchor.BottomRight,
                (component, param) =>
            {
                var instance    = ReflectionUtil.GetPrivate <InstanceID>(infoPanel, "m_InstanceID");
                var vehicleInfo = instance.Vehicle == 0 ? VehicleManager.instance.m_parkedVehicles.m_buffer[instance.ParkedVehicle].Info : VehicleManager.instance.m_vehicles.m_buffer[instance.Vehicle].Info;
                var assetName   = vehicleInfo.name;
                DumpUtil.DumpAsset(assetName, vehicleInfo.m_mesh, vehicleInfo.m_material, vehicleInfo.m_lodMesh, vehicleInfo.m_lodMaterial);
            }
                                    );
        }
コード例 #7
0
 private void DumpPropsofString(string findString)
 {
     for (int i = 0; i < loadedPrefab.m_lanes.Length; i++)
     {
         NetLaneProps LaneJProps = loadedPrefab.m_lanes[i].m_laneProps;
         for (int j = 0; j < LaneJProps.m_props.Length; j++)
         {
             PropInfo a = loadedPrefab.m_lanes[i].m_laneProps.m_props[j].m_prop;
             if (a.name.Contains(findString))
             {
                 DumpUtil.DumpMeshAndTextures(a.name, a.m_mesh, a.m_material);
                 propsDumped += 1;
             }
         }
     }
 }
コード例 #8
0
        private static void SetupNodeButtons(ReferenceChain refChain, NetInfo.Node nodeInfo)
        {
            if (nodeInfo.m_mesh != null && nodeInfo.m_mesh.isReadable && GUILayout.Button("Dump"))
            {
                var outPath = refChain.ToString().Replace(' ', '_');
                DumpUtil.DumpMeshAndTextures(
                    outPath,
                    nodeInfo.m_mesh,
                    nodeInfo.m_material);
                DumpUtil.DumpMeshAndTextures(
                    outPath + "_lod",
                    nodeInfo.m_lodMesh,
                    nodeInfo.m_lodMaterial);
            }

            SetupMeshPreviewButtons(name: null, nodeInfo.m_mesh, nodeInfo.m_material, nodeInfo.m_lodMesh, nodeInfo.m_lodMaterial);
        }
コード例 #9
0
        void AddBuildingPanelControls(WorldInfoPanel infoPanel, out UILabel assetNameLabel,
                                      out UIButton showExplorerButton, Vector3 showExplorerButtonOffset,
                                      out UIButton dumpMeshTextureButton, Vector3 dumpMeshTextureButtonOffset)
        {
            infoPanel.component.Find <UILabel>("AllGood").isVisible       = false;
            infoPanel.component.Find <UIPanel>("ProblemsPanel").isVisible = false;

            assetNameLabel = CreateLabel
                             (
                "AssetName: <>", 160, 24,
                infoPanel.component,
                new Vector3(8.0f, 48.0f, 0.0f),
                UIAlignAnchor.TopLeft
                             );

            showExplorerButton = CreateButton
                                 (
                "Find in SceneExplorer", 160, 24,
                infoPanel.component,
                showExplorerButtonOffset,
                UIAlignAnchor.TopRight,
                (component, param) =>
            {
                InstanceID instance = ReflectionUtil.GetPrivate <InstanceID>(infoPanel, "m_InstanceID");
                sceneExplorer.ExpandFromRefChain(buildingsBufferRefChain.Add(instance.Building));
                sceneExplorer.visible = true;
            }
                                 );

            dumpMeshTextureButton = CreateButton
                                    (
                "Dump asset", 160, 24,
                infoPanel.component,
                dumpMeshTextureButtonOffset,
                UIAlignAnchor.TopRight,
                (component, param) =>
            {
                var instance  = ReflectionUtil.GetPrivate <InstanceID>(infoPanel, "m_InstanceID");
                var building  = BuildingManager.instance.m_buildings.m_buffer[instance.Building];
                var assetName = building.Info.name;
                DumpUtil.DumpAsset(assetName, building.Info.m_mesh, building.Info.m_material, building.Info.m_lodMesh, building.Info.m_lodMaterial);
            }
                                    );
        }
コード例 #10
0
        public void DumpProps()
        {
            //so far dumps all props in road - problem is that dumping the mesh for most props doesn't work since most are "unreadable" in ModTools
            //tried investigating getting mesh from the sharedassets11.assets file in /Cities_Data but can't figure out how to load the file directly into the mod

            //Open to any pointers in how to solve this, If you are reading this and know a way feel free to make a new issue in GitHub
            Debug.Log(loadedPrefab.m_lanes.Length + " Lanes Exist");
            for (int i = 0; i < loadedPrefab.m_lanes.Length; i++)
            {
                NetLaneProps LaneJProps = loadedPrefab.m_lanes[i].m_laneProps;
                Debug.Log("lane" + i + "props len: " + LaneJProps.m_props.Length);

                for (int j = 0; j < LaneJProps.m_props.Length; j++)
                {
                    PropInfo a = loadedPrefab.m_lanes[i].m_laneProps.m_props[j].m_prop;
                    Debug.Log(a.name);
                    DumpUtil.DumpMeshAndTextures(a.name, a.m_mesh, a.m_material);
                }
            }
        }
コード例 #11
0
ファイル: DumpJson.cs プロジェクト: csinkers/ualbion
    public void Dump(string baseDir, ISet <AssetType> types, AssetId[] dumpIds)
    {
        var disposeList = new List <IDisposable>();

        TextWriter Writer(string name)
        {
            var filename  = Path.Combine(baseDir, "data", "exported", "json", name);
            var directory = Path.GetDirectoryName(filename);

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }

            var stream = File.Open(filename, FileMode.Create);
            var writer = new StreamWriter(stream);

            disposeList.Add(writer);
            disposeList.Add(stream);
            return(writer);
        }

        void Flush()
        {
            foreach (var d in disposeList)
            {
                d.Dispose();
            }
            disposeList.Clear();
        }

        var settings = new JsonSerializerSettings
        {
            Formatting           = Formatting.Indented,
            DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate,
        };

        var        assets = Resolve <IAssetManager>();
        var        s      = JsonSerializer.Create(settings);
        TextWriter tw;

        if (types.Contains(AssetType.Tileset))
        {
            foreach (var id in DumpUtil.All(AssetType.Tileset, dumpIds))
            {
                TilesetData asset = assets.LoadTileData(id);
                if (asset == null)
                {
                    continue;
                }
                tw = Writer($"tilesets/tileset{id.Id}.json");
                s.Serialize(tw, asset);
            }

            Flush();
        }

        if (types.Contains(AssetType.Labyrinth))
        {
            foreach (var id in DumpUtil.All(AssetType.Labyrinth, dumpIds))
            {
                LabyrinthData asset = assets.LoadLabyrinthData(id);
                if (asset == null)
                {
                    continue;
                }
                tw = Writer($"labdata/labyrinth{id.Id}.json");
                s.Serialize(tw, asset);
            }

            Flush();
        }

        // string str = assets.LoadString(StringId id, GameLanguage language);

        if (types.Contains(AssetType.Map))
        {
            foreach (var id in DumpUtil.All(AssetType.Map, dumpIds))
            {
                IMapData asset = assets.LoadMap(id);
                if (asset == null)
                {
                    continue;
                }
                tw = Writer($"maps/map{id.Id}_{id}.json");
                s.Serialize(tw, asset);
            }

            Flush();
        }

        if (types.Contains(AssetType.Item))
        {
            tw = Writer("items.json");
            s.Serialize(tw, DumpUtil.AllAssets(AssetType.Item, dumpIds, x => assets.LoadItem(x)));
            Flush();
        }

        if (types.Contains(AssetType.Party))
        {
            tw = Writer("party_members.json");
            s.Serialize(tw, DumpUtil.AllAssets(AssetType.Party, dumpIds, x => assets.LoadSheet(x)));
            Flush();
        }

        if (types.Contains(AssetType.Npc))
        {
            tw = Writer("npcs.json");
            s.Serialize(tw, DumpUtil.AllAssets(AssetType.Npc, dumpIds, x => assets.LoadSheet(x)));
            Flush();
        }

        if (types.Contains(AssetType.Monster))
        {
            tw = Writer("monsters.json");
            s.Serialize(tw, DumpUtil.AllAssets(AssetType.Monster, dumpIds, x => assets.LoadSheet(x)));
            Flush();
        }

        if (types.Contains(AssetType.Chest))
        {
            tw = Writer("chests.json");
            s.Serialize(tw, DumpUtil.AllAssets(AssetType.Chest, dumpIds, assets.LoadInventory));
            Flush();
        }

        if (types.Contains(AssetType.Merchant))
        {
            tw = Writer("merchants.json");
            s.Serialize(tw, DumpUtil.AllAssets(AssetType.Merchant, dumpIds, assets.LoadInventory));
            Flush();
        }

        if (types.Contains(AssetType.BlockList))
        {
            foreach (var id in DumpUtil.All(AssetType.BlockList, dumpIds))
            {
                IList <Block> asset = assets.LoadBlockList(id);
                if (asset == null)
                {
                    continue;
                }
                tw = Writer($"blocks/blocklist{id.Id}.json");
                s.Serialize(tw, asset);
            }
            Flush();
        }

        if (types.Contains(AssetType.EventSet))
        {
            tw = Writer("event_sets.json");
            s.Serialize(tw, DumpUtil.AllAssets(AssetType.EventSet, dumpIds, x => assets.LoadEventSet(x)));
            Flush();
        }

        if (types.Contains(AssetType.Script))
        {
            foreach (var id in DumpUtil.All(AssetType.Script, dumpIds))
            {
                IList <IEvent> asset = assets.LoadScript(id);
                if (asset == null)
                {
                    continue;
                }
                tw = Writer($"scripts/script{id.Id}.json");
                s.Serialize(tw, asset.Select(x => x.ToString()).ToArray());
            }
            Flush();
        }

        if (types.Contains(AssetType.Spell))
        {
            tw = Writer("spells.json");
            s.Serialize(tw, DumpUtil.AllAssets(AssetType.Spell, dumpIds, x => assets.LoadSpell(x)));
            Flush();
        }

        if (types.Contains(AssetType.MonsterGroup))
        {
            tw = Writer("monster_groups.json");
            s.Serialize(tw, DumpUtil.AllAssets(AssetType.MonsterGroup, dumpIds, x => assets.LoadMonsterGroup(x)));
            Flush();
        }

        if (types.Contains(AssetType.Palette))
        {
            foreach (var id in DumpUtil.All(AssetType.Palette, dumpIds))
            {
                tw = Writer($"palettes/palette{id.Id}_{id}.json");
                var palette = assets.LoadPalette(id);
                s.Serialize(tw, palette);
            }
            Flush();
        }
    }
コード例 #12
0
 public static void SetupButtons(Type type, object value, ReferenceChain refChain)
 {
     if (value is VehicleInfo)
     {
         var info = (VehicleInfo)value;
         if (info.m_mesh != null)
         {
             if (GUILayout.Button("Preview"))
             {
                 MeshViewer.CreateMeshViewer(info.name, info.m_mesh, info.m_material);
             }
         }
         if (info.m_lodMesh != null)
         {
             if (GUILayout.Button("Preview LOD"))
             {
                 MeshViewer.CreateMeshViewer(info.name + "_LOD", info.m_lodMesh, info.m_lodMaterial);
             }
         }
     }
     else if (value is NetInfo)
     {
         SetupPlopButton(value);
     }
     else if (value is BuildingInfo)
     {
         var info = (BuildingInfo)value;
         SetupPlopButton(value);
         if (info.m_mesh != null)
         {
             if (GUILayout.Button("Preview"))
             {
                 MeshViewer.CreateMeshViewer(info.name, info.m_mesh, info.m_material);
             }
         }
         if (info.m_lodMesh != null)
         {
             if (GUILayout.Button("Preview LOD"))
             {
                 MeshViewer.CreateMeshViewer(info.name + "_LOD", info.m_lodMesh, info.m_lodMaterial);
             }
         }
     }
     else if (value is PropInfo)
     {
         var info = (PropInfo)value;
         SetupPlopButton(value);
         if (info.m_mesh != null)
         {
             if (GUILayout.Button("Preview"))
             {
                 MeshViewer.CreateMeshViewer(info.name, info.m_mesh, info.m_material);
             }
         }
         if (info.m_lodMesh != null)
         {
             if (GUILayout.Button("Preview LOD"))
             {
                 MeshViewer.CreateMeshViewer(info.name + "_LOD", info.m_lodMesh, info.m_lodMaterial);
             }
         }
     }
     else if (value is TreeInfo)
     {
         var info = (TreeInfo)value;
         SetupPlopButton(value);
         if (info.m_mesh != null)
         {
             if (GUILayout.Button("Preview"))
             {
                 MeshViewer.CreateMeshViewer(info.name, info.m_mesh, info.m_material);
             }
         }
     }
     else if (value is CitizenInfo)
     {
         var info = (CitizenInfo)value;
         if (info.m_lodMesh != null)
         {
             if (GUILayout.Button("Preview LOD"))
             {
                 MeshViewer.CreateMeshViewer(info.name, info.m_lodMesh, info.m_lodMaterial);
             }
         }
     }
     else if (value is MilestoneInfo)
     {
         var info = (MilestoneInfo)value;
         if (GUILayout.Button("Unlock"))
         {
             var wrapper = new MilestonesWrapper(UnlockManager.instance);
             wrapper.UnlockMilestone(info.name);
         }
     }
     else if (value is NetInfo.Segment)
     {
         var info = (NetInfo.Segment)value;
         if (info.m_mesh != null)
         {
             if (GUILayout.Button("Preview"))
             {
                 MeshViewer.CreateMeshViewer(null, info.m_mesh, info.m_material);
             }
             if (GUILayout.Button("Preview LOD"))
             {
                 MeshViewer.CreateMeshViewer(null, info.m_lodMesh, info.m_lodMaterial);
             }
         }
     }
     else if (value is NetInfo.Node)
     {
         var info = (NetInfo.Node)value;
         if (info.m_mesh != null)
         {
             if (GUILayout.Button("Preview"))
             {
                 MeshViewer.CreateMeshViewer(null, info.m_mesh, info.m_material);
             }
             if (GUILayout.Button("Preview LOD"))
             {
                 MeshViewer.CreateMeshViewer(null, info.m_lodMesh, info.m_lodMaterial);
             }
         }
     }
     else if (TypeUtil.IsTextureType(type) && value != null)
     {
         var texture = (Texture)value;
         if (GUILayout.Button("Preview"))
         {
             TextureViewer.CreateTextureViewer(refChain, texture);
         }
         if (GUILayout.Button("Dump .png"))
         {
             TextureUtil.DumpTextureToPNG(texture);
         }
     }
     else if (TypeUtil.IsMeshType(type) && value != null)
     {
         if (GUILayout.Button("Preview"))
         {
             MeshViewer.CreateMeshViewer(null, (Mesh)value, null);
         }
         if (((Mesh)value).isReadable)
         {
             if (GUILayout.Button("Dump .obj"))
             {
                 var outPath = refChain.ToString().Replace(' ', '_');
                 DumpUtil.DumpMeshAndTextures(outPath, value as Mesh);
             }
         }
     }
     if (GUILayout.Button("Copy"))
     {
         _buffer = value;
     }
 }
コード例 #13
0
        protected override void DrawWindow()
        {
            if (previewMesh == null)
            {
                Title = "Mesh Viewer";
                GUILayout.Label("Use the Scene Explorer to select a Mesh for preview");
                return;
            }

            Title = $"Previewing \"{assetName ?? previewMesh.name}\"";

            GUILayout.BeginHorizontal();

            if (material != null)
            {
                useOriginalShader = GUILayout.Toggle(useOriginalShader, "Original Shader");
                if (previewMesh.isReadable)
                {
                    if (GUILayout.Button("Dump mesh+textures", GUILayout.Width(160)))
                    {
                        DumpUtil.DumpMeshAndTextures(assetName ?? previewMesh.name, previewMesh, material);
                    }
                }
                else if (GUILayout.Button("Dump textures", GUILayout.Width(160)))
                {
                    DumpUtil.DumpTextures(assetName, material);
                }
            }
            else
            {
                useOriginalShader = false;
                if (previewMesh.isReadable && GUILayout.Button("Dump mesh", GUILayout.Width(160)))
                {
                    DumpUtil.DumpMeshAndTextures($"{previewMesh.name}", previewMesh);
                }
            }

            if (previewMesh.isReadable)
            {
                GUILayout.Label($"Triangles: {previewMesh.triangles.Length / 3}");
            }
            else
            {
                var oldColor = GUI.color;
                GUI.color = Color.yellow;
                GUILayout.Label("Mesh isn't readable!");
                GUI.color = oldColor;
            }

            if (material?.mainTexture != null)
            {
                GUILayout.Label($"Texture size: {material.mainTexture.width}x{material.mainTexture.height}");
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            if (Event.current.type == EventType.MouseDown)
            {
                if (Event.current.button == 0 || Event.current.button == 2)
                {
                    lastLeftMousePos = Event.current.mousePosition;
                }
                else
                {
                    lastRightMousePos = Event.current.mousePosition;
                }
            }
            else if (Event.current.type == EventType.MouseDrag)
            {
                var pos = Event.current.mousePosition;
                if (Event.current.button == 0 || Event.current.button == 2)
                {
                    if (lastLeftMousePos != Vector2.zero)
                    {
                        var moveDelta = (pos - lastLeftMousePos) * 2.0f;
                        previewDir -= moveDelta / Mathf.Min(targetRT.width, targetRT.height)
                                      * UIView.GetAView().ratio * 140f;
                        previewDir.y = Mathf.Clamp(previewDir.y, -90f, 90f);
                    }

                    lastLeftMousePos = pos;
                }
                else
                {
                    if (lastRightMousePos != Vector2.zero)
                    {
                        var moveDelta1 = pos - lastRightMousePos;
                        distance += (float)(moveDelta1.y / (double)targetRT.height
                                            * UIView.GetAView().ratio * 40.0);
                        const float num1      = 6f;
                        var         magnitude = bounds.extents.magnitude;
                        var         num2      = magnitude + 16f;
                        distance = Mathf.Min(distance, 4f, num1 * (num2 / magnitude));
                    }

                    lastRightMousePos = pos;
                }
            }

            GUI.DrawTexture(new Rect(0.0f, 64.0f, WindowRect.width, WindowRect.height - 64.0f), targetRT, ScaleMode.StretchToFill, false);
        }
コード例 #14
0
        void DrawWindow()
        {
            if (previewMesh != null)
            {
                title = $"Previewing \"{assetName ?? previewMesh.name}\"";

                GUILayout.BeginHorizontal();

                if (material != null)
                {
                    useOriginalShader = GUILayout.Toggle(useOriginalShader, "Original Shader");
                    if (previewMesh.isReadable)
                    {
                        if (GUILayout.Button("Dump mesh+textures", GUILayout.Width(160)))
                        {
                            DumpUtil.DumpMeshAndTextures(assetName, previewMesh, material);
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("Dump textures", GUILayout.Width(160)))
                        {
                            DumpUtil.DumpTextures(assetName, material);
                        }
                    }
                }
                else
                {
                    useOriginalShader = false;
                    if (previewMesh.isReadable)
                    {
                        if (GUILayout.Button("Dump mesh", GUILayout.Width(160)))
                        {
                            DumpUtil.DumpMeshAndTextures($"{previewMesh.name}", previewMesh);
                        }
                    }
                }
                if (previewMesh.isReadable)
                {
                    GUILayout.Label($"Triangles: {previewMesh.triangles.Length / 3}");
                }
                else
                {
                    var oldColor = GUI.color;
                    GUI.color = Color.yellow;
                    GUILayout.Label("Mesh insn't readable!");
                    GUI.color = oldColor;
                }
                if (material?.mainTexture != null)
                {
                    GUILayout.Label($"Texture size: {material.mainTexture.width}x{material.mainTexture.height}");
                }

                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                if (Event.current.type == EventType.MouseDown)
                {
                    lastMousePos = Event.current.mousePosition;
                }
                else if (Event.current.type == EventType.MouseDrag)
                {
                    var pos = Event.current.mousePosition;
                    if (lastMousePos != Vector2.zero)
                    {
                        var delta = pos - lastMousePos;
                        zoom     += delta.y;
                        rotation *= Quaternion.Euler(0.0f, -delta.x, 0.0f);
                    }
                    lastMousePos = pos;
                }

                GUI.DrawTexture(new Rect(0.0f, 64.0f, rect.width, rect.height - 64.0f), targetRT, ScaleMode.StretchToFill, false);
            }
            else
            {
                title = "Mesh Viewer";
                GUILayout.Label("Use the Scene Explorer to select a Mesh for preview");
            }
        }
コード例 #15
0
        private static void Dump(string[] args)
        {
            // Drag & Drop save file folder.
            if (args.Length == 1)
            {
                var first = args[0];
                if (Directory.Exists(first))
                {
                    Console.WriteLine("Extracting save data...");
                    SaveDumper.ExtractEntries(first, first);
                    Console.WriteLine("Done!");
                    return;
                }

                if (File.Exists(first))
                {
                    Console.WriteLine("Extracting save data...");
                    SaveDumper.ExtractFile(first);
                    Console.WriteLine("Done!");
                    return;
                }
            }

            if (args.Length is not(2 or 3 or 4))
            {
                PrintUsage();
                return;
            }

            var mode = args[0];
            var path = args[1];

            switch (mode)
            {
            case "-sav" when File.Exists(path):
            {
                var index = SaveReader.GetIndex(Path.GetFileNameWithoutExtension(path));

                string GetDestination()
                {
                    var p = args.Length > 2 ? args[2] : Directory.GetParent(Path.GetFullPath(path)).FullName;

                    return(Path.Combine(p, $"{index:00}"));
                }

                var dest = GetDestination();
                SaveDumper.ExtractFiles(path, dest, index);
                break;
            }

            case "-sav" when !Directory.Exists(path):
                Console.WriteLine("Input save file directory not found.");
                return;

            case "-sav":
            {
                var dest = args.Length == 3 ? args[2] : path;
                SaveDumper.ExtractEntries(path, dest);
                break;
            }

            case "-drp" when Directory.Exists(path):
            {
                var dest = args.Length == 3 ? args[2] : path;
                DumpUtil.DumpAllDrp(path, dest);
                break;
            }

            case "-drp" when !File.Exists(path):
                Console.WriteLine("Input drp file not found.");
                return;

            case "-drp":
            {
                var dest = args.Length == 3 ? args[2] : Path.GetFullPath(path);
                DumpUtil.DumpToPath(path, dest);
                break;
            }

            case "-ms" or "-mf" when !File.Exists(path):
                Console.WriteLine("Input drp file not found.");
                return;

            case "-ms" when args.Length > 2 && File.Exists(args[2]):     // src, inj
                DrpArchiveChanger.Replace(path, path, args[2..]);