add action ui; add hotkey; add face override

master
wlt233 8 months ago
parent c65f8d7986
commit adcb6e7f54

@ -8,12 +8,14 @@ using UnityEngine.UI;
public class Main : MonoBehaviour public class Main : MonoBehaviour
{ {
#region var #region var
private GameObject chara; public GameObject chara;
private GameObject weapon; private GameObject weapon;
private GameObject weaponL; private GameObject weaponL;
private GameObject weaponR; private GameObject weaponR;
private GameObject attachment; private GameObject attachment;
private RuntimeAnimatorController originAnimator; private RuntimeAnimatorController originAnimator;
private SkinnedMeshRenderer charaFaceRender;
private int faceOverride = 0;
private string basePath = "F:/Ongeki_Unity/ab/"; private string basePath = "F:/Ongeki_Unity/ab/";
public Dictionary<string, List<string>> charaAssetsNames = new Dictionary<string, List<string>>(); public Dictionary<string, List<string>> charaAssetsNames = new Dictionary<string, List<string>>();
@ -21,6 +23,7 @@ public class Main : MonoBehaviour
public Dictionary<string, List<string>> attachmentAssetsNames = new Dictionary<string, List<string>>(); public Dictionary<string, List<string>> attachmentAssetsNames = new Dictionary<string, List<string>>();
public Dictionary<string, string> charaWeapon = new Dictionary<string, string>(); public Dictionary<string, string> charaWeapon = new Dictionary<string, string>();
public Dictionary<string, string> attachmentPosition = new Dictionary<string, string>(); public Dictionary<string, string> attachmentPosition = new Dictionary<string, string>();
public float speed;
#endregion #endregion
void Start() void Start()
@ -29,7 +32,8 @@ public class Main : MonoBehaviour
loadCharaCSV(); loadCharaCSV();
loadWeaponCSV(); loadWeaponCSV();
loadAttachmentCSV(); loadAttachmentCSV();
speed = 1.0f;
GameObject.Find("charaDropdown").GetComponent<Dropdown>().value = 14; GameObject.Find("charaDropdown").GetComponent<Dropdown>().value = 14;
} }
@ -122,6 +126,8 @@ public class Main : MonoBehaviour
charaAssetsNames.TryGetValue(charaName, out assetNames); charaAssetsNames.TryGetValue(charaName, out assetNames);
loadPrefab(charaName, assetNames, ref chara); loadPrefab(charaName, assetNames, ref chara);
if (charaWeapon[charaName] != null) loadWeapon(charaWeapon[charaName]); if (charaWeapon[charaName] != null) loadWeapon(charaWeapon[charaName]);
originAnimator = chara.GetComponent<Animator>().runtimeAnimatorController;
charaFaceRender = chara.GetComponentsInChildren<SkinnedMeshRenderer>()[1];
} }
#endregion #endregion
@ -155,6 +161,7 @@ public class Main : MonoBehaviour
Destroy(parent.GetChild(i).gameObject); Destroy(parent.GetChild(i).gameObject);
Transform childL = Utils.findChildRecursive(weaponL.transform, "l_weapon"); Transform childL = Utils.findChildRecursive(weaponL.transform, "l_weapon");
Transform childR = Utils.findChildRecursive(weaponL.transform, "r_weapon"); Transform childR = Utils.findChildRecursive(weaponL.transform, "r_weapon");
removeWeaponButtonListener("L");
if (childL != null) if (childL != null)
{ {
addWeaponButtonListener(childL.gameObject.AddComponent<RemoveAnimationTransfrom>(), "L"); addWeaponButtonListener(childL.gameObject.AddComponent<RemoveAnimationTransfrom>(), "L");
@ -181,6 +188,7 @@ public class Main : MonoBehaviour
Destroy(parent.GetChild(i).gameObject); Destroy(parent.GetChild(i).gameObject);
Transform childL = Utils.findChildRecursive(weaponR.transform, "l_weapon"); Transform childL = Utils.findChildRecursive(weaponR.transform, "l_weapon");
Transform childR = Utils.findChildRecursive(weaponR.transform, "r_weapon"); Transform childR = Utils.findChildRecursive(weaponR.transform, "r_weapon");
removeWeaponButtonListener("R");
if (childL != null) if (childL != null)
{ {
addWeaponButtonListener(childL.gameObject.AddComponent<RemoveAnimationTransfrom>(), "R"); addWeaponButtonListener(childL.gameObject.AddComponent<RemoveAnimationTransfrom>(), "R");
@ -263,8 +271,6 @@ public class Main : MonoBehaviour
var animatorName = names[i]; var animatorName = names[i];
var bundle = AssetBundle.LoadFromFile(basePath + animatorName); var bundle = AssetBundle.LoadFromFile(basePath + animatorName);
var aoc = bundle.LoadAsset<AnimatorOverrideController>(animatorName); var aoc = bundle.LoadAsset<AnimatorOverrideController>(animatorName);
if (originAnimator == null)
originAnimator = chara.GetComponent<Animator>().runtimeAnimatorController;
chara.GetComponent<Animator>().runtimeAnimatorController = aoc; chara.GetComponent<Animator>().runtimeAnimatorController = aoc;
bundle.Unload(false); bundle.Unload(false);
} }
@ -273,18 +279,31 @@ public class Main : MonoBehaviour
#region Internal #region Face
void addWeaponButtonListener(RemoveAnimationTransfrom rat, string LR) public void setFace(int i)
{
GameObject.Find("faceDropdown").GetComponent<Dropdown>().value = i;
faceOverride = i;
}
#endregion
#region Model Internal
void removeWeaponButtonListener(string LR)
{ {
GameObject.Find(string.Format("weapon{0}x", LR)).GetComponent<Button>().onClick.RemoveAllListeners(); GameObject.Find(string.Format("weapon{0}x", LR)).GetComponent<Button>().onClick.RemoveAllListeners();
GameObject.Find(string.Format("weapon{0}x", LR)).GetComponent<Button>().onClick.AddListener(rat.xReverse);
GameObject.Find(string.Format("weapon{0}y", LR)).GetComponent<Button>().onClick.RemoveAllListeners(); GameObject.Find(string.Format("weapon{0}y", LR)).GetComponent<Button>().onClick.RemoveAllListeners();
GameObject.Find(string.Format("weapon{0}y", LR)).GetComponent<Button>().onClick.AddListener(rat.yReverse);
GameObject.Find(string.Format("weapon{0}z", LR)).GetComponent<Button>().onClick.RemoveAllListeners(); GameObject.Find(string.Format("weapon{0}z", LR)).GetComponent<Button>().onClick.RemoveAllListeners();
GameObject.Find(string.Format("weapon{0}z", LR)).GetComponent<Button>().onClick.AddListener(rat.zReverse);
GameObject.Find(string.Format("weapon{0}p", LR)).GetComponent<Button>().onClick.RemoveAllListeners(); GameObject.Find(string.Format("weapon{0}p", LR)).GetComponent<Button>().onClick.RemoveAllListeners();
GameObject.Find(string.Format("weapon{0}p", LR)).GetComponent<Button>().onClick.AddListener(rat.zPlus);
GameObject.Find(string.Format("weapon{0}m", LR)).GetComponent<Button>().onClick.RemoveAllListeners(); GameObject.Find(string.Format("weapon{0}m", LR)).GetComponent<Button>().onClick.RemoveAllListeners();
}
void addWeaponButtonListener(RemoveAnimationTransfrom rat, string LR)
{
GameObject.Find(string.Format("weapon{0}x", LR)).GetComponent<Button>().onClick.AddListener(rat.xReverse);
GameObject.Find(string.Format("weapon{0}y", LR)).GetComponent<Button>().onClick.AddListener(rat.yReverse);
GameObject.Find(string.Format("weapon{0}z", LR)).GetComponent<Button>().onClick.AddListener(rat.zReverse);
GameObject.Find(string.Format("weapon{0}p", LR)).GetComponent<Button>().onClick.AddListener(rat.zPlus);
GameObject.Find(string.Format("weapon{0}m", LR)).GetComponent<Button>().onClick.AddListener(rat.zMinus); GameObject.Find(string.Format("weapon{0}m", LR)).GetComponent<Button>().onClick.AddListener(rat.zMinus);
} }
@ -322,35 +341,159 @@ public class Main : MonoBehaviour
#region Action
public void setState(int i)
{
if (i != 1) removeWeapon();
if (i == 2 || i == 3) chara.transform.rotation = Quaternion.Euler(0, 180, 0);
else chara.transform.rotation = Quaternion.Euler(0, 0, 0);
if (chara.GetComponent<Animator>() != null)
chara.GetComponent<Animator>().SetInteger(Animator.StringToHash("State"), i);
}
public void setRoom(int i)
{
setState(6);
string[] names = {
"RoomAwake",
"RoomPresent", // not implement
"RoomFavorite",
"RoomJoy",
"RoomFaint"
};
setTrigger(names[i]);
}
void Update() public void setTurn(float i)
{
setState(1);
setFloat("Turn", i);
}
public void setDamageScale(float i)
{
setState(1);
setFloat("Damage_Scale", i);
}
public void setDamage()
{
setState(1);
setTrigger("Damage");
}
public void setHolding(bool i)
{ {
setState(1);
setBool("Holding", i);
}
public void setAttack(int i)
{
setState(1);
if (i == 1 || i == 2 || i == 3) setFace(1);
string[] names = {
"Attack_A",
"Attack_A_002",
"Attack_A_003",
"Attack_A_004",
"Attack_B"
};
setTrigger(names[i]);
}
public void setSpeed(float value)
{
speed = value;
if (chara.GetComponent<Animator>() != null)
chara.GetComponent<Animator>().speed = value;
if (weapon && weapon.GetComponent<Animator>() != null)
weapon.GetComponent<Animator>().speed = value;
if (weaponL && weaponL.GetComponent<Animator>() != null)
weaponL.GetComponent<Animator>().speed = value;
if (weaponR && weaponR.GetComponent<Animator>() != null)
weaponR.GetComponent<Animator>().speed = value;
GameObject.Find("speedinput").GetComponent<InputField>().text = String.Format("{0:0.00}", value);
}
#endregion
#region Action Internal
void setTrigger(string triggerName)
{
if (chara.GetComponent<Animator>() != null)
chara.GetComponent<Animator>().SetTrigger(Animator.StringToHash(triggerName));
if (weapon && weapon.GetComponent<Animator>() != null)
weapon.GetComponent<Animator>().SetTrigger(Animator.StringToHash(triggerName));
if (weaponL && weaponL.GetComponent<Animator>() != null)
weaponL.GetComponent<Animator>().SetTrigger(Animator.StringToHash(triggerName));
if (weaponR && weaponR.GetComponent<Animator>() != null)
weaponR.GetComponent<Animator>().SetTrigger(Animator.StringToHash(triggerName));
}
void setFloat(string triggerName, float value)
{
if (chara.GetComponent<Animator>() != null)
chara.GetComponent<Animator>().SetFloat(Animator.StringToHash(triggerName), value);
if (weapon && weapon.GetComponent<Animator>() != null)
weapon.GetComponent<Animator>().SetFloat(Animator.StringToHash(triggerName), value);
if (weaponL && weaponL.GetComponent<Animator>() != null)
weaponL.GetComponent<Animator>().SetFloat(Animator.StringToHash(triggerName), value);
if (weaponR && weaponR.GetComponent<Animator>() != null)
weaponR.GetComponent<Animator>().SetFloat(Animator.StringToHash(triggerName), value);
}
void setBool(string triggerName, bool value)
{
if (chara.GetComponent<Animator>() != null)
chara.GetComponent<Animator>().SetBool(Animator.StringToHash(triggerName), value);
if (weapon && weapon.GetComponent<Animator>() != null)
weapon.GetComponent<Animator>().SetBool(Animator.StringToHash(triggerName), value);
if (weaponL && weaponL.GetComponent<Animator>() != null)
weaponL.GetComponent<Animator>().SetBool(Animator.StringToHash(triggerName), value);
if (weaponR && weaponR.GetComponent<Animator>() != null)
weaponR.GetComponent<Animator>().SetBool(Animator.StringToHash(triggerName), value);
}
#endregion
if (Input.GetMouseButtonDown(0)) void Update()
{
if (Input.GetKeyDown(KeyCode.Alpha1)) setState(1);
else if (Input.GetKeyDown(KeyCode.Alpha2)) setState(2);
else if (Input.GetKeyDown(KeyCode.Alpha3)) setState(3);
else if (Input.GetKeyDown(KeyCode.Alpha4)) setState(4);
else if (Input.GetKeyDown(KeyCode.Alpha5)) setState(5);
else if (Input.GetKeyDown(KeyCode.Alpha6)) setState(6);
else if (Input.GetKeyDown(KeyCode.V)) setRoom(0);
else if (Input.GetKeyDown(KeyCode.B)) setRoom(2);
else if (Input.GetKeyDown(KeyCode.N)) setRoom(3);
else if (Input.GetKeyDown(KeyCode.M)) setRoom(4);
else if (Input.GetKeyDown(KeyCode.A)) setAttack(0);
else if (Input.GetKeyDown(KeyCode.S)) setAttack(1);
else if (Input.GetKeyDown(KeyCode.D)) setAttack(2);
else if (Input.GetKeyDown(KeyCode.F)) setAttack(3);
else if (Input.GetKeyDown(KeyCode.G)) setAttack(4);
else if (Input.GetKeyDown(KeyCode.X)) setDamage();
else if (Input.GetKeyDown(KeyCode.Space))
GameObject.Find("stopbutton").GetComponent<Button>().onClick.Invoke();
else if (Input.GetKeyDown(KeyCode.Z))
{ {
Toggle t = GameObject.Find("holdingtoggle").GetComponent<Toggle>();
t.isOn = !t.isOn;
}
//Animator animator = model.GetComponent<Animator>();
//RuntimeAnimatorController rac = animator.runtimeAnimatorController;
//foreach (AnimationClip a in rac.animationClips)
//{
// //Debug.Log(a);
//}
////animator.Play(Animator.StringToHash("Extra_Attack_C_001_ref"), 0);
///
//chara.GetComponent<Animator>().SetTrigger(Animator.StringToHash("Attack_A"));
//weaponL.GetComponent<Animator>().SetTrigger(Animator.StringToHash("Attack_A"));
//weaponR.GetComponent<Animator>().SetTrigger(Animator.StringToHash("Attack_A"));
////animator.SetInteger(Animator.StringToHash("State"), 2);
////Animator animator2 = weapon.GetComponent<Animator>();
////animator2.SetInteger(Animator.StringToHash("State"), 2);
//chara.GetComponent<Animator>().SetBool(Animator.StringToHash("Holding"), true);
//weapon.GetComponent<Animator>().SetBool(Animator.StringToHash("Holding"), true); if (Input.GetMouseButtonDown(1))
{
//MotionEffectManager mem = chara.GetComponent<MotionEffectManager>(); //MotionEffectManager mem = chara.GetComponent<MotionEffectManager>();
//mem.isAttached = true; //mem.isAttached = true;
@ -358,11 +501,20 @@ public class Main : MonoBehaviour
//mem.initialize(); //mem.initialize();
//mem.TriggerEffect("StartEffect_attack_c_003"); //mem.TriggerEffect("StartEffect_attack_c_003");
//MotionEffectManager mem2 = weapon.GetComponent<MotionEffectManager>();
//mem2.isAttached = true;
//mem2.attachmentMotionIndex = 0;
//mem2.initialize();
//mem2.TriggerEffect("StartEffect_attack_c_002");
} }
} }
void LateUpdate()
{
if (faceOverride != 0)
{
float u = (faceOverride == 1 || faceOverride == 3 ? 0f : 0.5f);
float v = (faceOverride == 1 || faceOverride == 2 ? 0f : 0.5f);
MaterialPropertyBlock block = new MaterialPropertyBlock();
charaFaceRender.GetPropertyBlock(block);
block.SetVector("_DecalTex_ST", new Vector4(1f, 1f, u, v));
charaFaceRender.SetPropertyBlock(block);
}
}
} }

