add open asset bundle

master
wlt233 2 years ago
parent fec62609c6
commit 7f68ce6801

@ -0,0 +1,82 @@
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using UnityEngine;
public static class FileUtil
{ // My Super Fucking File Manager
public static string OpenFile()
{
FileOpenDialog dialog = new FileOpenDialog();
dialog.structSize = Marshal.SizeOf(dialog);
dialog.filter = "All Files\0*\0\0";
dialog.file = new string(new char[256]);
dialog.maxFile = dialog.file.Length;
dialog.fileTitle = new string(new char[64]);
dialog.maxFileTitle = dialog.fileTitle.Length;
dialog.initialDir = UnityEngine.Application.dataPath;
dialog.title = "Open Card Asset Bundle";
dialog.defExt = "";
dialog.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000008;
//OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST|OFN_NOCHANGEDIR
if (DialogShow.GetOpenFileName(dialog))
{
Debug.Log(dialog.file);
return dialog.file;
}
return "";
}
public static void WatchFile(string dirPath, string filename, FileSystemEventHandler handler)
{
var watcher = new FileSystemWatcher(dirPath);
watcher.NotifyFilter = NotifyFilters.LastWrite;
watcher.Changed += handler;
watcher.Filter = filename;
watcher.EnableRaisingEvents = true;
}
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public class FileOpenDialog
{
public int structSize = 0;
public IntPtr dlgOwner = IntPtr.Zero;
public IntPtr instance = IntPtr.Zero;
public String filter = null;
public String customFilter = null;
public int maxCustFilter = 0;
public int filterIndex = 0;
public String file = null;
public int maxFile = 0;
public String fileTitle = null;
public int maxFileTitle = 0;
public String initialDir = null;
public String title = null;
public int flags = 0;
public short fileOffset = 0;
public short fileExtension = 0;
public String defExt = null;
public IntPtr custData = IntPtr.Zero;
public IntPtr hook = IntPtr.Zero;
public String templateName = null;
public IntPtr reservedPtr = IntPtr.Zero;
public int reservedInt = 0;
public int flagsEx = 0;
}
public class DialogShow
{
[DllImport("Comdlg32.dll", SetLastError = true, ThrowOnUnmappableChar = true, CharSet = CharSet.Auto)]
public static extern bool GetOpenFileName([In, Out] FileOpenDialog dialog);
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 74ab086419b583d4686de800dfe08671
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 51fcc10415dcbf74c96b465d2f94acb0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,242 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
//using DG.Tweening;
// code disassembled from version 3.17.1
namespace Illusion
{
[Serializable]
public class weaponMaterialType
{
// Token: 0x06009E4E RID: 40526 RVA: 0x00002053 File Offset: 0x00000253
//[Token(Token = "0x6007965")]
//[Address(RVA = "0x3429360", Offset = "0x3429360", VA = "0x3429360")]
public weaponMaterialType()
{
;
}
// Token: 0x04005EB1 RID: 24241
//[Token(Token = "0x4003D49")]
//[FieldOffset(Offset = "0x10")]
public int colorIndex;
// Token: 0x04005EB2 RID: 24242
//[Token(Token = "0x4003D4A")]
//[FieldOffset(Offset = "0x18")]
public Material colorMat;
}
[Serializable]
public class SpecialEffectType
{
// Token: 0x06009E4F RID: 40527 RVA: 0x00002053 File Offset: 0x00000253
//[Token(Token = "0x6007966")]
//[Address(RVA = "0x2F3C290", Offset = "0x2F3C290", VA = "0x2F3C290")]
public SpecialEffectType()
{
;
}
// Token: 0x04005EB3 RID: 24243
//[Token(Token = "0x4003D4B")]
//[FieldOffset(Offset = "0x10")]
public int id;
// Token: 0x04005EB4 RID: 24244
//[Token(Token = "0x4003D4C")]
//[FieldOffset(Offset = "0x18")]
public GameObject effect;
}
//[Token(Token = "0x2000AE4")]
public enum WeaponMode
{
// Token: 0x04004FD6 RID: 20438
//[Token(Token = "0x4003349")]
WeaponTypeA = 1,
// Token: 0x04004FD7 RID: 20439
//[Token(Token = "0x400334A")]
WeaponTypeB
}
public class WeaponController : MonoBehaviour // TypeDefIndex: 10711
{
// Fields
public Animator weapon; // 0x18
[SerializeField] // RVA: 0x16333E0 Offset: 0x16333E0 VA: 0x16333E0
private SkinnedMeshRenderer meshRenderer; // 0x20
[SerializeField] // RVA: 0x16333F0 Offset: 0x16333F0 VA: 0x16333F0
//private weaponMaterialType[] weaponMaterialList; // 0x28
public weaponMaterialType[] weaponMaterialList; // 0x28
[SerializeField] // RVA: 0x1633400 Offset: 0x1633400 VA: 0x1633400
private Transform[] weaponCenterPos; // 0x30
[SerializeField] // RVA: 0x1633410 Offset: 0x1633410 VA: 0x1633410
private GameObject[] weaponEffects1; // 0x38
[SerializeField] // RVA: 0x1633420 Offset: 0x1633420 VA: 0x1633420
private GameObject[] weaponEffects2; // 0x40
[SerializeField] // RVA: 0x1633430 Offset: 0x1633430 VA: 0x1633430
private GameObject[] weaponEffects3; // 0x48
[SerializeField] // RVA: 0x1633440 Offset: 0x1633440 VA: 0x1633440
//private SpecialEffectType[] specialEffectList; // 0x50
public SpecialEffectType[] specialEffectList; // 0x50
private int weaponRarity; // 0x58
// Methods
// RVA: 0x327B8BC Offset: 0x327B8BC VA: 0x327B8BC
private void Start()
{
;
}
// RVA: 0x327B8C0 Offset: 0x327B8C0 VA: 0x327B8C0
public void SetRarerity(int rarityValue)
{
weaponRarity = rarityValue;
for (int i = 0; i < weaponEffects1.Length; i++)
weaponEffects1[i].SetActive(false);
for (int i = 0; i < weaponEffects2.Length; i++)
weaponEffects2[i].SetActive(false);
for (int i = 0; i < weaponEffects3.Length; i++)
weaponEffects3[i].SetActive(false);
if (weaponRarity == 6)
{
for (int i = 0; i < weaponEffects3.Length; i++)
weaponEffects3[i].SetActive(true);
}
else if (weaponRarity == 3)
{
for (int i = 0; i < weaponEffects2.Length; i++)
weaponEffects2[i].SetActive(true);
}
else
{
for (int i = 0; i < weaponEffects1.Length; i++)
weaponEffects1[i].SetActive(true);
}
}
// RVA: 0x327BB74 Offset: 0x327BB74 VA: 0x327BB74
public Vector3 CurrentCenterPosionCheck(int type)
{
// ?
return weaponCenterPos[type].transform.localPosition;
}
// RVA: 0x327BBDC Offset: 0x327BBDC VA: 0x327BBDC
public bool IsPlayingAnimation()
{
// ?
return weapon.GetCurrentAnimatorStateInfo(0).normalizedTime < 1.0;
}
// RVA: 0x327BC58 Offset: 0x327BC58 VA: 0x327BC58
public void ChangeWeaponStyle(int colorIndex)
{
// ?
for (int i = 0; i < weaponMaterialList.Length; i++)
{
if (weaponMaterialList[i].colorIndex == colorIndex)
{
//Material[] t = meshRenderer.materials;
//t[0] = weaponMaterialList[i].colorMat;
//meshRenderer.materials = t;
meshRenderer.material = weaponMaterialList[i].colorMat;
break;
}
}
}
// RVA: 0x327BE28 Offset: 0x327BE28 VA: 0x327BE28
public void WeaponChangeOnly(WeaponMode weaponMode)
{
weapon.SetInteger("Type", (int)weaponMode);
}
// RVA: 0x327BE9C Offset: 0x327BE9C VA: 0x327BE9
public void SetChange(Animator targetAnim, WeaponMode weaponMode)
{
targetAnim.SetTrigger("Change");
WeaponChangeOnly(weaponMode);
}
// RVA: 0x327BF18 Offset: 0x327BF18 VA: 0x327BF18
public void SetAnimeSpeed(float time)
{
weapon.speed = time;
}
// RVA: 0x327BF58 Offset: 0x327BF58 VA: 0x327BF58
public void SetAnimState(float value)
{
weapon.speed = 0.0F;
weapon.Play("Weapon001AnimAB", 0, value);
}
// RVA: 0x327BFF0 Offset: 0x327BFF0 VA: 0x327BFF0
public void SetWeaponMode(int weaponMode)
{
weapon.speed = 0.0F;
if (weaponMode == 1)
{
weapon.Play("Weapon001AnimALoop", 0, 0.0F);
}
else if (weaponMode == 2)
{
weapon.Play("Weapon001AnimBLoop", 0, 0.0F);
}
}
// RVA: 0x327C0C4 Offset: 0x327C0C4 VA: 0x327C0C4
public void WeaponCustomDeform(float time)
{
// ?
weapon.SetInteger("Deform", 2);
/*DOVirtual.DelayedCall(time, () =>
{
weapon.SetInteger("Deform", 1);
}
, true);*/
}
// RVA: 0x327C178 Offset: 0x327C178 VA: 0x327C178
public Material GetWeaponCloneMaterialNeunwelt()
{
return (Material)meshRenderer.materials[0];
}
// RVA: 0x327C2BC Offset: 0x327C2BC VA: 0x327C2BC
public void SetSpecialEffect(int id)
{
if (id >= 1)
{
for (int i = 0; i < specialEffectList.Length; i++)
{
specialEffectList[i].effect.SetActive(false); // modify
if (specialEffectList[i].id == id)
specialEffectList[i].effect.SetActive(true);
}
}
}
// RVA: 0x327C384 Offset: 0x327C384 VA: 0x327C384
//public void .ctor() { }
public WeaponController()
{
weaponRarity = 1;
}
//[CompilerGeneratedAttribute] // RVA: 0x16ADEA8 Offset: 0x16ADEA8 VA: 0x16ADEA8
// RVA: 0x327C394 Offset: 0x327C394 VA: 0x327C394
//private void _<WeaponCustomDeform>b__19_0() { }
}
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 382f5eae359a1e146b2cb0d9bee03ba0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -123,6 +123,7 @@ GameObject:
- component: {fileID: 534669905}
- component: {fileID: 534669904}
- component: {fileID: 534669903}
- component: {fileID: 534669906}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
@ -161,8 +162,8 @@ Camera:
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
far clip plane: 100
field of view: 50
orthographic: 0
orthographic size: 5
m_Depth: -1
@ -187,10 +188,22 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 534669902}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -10}
m_LocalRotation: {x: 0, y: 0.7071068, z: 0, w: 0.7071068}
m_LocalPosition: {x: -30, y: 0, z: -8}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_LocalEulerAnglesHint: {x: 0, y: 90, z: 0}
--- !u!114 &534669906
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 534669902}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0f380ef75cfc644449da67063fa2fc84, type: 3}
m_Name:
m_EditorClassIdentifier:

