90 lines
2.9 KiB
C#
90 lines
2.9 KiB
C#
|
|
using System;
|
|||
|
|
using NaughtyAttributes;
|
|||
|
|
using UnityEngine;
|
|||
|
|
|
|||
|
|
|
|||
|
|
public class WeaponScaleAdapter : MonoBehaviour
|
|||
|
|
{
|
|||
|
|
[SerializeField] private int i = 0;
|
|||
|
|
public GameObject target;
|
|||
|
|
public PlayableCharacterSkin targetSkin;
|
|||
|
|
|
|||
|
|
[Button]
|
|||
|
|
public void CopyCurrentAllTo()
|
|||
|
|
{
|
|||
|
|
var wj = weaponSizeByPlayerSkin.weaponListDataContainers.Find((d)=> d.playableCharacterSkin==targetSkin);
|
|||
|
|
var weapon = wj.weaponDataClass.objectWeapon.transform;
|
|||
|
|
wj.weaponDataClass.scale = weapon.localScale;
|
|||
|
|
wj.weaponDataClass.pos = weapon.localPosition;
|
|||
|
|
wj.weaponDataClass.rot = weapon.localRotation.eulerAngles;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[Button]
|
|||
|
|
public void InitAllTargets()
|
|||
|
|
{
|
|||
|
|
foreach (var pair in weaponSizeByPlayerSkin.weaponListDataContainers)
|
|||
|
|
{
|
|||
|
|
pair.weaponDataClass.objectWeapon = target;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[Button]
|
|||
|
|
public void ViewSkin()
|
|||
|
|
{
|
|||
|
|
var wj = weaponSizeByPlayerSkin.weaponListDataContainers.Find((d)=> d.playableCharacterSkin==targetSkin);
|
|||
|
|
var weapon = wj.weaponDataClass.objectWeapon.transform;
|
|||
|
|
weapon.localScale = wj.weaponDataClass.scale;
|
|||
|
|
weapon.localPosition = wj.weaponDataClass.pos;
|
|||
|
|
weapon.localRotation = Quaternion.Euler( wj.weaponDataClass.rot);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[Button]
|
|||
|
|
public void ViewNext()
|
|||
|
|
{
|
|||
|
|
foreach (var listData in weaponSizeByPlayerSkin.weaponListDataContainers)
|
|||
|
|
{
|
|||
|
|
listData.playableCharacterSkin.DeactivateEditor();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var wj = weaponSizeByPlayerSkin.weaponListDataContainers[i];
|
|||
|
|
targetSkin = wj.playableCharacterSkin;
|
|||
|
|
var weapon = wj.weaponDataClass.objectWeapon.transform;
|
|||
|
|
wj.playableCharacterSkin.ActivateEditor();
|
|||
|
|
weapon.localScale = wj.weaponDataClass.scale;
|
|||
|
|
weapon.localPosition = wj.weaponDataClass.pos;
|
|||
|
|
weapon.localRotation = Quaternion.Euler( wj.weaponDataClass.rot);
|
|||
|
|
|
|||
|
|
i++;
|
|||
|
|
if (i == weaponSizeByPlayerSkin.weaponListDataContainers.Count) i = 0;
|
|||
|
|
}
|
|||
|
|
[Button]
|
|||
|
|
public void ZeroCurrentTo()
|
|||
|
|
{
|
|||
|
|
var wj = weaponSizeByPlayerSkin.weaponListDataContainers.Find((d)=> d.playableCharacterSkin==targetSkin);
|
|||
|
|
|
|||
|
|
wj.weaponDataClass.pos = Vector3.zero;
|
|||
|
|
wj.weaponDataClass.rot = Vector3.zero;
|
|||
|
|
ViewSkin();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void Awake()
|
|||
|
|
{
|
|||
|
|
weaponSizeByPlayerSkin.Init();
|
|||
|
|
foreach (var playSkin in weaponSizeByPlayerSkin.Data.Keys)
|
|||
|
|
{
|
|||
|
|
playSkin.OnInitProvide += OnInitProvide;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void OnInitProvide(PlayableCharacterSkin playableCharacterSkin)
|
|||
|
|
{
|
|||
|
|
var wj = weaponSizeByPlayerSkin.Data[playableCharacterSkin];
|
|||
|
|
var weapon = wj.objectWeapon.transform;
|
|||
|
|
|
|||
|
|
weapon.localScale = wj.scale;
|
|||
|
|
weapon.localPosition = wj.pos;
|
|||
|
|
weapon.localRotation = Quaternion.Euler(wj.rot);
|
|||
|
|
}
|
|||
|
|
[SerializeField] internal WeaponSizeByPlayerSkin weaponSizeByPlayerSkin;
|
|||
|
|
|
|||
|
|
}
|