Binary file not shown.

@ -8,17 +8,20 @@ using UnityEngine.UI;
public class UIFunction : MonoBehaviour public class UIFunction : MonoBehaviour
{ {
Main main; Main main;
float speed;
void Start() void Start()
{ {
main = GameObject.Find("Main Camera").GetComponent<Main>(); main = GameObject.Find("Main Camera").GetComponent<Main>();
} }
#region Model
public void chooseCharaModel(int i) public void chooseCharaModel(int i)
{ {
var charaName = main.charaAssetsNames.Keys.ToList()[i]; var charaName = main.charaAssetsNames.Keys.ToList()[i];
main.loadChara(charaName); main.loadChara(charaName);
} }
public void chooseWeaponLModel(int i) public void chooseWeaponLModel(int i)
{ {
if (i == 0) main.removeWeapon(); if (i == 0) main.removeWeapon();
@ -53,4 +56,79 @@ public class UIFunction : MonoBehaviour
{ {
main.loadAnimator(i); main.loadAnimator(i);
} }
}
public void chooseFace(int i)
{
main.setFace(i);
}
#endregion
#region Action
public void actionRoom(int i)
{
main.setRoom(i);
}
public void actionState(int i)
{
main.setState(i);
}
public void actionTurn(float i)
{
main.setTurn(-i);
}
public void actionDamageScale(float i)
{
main.setDamageScale(i);
}
public void actionDamage()
{
main.setDamage();
}
public void actionHolding(bool i)
{
main.setHolding(i);
}
public void actionAttack(int i)
{
main.setAttack(i);
}
public void actionSpeed(float i)
{
main.setSpeed(i);
}
public void actionSpeedInput(string i)
{
float s = 1.0f;
float.TryParse(i, out s);
main.setSpeed(s);
}
public void actionStop()
{
if (main.speed >= 0.01f)
{
speed = main.speed;
main.setSpeed(0f);
}
else
{
main.setSpeed(speed);
}
}
#endregion
}

@ -2,32 +2,22 @@
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
public class UI : MonoBehaviour public class UIHideshow : MonoBehaviour
{ {
private CanvasGroup UICanvas;
private float alpha = 0;
private float speed = 10;
void Start() void Start()
{ {
UICanvas = this.GetComponent<CanvasGroup>(); GetComponent<CanvasGroup>().alpha = 0;
}
void Update()
{
UICanvas.alpha = Mathf.Lerp(UICanvas.alpha, alpha, speed * Time.deltaTime);
} }
public void EnterUIShow() public void EnterUIShow()
{ {
alpha = 1; GetComponent<CanvasGroup>().alpha = 1;
GameObject.Find("Main Camera").GetComponent<CameraOrbit>().canScroll = false; GameObject.Find("Main Camera").GetComponent<CameraOrbit>().canScroll = false;
} }
public void ExitUIHide() public void ExitUIHide()
{ {
alpha = 0; GetComponent<CanvasGroup>().alpha = 0;
GameObject.Find("Main Camera").GetComponent<CameraOrbit>().canScroll = true; GameObject.Find("Main Camera").GetComponent<CameraOrbit>().canScroll = true;
} }
} }

@ -1,6 +1,6 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: a8284cce1ed2d0b489e15e1e43067d32 guid: 776a50d6d75773b49b5cf85b7c4db12d
timeCreated: 1712801468 timeCreated: 1713141603
licenseType: Free licenseType: Free
MonoImporter: MonoImporter:
serializedVersion: 2 serializedVersion: 2
Loading…
Cancel
Save