@ -1,16 +1,71 @@
using System.Collections;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Illusion;
public class main : MonoBehaviour
public class Main : MonoBehaviour
{
// Start is called before the first frame update
private string abPath = "";
private string abDir;
private List<string> abNameList = new List<string>();
private int idx = 0;
private int count;
private GameObject charm;
private WeaponController controller;
public List<int> styleId;
private int style = -1;
public List<int> effectId;
private int effect = -1;
private int mode = -1;
void Start()
{
if (abPath == "" || abPath == "null")
{
abPath = FileUtil.OpenFile();
}
FileInfo fileInfo = new FileInfo(abPath);
abDir = fileInfo.DirectoryName;
DirectoryInfo folderInfo = new DirectoryInfo(abDir);
int t = 0;
foreach (FileInfo NextFile in folderInfo.GetFiles())
{
Debug.Log(NextFile.Name);
abNameList.Add(NextFile.Name);
if (NextFile.Name == fileInfo.Name)
{
idx = t;
}
t++;
}
count = abNameList.Count;
var bundle = AssetBundle.LoadFromFile(abDir + '\\' +abNameList[idx % count]);
foreach (var name in bundle.GetAllAssetNames())
{
Debug.Log(name);
charm = (GameObject)Instantiate(bundle.LoadAsset(name));
charm.transform.localScale = new Vector3(100, 100, 100);
controller = charm.GetComponent<WeaponController>();
//charm.AddComponent<MouseControlModel>();
styleId.Clear();
for (int i = 0; i < controller.weaponMaterialList.Length; i++)
{
styleId.Add(controller.weaponMaterialList[i].colorIndex);
}
effectId.Clear();
for (int i = 0; i < controller.specialEffectList.Length; i++)
{
effectId.Add(controller.specialEffectList[i].id);
}
}
bundle.Unload(false);
}
// Update is called once per frame
void Update()
{

Loading…
Cancel
Save