1
This commit is contained in:
@@ -74,7 +74,7 @@
|
||||
"id": "9b32c7f1-0553-4735-b0f9-7726d59808ca",
|
||||
"expectedControlType": "Button",
|
||||
"processors": "",
|
||||
"interactions": "Hold,Tap",
|
||||
"interactions": "Press,Hold",
|
||||
"initialStateCheck": false
|
||||
},
|
||||
{
|
||||
@@ -128,7 +128,7 @@
|
||||
"id": "113a3c02-0fbb-4081-9fac-c39878ddfd09",
|
||||
"expectedControlType": "Button",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"interactions": "Press,Hold",
|
||||
"initialStateCheck": false
|
||||
},
|
||||
{
|
||||
@@ -137,7 +137,7 @@
|
||||
"id": "57a12f28-2fde-45e5-957f-d8d61afe44de",
|
||||
"expectedControlType": "Button",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"interactions": "Press,Hold",
|
||||
"initialStateCheck": false
|
||||
},
|
||||
{
|
||||
@@ -146,7 +146,7 @@
|
||||
"id": "c2535f43-fec8-42bd-b680-6d1cee5246e5",
|
||||
"expectedControlType": "Button",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"interactions": "Press,Hold",
|
||||
"initialStateCheck": false
|
||||
},
|
||||
{
|
||||
@@ -155,7 +155,7 @@
|
||||
"id": "6740f3a7-7571-4277-96e9-15aa08af7302",
|
||||
"expectedControlType": "Button",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"interactions": "Press,Hold",
|
||||
"initialStateCheck": false
|
||||
},
|
||||
{
|
||||
@@ -211,6 +211,15 @@
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
},
|
||||
{
|
||||
"name": "Holster",
|
||||
"type": "Button",
|
||||
"id": "7e9d80ac-533b-4a17-bf2a-74d3ccd6ec1c",
|
||||
"expectedControlType": "Button",
|
||||
"processors": "",
|
||||
"interactions": "Press,Hold",
|
||||
"initialStateCheck": false
|
||||
}
|
||||
],
|
||||
"bindings": [
|
||||
@@ -510,6 +519,17 @@
|
||||
"action": "Quinary",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "570f3f2d-b544-4e16-b825-a59c546c18b9",
|
||||
"path": "<Keyboard>/h",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Holster",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@@ -35,8 +35,6 @@ namespace BITKit.Animations
|
||||
}
|
||||
[Header(Constant.Header.Components)]
|
||||
public Animator animator;
|
||||
[Header(Constant.Header.State)]
|
||||
public bool isMatchingTarget;
|
||||
public AnimatorLayerInfo this[int index]
|
||||
{
|
||||
get
|
||||
@@ -116,7 +114,6 @@ namespace BITKit.Animations
|
||||
{
|
||||
this[i].currentState = animator.GetCurrentAnimatorStateInfo(i);
|
||||
}
|
||||
isMatchingTarget = animator.isMatchingTarget;
|
||||
}
|
||||
}
|
||||
}
|
@@ -62,6 +62,14 @@ namespace BITKit.Entities
|
||||
/// </summary>
|
||||
public interface IEntityMovement:IStateMachine<IEntityMovementState>
|
||||
{
|
||||
/// <summary>
|
||||
/// 视角中心,通常是摄像机的位置
|
||||
/// </summary>
|
||||
Vector3 ViewCenter { get; }
|
||||
/// <summary>
|
||||
/// 视角旋转,通常是摄像机的旋转
|
||||
/// </summary>
|
||||
Quaternion ViewRotation { get; }
|
||||
/// <summary>
|
||||
/// 基于运动的速度,是相对于标准化移动速度的相对速度
|
||||
/// </summary>
|
||||
@@ -75,6 +83,10 @@ namespace BITKit.Entities
|
||||
/// </summary>
|
||||
Vector3 GroundVelocity { get; }
|
||||
/// <summary>
|
||||
/// 旋转速度
|
||||
/// </summary>
|
||||
Vector3 AngularVelocity { get; }
|
||||
/// <summary>
|
||||
/// 是否在地面上
|
||||
/// </summary>
|
||||
bool IsGrounded { get; }
|
||||
@@ -96,8 +108,16 @@ namespace BITKit.Entities
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
void Movement(InputAction.CallbackContext context);
|
||||
|
||||
/// <summary>
|
||||
/// 执行命令
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
void ExecuteCommand<T>(T command=default);
|
||||
/// <summary>
|
||||
/// 执行命令的回调
|
||||
/// </summary>
|
||||
event Action<object> OnCommand;
|
||||
}
|
||||
public interface IEntityMovementState:IState
|
||||
{
|
||||
@@ -107,80 +127,4 @@ namespace BITKit.Entities
|
||||
void AfterUpdateMovement(float deltaTime);
|
||||
void ExecuteCommand<T>(T command);
|
||||
}
|
||||
public interface IPlayerMovementCommand{}
|
||||
[Serializable]
|
||||
public class MonoMovementProxy:IEntityMovement
|
||||
{
|
||||
[SerializeField] private MonoBehaviour monoBehaviour;
|
||||
private IEntityMovement _entityMovementImplementation=>monoBehaviour as IEntityMovement;
|
||||
|
||||
public Vector3 LocomotionBasedVelocity=>_entityMovementImplementation.LocomotionBasedVelocity;
|
||||
public Vector3 Velocity => _entityMovementImplementation.Velocity;
|
||||
|
||||
public Vector3 GroundVelocity => _entityMovementImplementation.GroundVelocity;
|
||||
|
||||
public bool IsGrounded => _entityMovementImplementation.IsGrounded;
|
||||
|
||||
public void SyncMovement(Vector3 velocity, Vector3 position, Quaternion rotation, bool isGrounded)
|
||||
{
|
||||
_entityMovementImplementation.SyncMovement(velocity, position, rotation, isGrounded);
|
||||
}
|
||||
|
||||
public void Movement(Vector3 relativeVector)
|
||||
{
|
||||
_entityMovementImplementation.Movement(relativeVector);
|
||||
}
|
||||
|
||||
public void Movement(InputAction.CallbackContext context)
|
||||
{
|
||||
_entityMovementImplementation.Movement(context);
|
||||
}
|
||||
|
||||
public void ExecuteCommand<T>(T command)=>_entityMovementImplementation.ExecuteCommand(command);
|
||||
|
||||
public bool Enabled
|
||||
{
|
||||
get => _entityMovementImplementation.Enabled;
|
||||
set => _entityMovementImplementation.Enabled = value;
|
||||
}
|
||||
|
||||
public IEntityMovementState CurrentState
|
||||
{
|
||||
get => _entityMovementImplementation.CurrentState;
|
||||
set => _entityMovementImplementation.CurrentState = value;
|
||||
}
|
||||
|
||||
public event Action<IEntityMovementState, IEntityMovementState> OnStateChanged
|
||||
{
|
||||
add => _entityMovementImplementation.OnStateChanged += value;
|
||||
remove => _entityMovementImplementation.OnStateChanged -= value;
|
||||
}
|
||||
|
||||
public IDictionary<Type, IEntityMovementState> StateDictionary => _entityMovementImplementation.StateDictionary;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
_entityMovementImplementation.Initialize();
|
||||
}
|
||||
|
||||
public void UpdateState(float deltaTime)
|
||||
{
|
||||
_entityMovementImplementation.UpdateState(deltaTime);
|
||||
}
|
||||
|
||||
public void DisposeState()
|
||||
{
|
||||
_entityMovementImplementation.DisposeState();
|
||||
}
|
||||
|
||||
public void TransitionState<State>() where State : IEntityMovementState
|
||||
{
|
||||
_entityMovementImplementation.TransitionState<State>();
|
||||
}
|
||||
|
||||
public void TransitionState(IEntityMovementState state)
|
||||
{
|
||||
_entityMovementImplementation.TransitionState(state);
|
||||
}
|
||||
}
|
||||
}
|
@@ -14,9 +14,12 @@ namespace BITKit
|
||||
#endregion
|
||||
#region 接口实现
|
||||
|
||||
public Vector3 ViewCenter { get; set; }
|
||||
public Quaternion ViewRotation { get; set; }
|
||||
public Vector3 LocomotionBasedVelocity { get; private set; }
|
||||
public Vector3 Velocity { get; private set; }
|
||||
public Vector3 GroundVelocity { get; private set; }
|
||||
public Vector3 AngularVelocity { get; private set; }
|
||||
public bool IsGrounded { get; private set; }
|
||||
private bool isDead;
|
||||
private Vector3 recordPosition;
|
||||
@@ -55,6 +58,8 @@ namespace BITKit
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public event Action<object> OnCommand;
|
||||
|
||||
public void OnSetAlive(bool alive)
|
||||
{
|
||||
switch (alive)
|
||||
|
@@ -90,9 +90,6 @@ namespace BITKit.Entities
|
||||
{
|
||||
OnSetAliveInternal(IsAlive = _isAlive);
|
||||
}
|
||||
|
||||
//entity.Invoke<int>(_onSetHP, newHP);
|
||||
//entity.Set<int>("HP", newHP);
|
||||
foreach (var x in entity.GetCallbacks<IHealthCallback>())
|
||||
{
|
||||
x.OnSetHP(newHP);
|
||||
@@ -108,20 +105,17 @@ namespace BITKit.Entities
|
||||
|
||||
private void OnSetAliveInternal(bool alive)
|
||||
{
|
||||
IsAlive = alive;
|
||||
foreach (var x in entity.GetCallbacks<IHealthCallback>())
|
||||
{
|
||||
x.OnSetAlive(alive);
|
||||
}
|
||||
|
||||
foreach (var x in additiveCallback)
|
||||
{
|
||||
x.OnSetAlive(alive);
|
||||
}
|
||||
|
||||
//entity.Invoke<bool>(_onSetAlive, alive);
|
||||
//entity.Set<bool>(_isAlive, alive);
|
||||
onSetAlive.Invoke(alive);
|
||||
OnSetAlive?.Invoke(alive);
|
||||
onSetAlive.Invoke(alive);
|
||||
}
|
||||
|
||||
private void AddHP(int hp)
|
||||
|
@@ -68,7 +68,7 @@ namespace BITKit.Entities.Player
|
||||
}
|
||||
public void Interactive(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context.interaction is not TapInteraction || !context.performed) return;
|
||||
if (context.interaction is not PressInteraction || !context.performed) return;
|
||||
var _selected = selected;
|
||||
if (_selected is not MonoBehaviour monoBehaviour) return;
|
||||
if (monoBehaviour.TryGetComponentAny<IAction>(out var action))
|
||||
|
@@ -31,8 +31,7 @@ namespace BITKit.Entities
|
||||
entityComponents = GetComponentsInChildren<IEntityComponent>(true).Distinct().ToArray();
|
||||
foreach (var x in entityComponents)
|
||||
{
|
||||
var att = x.GetType().GetCustomAttribute<CustomTypeAttribute>();
|
||||
if (att is not null)
|
||||
foreach (var att in x.GetType().GetCustomAttributes<CustomTypeAttribute>())
|
||||
{
|
||||
genericEvent.Set(att.Type, x);
|
||||
}
|
||||
|
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "BITFALL.Entities.EquipSelector.Runtime",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:709caf8d7fb6ef24bbba0ab9962a3ad0",
|
||||
"GUID:b355af20142c0c541ba9588ab1d0f64e",
|
||||
"GUID:75469ad4d38634e559750d17036d5f7c",
|
||||
"GUID:30cdc242b1ac6a944a460f4ab0b77b88",
|
||||
"GUID:677cd05ca06c46b4395470200b1acdad",
|
||||
"GUID:7efac18f239530141802fb139776f333",
|
||||
"GUID:84d565da37ad40546a118cfb3c3509f3",
|
||||
"GUID:42a9827d94e00374aa52e51f0a1b035c",
|
||||
"GUID:d525ad6bd40672747bde77962f1c401e",
|
||||
"GUID:49b49c76ee64f6b41bf28ef951cb0e50",
|
||||
"GUID:9354affc93e0f3e4a904785e7d4c0f59"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
@@ -0,0 +1,164 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using BITKit;
|
||||
using BITKit.Entities;
|
||||
using UnityEngine.InputSystem;
|
||||
using static UnityEditor.Progress;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using BITKit.Entities.Player;
|
||||
using UnityEngine.InputSystem.Interactions;
|
||||
using Debug = UnityEngine.Debug;
|
||||
|
||||
namespace BITFALL
|
||||
{
|
||||
[CustomType(typeof(IPlayerEquipSelector))]
|
||||
public class PlayerEquipSelector : EntityComponent,TaskSubscriber<IBasicItem>,IEntityInventoryCallback,IPlayerEquipSelector
|
||||
{
|
||||
[Header(Constant.Header.Components)]
|
||||
public EntityEquipment equipment;
|
||||
|
||||
[Header(Constant.Header.InternalVariables)]
|
||||
private readonly Dictionary<int, IBasicItem> equips=new();
|
||||
private IBasicItemContainer inventory;
|
||||
|
||||
public event Action<IBasicItem> OnEquip;
|
||||
public event Action<IBasicItem> OnDeEquip;
|
||||
public event Action<IDictionary<int, IBasicItem>> OnUpdateEquip;
|
||||
|
||||
private IBasicItem currentEquip;
|
||||
public override void OnAwake()
|
||||
{
|
||||
var health = entity.Get<IHealth>();
|
||||
health.OnSetAlive += OnSetAlive;
|
||||
OnDeEquip += DeEquip;
|
||||
OnEquip += Equip;
|
||||
}
|
||||
public override void OnStart()
|
||||
{
|
||||
base.OnStart();
|
||||
|
||||
entity.RegisterCallback<TaskSubscriber<IBasicItem>>(this);
|
||||
|
||||
inventory = entity.Get<IBasicItemContainer>();
|
||||
}
|
||||
public void OnPrimary(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context is not {interaction:PressInteraction ,performed:true}) return;
|
||||
Equip(1);
|
||||
}
|
||||
public void OnSecondary(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context is not {interaction:PressInteraction ,performed:true}) return;
|
||||
Equip(2);
|
||||
}
|
||||
public void OnTertiary(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context is not {interaction:PressInteraction ,performed:true}) return;
|
||||
if (Equip(3) is false)
|
||||
{
|
||||
Equip(-1);
|
||||
}
|
||||
}
|
||||
public void OnQuaternary(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context is not {interaction:PressInteraction ,performed:true}) return;
|
||||
Equip(4);
|
||||
}
|
||||
public void OnHolster(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context is not {interaction:PressInteraction ,performed:true}) return;
|
||||
Equip(-1);
|
||||
}
|
||||
private void OnSetAlive(bool alive)
|
||||
{
|
||||
if (alive) return;
|
||||
foreach (var x in equips.ToArray())
|
||||
{
|
||||
inventory.Add(x.Value);
|
||||
}
|
||||
equips.Clear();
|
||||
UpdateEquip();
|
||||
Equip(-1);
|
||||
}
|
||||
int TaskSubscriber<IBasicItem>.Priority => 0;
|
||||
|
||||
bool TaskSubscriber<IBasicItem>.TryExecute(IBasicItem value)
|
||||
{
|
||||
var asset = value.GetAssetable();
|
||||
if (IsSupportItem(value) is false) return false;
|
||||
switch (asset)
|
||||
{
|
||||
case var _ when asset.TryGetProperty<EquipmentAsWeapon>(out _):
|
||||
if (equips.TryAdd(1, value) || equips.TryAdd(2,value))
|
||||
{
|
||||
OnEquip?.Invoke(value);
|
||||
UpdateEquip();
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void OnAdd(IBasicItem item)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnRemove(IBasicItem item)
|
||||
{
|
||||
if (IsSupportItem(item) is false)
|
||||
{
|
||||
UpdateEquip();
|
||||
}
|
||||
}
|
||||
private bool IsSupportItem(IBasicItem item)
|
||||
{
|
||||
return equipment.equips.list.Any(x => x.AddressablePath == item.AddressablePath);
|
||||
}
|
||||
private void UpdateEquip()
|
||||
{
|
||||
OnUpdateEquip?.Invoke(new Dictionary<int, IBasicItem>(equips));
|
||||
}
|
||||
|
||||
public bool TryDeEquip(IBasicItem item)
|
||||
{
|
||||
if (item is null) return false;
|
||||
if (equips.Any(x => x.Value.AddressablePath == item.AddressablePath) is false) return false;
|
||||
var index = equips.Single(x=>x.Value.AddressablePath==item.AddressablePath).Key;
|
||||
if (equips.TryRemove(index) is false) return false;
|
||||
if (!inventory.Add(item)) return false;
|
||||
OnDeEquip?.Invoke(item);
|
||||
UpdateEquip();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void Equip(IBasicItem item)
|
||||
{
|
||||
if (item is null)
|
||||
{
|
||||
equipment.equips.Entry(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
equipment.equips.Entry(x=>x.AddressablePath == item.AddressablePath);
|
||||
}
|
||||
}
|
||||
|
||||
private bool Equip(int index)
|
||||
{
|
||||
if (!equips.TryGetValue(index, out var x) && index is not -1) return false;
|
||||
if (index is -1)
|
||||
{
|
||||
OnEquip?.Invoke(x);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void DeEquip(IBasicItem item)
|
||||
{
|
||||
equipment.equips.Entry(-1);
|
||||
}
|
||||
}
|
||||
}
|
@@ -4,37 +4,39 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using System.Linq;
|
||||
|
||||
namespace BITKit
|
||||
{
|
||||
[System.Serializable]
|
||||
public class InputActionGroup : IDisposable
|
||||
{
|
||||
int lockFile = Guid.NewGuid().GetHashCode();
|
||||
private int lockFile = Guid.NewGuid().GetHashCode();
|
||||
public bool allowGlobalActivation = true;
|
||||
public bool isEnabled;
|
||||
InitializationState state = InitializationState.None;
|
||||
[SerializeField, ReadOnly] private bool isEnabled;
|
||||
private InitializationState state = InitializationState.None;
|
||||
public ValidHandle allowInput = new();
|
||||
List<InputAction> actions = new();
|
||||
public InputActionGroup RegisterCallback(InputActionReference reference, Action<InputAction.CallbackContext> callback)
|
||||
private readonly List<InputAction> actions = new();
|
||||
|
||||
public InputActionGroup RegisterCallback(InputActionReference reference,
|
||||
Action<InputAction.CallbackContext> callback)
|
||||
{
|
||||
if (reference is null)
|
||||
{
|
||||
Debug.LogWarning($"未知的引用");
|
||||
return this;
|
||||
}
|
||||
|
||||
EnsureConfiguration();
|
||||
var action = reference.action.Clone();
|
||||
|
||||
actions
|
||||
.Where(x => x.name == action.name)
|
||||
.CreateOrAddIfEmety(actions, action)
|
||||
.ForEach(x =>
|
||||
{
|
||||
x.RegisterCallback(callback);
|
||||
});
|
||||
.Where(x => x.name == action.name)
|
||||
.CreateOrAddIfEmety(actions, action)
|
||||
.ForEach(x => { x.RegisterCallback(callback); });
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void UnRegisterCallback(InputActionReference reference, Action<InputAction.CallbackContext> callback)
|
||||
{
|
||||
foreach (var action in actions.Where(x => x.name == reference.action.name))
|
||||
@@ -42,7 +44,8 @@ namespace BITKit
|
||||
action.UnRegisterCallback(callback);
|
||||
}
|
||||
}
|
||||
void EnsureConfiguration()
|
||||
|
||||
private void EnsureConfiguration()
|
||||
{
|
||||
if (state is not InitializationState.Initialized)
|
||||
{
|
||||
@@ -50,18 +53,21 @@ namespace BITKit
|
||||
state = InitializationState.Initialized;
|
||||
}
|
||||
}
|
||||
void Init()
|
||||
|
||||
private void Init()
|
||||
{
|
||||
if (allowGlobalActivation)
|
||||
BITInputSystem.AllowInput.AddListener(Listen);
|
||||
allowInput.AddListener(Allow);
|
||||
}
|
||||
void Listen(bool allowInput)
|
||||
|
||||
private void Listen(bool allowInput)
|
||||
{
|
||||
this.allowInput.SetElements(lockFile, allowInput);
|
||||
this.allowInput.SetDisableElements(lockFile, !allowInput);
|
||||
}
|
||||
void Allow(bool allow)
|
||||
|
||||
private void Allow(bool allow)
|
||||
{
|
||||
foreach (var action in actions)
|
||||
{
|
||||
@@ -74,6 +80,7 @@ namespace BITKit
|
||||
action.Disable();
|
||||
}
|
||||
}
|
||||
|
||||
isEnabled = allow;
|
||||
}
|
||||
|
||||
@@ -83,6 +90,7 @@ namespace BITKit
|
||||
{
|
||||
action.Disable();
|
||||
}
|
||||
|
||||
actions.Clear();
|
||||
}
|
||||
}
|
||||
|
@@ -1,26 +1,27 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
// ReSharper disable InvertIf
|
||||
namespace BITKit
|
||||
{
|
||||
public class LocationAdditive : BITBehavior
|
||||
public class LocationAdditive : MonoBehaviour
|
||||
{
|
||||
Vector3 currentPosition;
|
||||
Vector3 currentEulur;
|
||||
private Vector3 currentPosition;
|
||||
private Vector3 currentEuler;
|
||||
public void AddPosition(Vector3 value)
|
||||
{
|
||||
currentPosition += value;
|
||||
}
|
||||
public void AddEuler(Vector3 value)
|
||||
{
|
||||
currentEulur += value;
|
||||
currentEuler += value;
|
||||
}
|
||||
public void LateUpdate()
|
||||
{
|
||||
if (currentEulur.IsDefault() is false)
|
||||
if (currentEuler.IsDefault() is false)
|
||||
{
|
||||
transform.localEulerAngles = currentEulur;
|
||||
currentEulur = default;
|
||||
transform.localEulerAngles = currentEuler;
|
||||
currentEuler = default;
|
||||
}
|
||||
if (currentPosition.IsDefault() is false)
|
||||
{
|
||||
|
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit
|
||||
{
|
||||
public class LocationAdditiveElement : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private LocationAdditive locationAdditive;
|
||||
private void Update()
|
||||
{
|
||||
locationAdditive.AddPosition(transform.localPosition);
|
||||
locationAdditive.AddEuler(transform.localEulerAngles);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@ namespace BITKit
|
||||
public class LocationMixer : BITBehavior
|
||||
{
|
||||
[System.Serializable]
|
||||
struct LocationInfo
|
||||
private struct LocationInfo
|
||||
{
|
||||
public Location location;
|
||||
public float weight;
|
||||
|
18
Assets/BITKit/Unity/Scripts/UX/Library/CustomButton.cs
Normal file
18
Assets/BITKit/Unity/Scripts/UX/Library/CustomButton.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace BITKit.UX
|
||||
{
|
||||
public class CustomButton : Button
|
||||
{
|
||||
public new class UxmlTraits : Button.UxmlTraits
|
||||
{
|
||||
}
|
||||
public CustomButton() : base()
|
||||
{
|
||||
}
|
||||
public new class UxmlFactory : UxmlFactory<CustomButton, UxmlTraits> { }
|
||||
}
|
||||
}
|
@@ -23,12 +23,18 @@ namespace BITKit.UX
|
||||
{
|
||||
name = "tabs"
|
||||
};
|
||||
private readonly UxmlBoolAttributeDescription m_allowFocus = new ()
|
||||
{
|
||||
name = "allowFocus",
|
||||
defaultValue = true
|
||||
};
|
||||
public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc)
|
||||
{
|
||||
base.Init(ve, bag, cc);
|
||||
var tabBar = (TabBar)ve;
|
||||
tabBar.CurrentTab = m_TabBarAttribute.GetValueFromBag(bag, cc);
|
||||
tabBar.Tabs = m_TabsAttribute.GetValueFromBag(bag, cc);
|
||||
tabBar.allowFocus = m_allowFocus.GetValueFromBag(bag, cc);
|
||||
}
|
||||
}
|
||||
public new class UxmlFactory : UxmlFactory<TabBar, UxmlTraits> { }
|
||||
@@ -58,6 +64,22 @@ namespace BITKit.UX
|
||||
SetTabs(value);
|
||||
}
|
||||
}
|
||||
|
||||
private bool allowFocus;
|
||||
public bool AllowFocus
|
||||
{
|
||||
get => allowFocus;
|
||||
set
|
||||
{
|
||||
allowFocus = value;
|
||||
foreach (var x in _buttons)
|
||||
{
|
||||
x.focusable = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void SetTabs(string value)
|
||||
{
|
||||
var split = value.Split(",");
|
||||
@@ -72,6 +94,7 @@ namespace BITKit.UX
|
||||
var index = i;
|
||||
var button = _buttons[i] = this.Create<Button>();
|
||||
button.text = tabName;
|
||||
button.focusable = allowFocus;
|
||||
button.clicked += () => CurrentTab = index;
|
||||
}
|
||||
}
|
||||
|
@@ -76,6 +76,8 @@ namespace BITKit.UX
|
||||
|
||||
[SerializeReference, SubclassSelector] private IUXPanel initialPanel;
|
||||
|
||||
[SerializeField] private TextAsset validTexts;
|
||||
|
||||
private bool initialized;
|
||||
private void Awake()
|
||||
{
|
||||
|
@@ -18,17 +18,16 @@ namespace BITKit
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = true, Inherited = true)]
|
||||
public class CustomTypeAttribute : System.Attribute
|
||||
{
|
||||
public readonly Type Type;
|
||||
|
||||
public CustomTypeAttribute(Type type)
|
||||
{
|
||||
|
||||
Type = type;
|
||||
}
|
||||
}
|
||||
|
||||
public class BITEditorUtils
|
||||
{
|
||||
public const string InspectorPath = "Assets/BITKit/Unity/UX/BITInspector.uss";
|
||||
|
@@ -563,6 +563,7 @@ namespace BITKit
|
||||
.CameraTransformWorldToPanel(self.panel, worldPosition, camera);
|
||||
|
||||
pos.x = (pos.x - self.layout.width / 2);
|
||||
pos.y = (pos.y - self.layout.height / 2);
|
||||
|
||||
self.style.left = 0;
|
||||
self.style.top = 0;
|
||||
|
138
Assets/BITKit/Unity/ShaderGraph/Billboard.mat
Normal file
138
Assets/BITKit/Unity/ShaderGraph/Billboard.mat
Normal file
@@ -0,0 +1,138 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &-5291136167880478882
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 11
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
version: 7
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Billboard
|
||||
m_Shader: {fileID: -6465566751694194690, guid: fc56a447eb0944f4f9fc3b51a4913759,
|
||||
type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BaseMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTexture:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _SpecGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_Lightmaps:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_LightmapsInd:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_ShadowMasks:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _AlphaClip: 0
|
||||
- _AlphaToMask: 0
|
||||
- _Blend: 0
|
||||
- _BlendModePreserveSpecular: 1
|
||||
- _BumpScale: 1
|
||||
- _ClearCoatMask: 0
|
||||
- _ClearCoatSmoothness: 0
|
||||
- _Cull: 2
|
||||
- _Cutoff: 0.5
|
||||
- _DetailAlbedoMapScale: 1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _DstBlendAlpha: 0
|
||||
- _EnvironmentReflections: 1
|
||||
- _GlossMapScale: 0
|
||||
- _Glossiness: 0
|
||||
- _GlossyReflections: 0
|
||||
- _Metallic: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.005
|
||||
- _QueueControl: 0
|
||||
- _QueueOffset: 0
|
||||
- _ReceiveShadows: 1
|
||||
- _Smoothness: 0.5
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _SrcBlendAlpha: 1
|
||||
- _Surface: 0
|
||||
- _WorkflowMode: 1
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
||||
m_BuildTextureStacks: []
|
2528
Assets/BITKit/Unity/ShaderGraph/Billboard.shadergraph
Normal file
2528
Assets/BITKit/Unity/ShaderGraph/Billboard.shadergraph
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user