1
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!74 &7400000
|
||||
AnimationClip:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Emety_Inspect
|
||||
serializedVersion: 7
|
||||
m_Legacy: 0
|
||||
m_Compressed: 0
|
||||
m_UseHighQualityCurve: 1
|
||||
m_RotationCurves: []
|
||||
m_CompressedRotationCurves: []
|
||||
m_EulerCurves: []
|
||||
m_PositionCurves: []
|
||||
m_ScaleCurves: []
|
||||
m_FloatCurves: []
|
||||
m_PPtrCurves: []
|
||||
m_SampleRate: 60
|
||||
m_WrapMode: 0
|
||||
m_Bounds:
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
m_Extent: {x: 0, y: 0, z: 0}
|
||||
m_ClipBindingConstant:
|
||||
genericBindings: []
|
||||
pptrCurveMapping: []
|
||||
m_AnimationClipSettings:
|
||||
serializedVersion: 2
|
||||
m_AdditiveReferencePoseClip: {fileID: 0}
|
||||
m_AdditiveReferencePoseTime: 0
|
||||
m_StartTime: 0
|
||||
m_StopTime: 1
|
||||
m_OrientationOffsetY: 0
|
||||
m_Level: 0
|
||||
m_CycleOffset: 0
|
||||
m_HasAdditiveReferencePose: 0
|
||||
m_LoopTime: 0
|
||||
m_LoopBlend: 0
|
||||
m_LoopBlendOrientation: 0
|
||||
m_LoopBlendPositionY: 0
|
||||
m_LoopBlendPositionXZ: 0
|
||||
m_KeepOriginalOrientation: 0
|
||||
m_KeepOriginalPositionY: 1
|
||||
m_KeepOriginalPositionXZ: 0
|
||||
m_HeightFromFeet: 0
|
||||
m_Mirror: 0
|
||||
m_EditorCurves: []
|
||||
m_EulerEditorCurves: []
|
||||
m_HasGenericRootTransform: 0
|
||||
m_HasMotionFloatCurves: 0
|
||||
m_Events: []
|
@@ -229,6 +229,15 @@
|
||||
"processors": "",
|
||||
"interactions": "Press",
|
||||
"initialStateCheck": false
|
||||
},
|
||||
{
|
||||
"name": "Inspect",
|
||||
"type": "Button",
|
||||
"id": "69a6c6fe-6caf-478d-aef5-e51e17372a83",
|
||||
"expectedControlType": "Button",
|
||||
"processors": "",
|
||||
"interactions": "Hold,Press",
|
||||
"initialStateCheck": false
|
||||
}
|
||||
],
|
||||
"bindings": [
|
||||
@@ -550,6 +559,17 @@
|
||||
"action": "ToggleCamera",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "c7bf69ae-febf-4280-b153-d529229f82b5",
|
||||
"path": "<Keyboard>/i",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Inspect",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@@ -7,15 +7,23 @@ namespace BITKit.Animations
|
||||
{
|
||||
public class OverrideAnimatorFallbackController : MonoBehaviour
|
||||
{
|
||||
[SerializeField,ReadOnly] private bool _isOverride;
|
||||
[SerializeField, ReadOnly] private bool _isOverride;
|
||||
[SerializeField, ReadOnly] private string _buildReport="None";
|
||||
[SerializeField] private AnimatorOverrideController overrideController;
|
||||
[SerializeField] private AnimatorOverrideController[] additionalOverrideControllers;
|
||||
private void Start()
|
||||
{
|
||||
if (!overrideController) return;
|
||||
if (!TryGetComponent<Animator>(out var animator) ||
|
||||
animator.runtimeAnimatorController is not AnimatorOverrideController sourceController) return;
|
||||
animator.runtimeAnimatorController = sourceController.CopyAndFillMissingContent(overrideController);
|
||||
|
||||
var controller = sourceController.CopyAndFillMissingContent(overrideController);
|
||||
|
||||
foreach (var additional in additionalOverrideControllers)
|
||||
{
|
||||
controller = controller.CopyAndFillMissingContent(additional);
|
||||
}
|
||||
animator.runtimeAnimatorController = controller;
|
||||
_isOverride = true;
|
||||
}
|
||||
}
|
||||
|
@@ -61,7 +61,7 @@ namespace BITKit.Entities
|
||||
|
||||
private void OnHealthPointChangedInternal(int old, int newHP)
|
||||
{
|
||||
healthPoint = newHP;
|
||||
healthPoint =Mathf.Clamp(newHP,-1,maxHealthPoint) ;
|
||||
var _isAlive = newHP >= 0;
|
||||
if (_isAlive != IsAlive)
|
||||
{
|
||||
|
@@ -48,6 +48,9 @@ namespace BITKit
|
||||
{
|
||||
currentEuler = Vector3.Scale(currentEuler, rotationWeight);
|
||||
currentPosition = Vector3.Scale(currentPosition, positionWeight);
|
||||
|
||||
currentEuler = Vector3.ClampMagnitude(currentEuler, 4096);
|
||||
currentPosition = Vector3.ClampMagnitude(currentPosition, 4096);
|
||||
|
||||
if (disabledRotation is false)
|
||||
switch (currentEuler, globalRotation)
|
||||
|
@@ -7,6 +7,7 @@ namespace BITKit
|
||||
{
|
||||
public class LocationAdditiveElement : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private bool useLateUpdate;
|
||||
[SerializeField] private LocationAdditive locationAdditive;
|
||||
[SerializeField] private Vector3 positionWeight = Vector3.one;
|
||||
[SerializeField] private Vector3 eulerWeight = Vector3.one;
|
||||
@@ -18,6 +19,18 @@ namespace BITKit
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (useLateUpdate) return;
|
||||
Tick();
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (!useLateUpdate) return;
|
||||
Tick();
|
||||
}
|
||||
|
||||
private void Tick()
|
||||
{
|
||||
var localPosition = Transform.localPosition;
|
||||
var localEulerAngles = Transform.localEulerAngles;
|
||||
|
@@ -9,14 +9,29 @@ namespace BITKit.Sensors
|
||||
public class RaySensor : Sensor
|
||||
{
|
||||
[Header(Constant.Header.Settings)]
|
||||
[SerializeField] private float radius = 0.16f;
|
||||
public float distance;
|
||||
public override IEnumerable<Transform> Get() => detected;
|
||||
private readonly RaycastHit[] raycasts = new RaycastHit[16];
|
||||
public override UniTask Execute()
|
||||
{
|
||||
var _transform = transform;
|
||||
var ray = new Ray(_transform.position,_transform.forward);
|
||||
var size = Physics.RaycastNonAlloc(ray, raycasts, distance, detectLayer);
|
||||
var forward = _transform.forward;
|
||||
var position = _transform.position;
|
||||
|
||||
var size = 0;
|
||||
if (radius is not 0)
|
||||
{
|
||||
size = Physics.CapsuleCastNonAlloc(position, position + forward * distance, radius, forward,
|
||||
raycasts
|
||||
, distance, detectLayer);
|
||||
}
|
||||
else
|
||||
{
|
||||
var ray = new Ray(_transform.position,_transform.forward);
|
||||
size = Physics.RaycastNonAlloc(ray, raycasts, distance, detectLayer);
|
||||
}
|
||||
|
||||
detected = raycasts
|
||||
.Take(size)
|
||||
.Select(x => x.collider)
|
||||
|
@@ -28,20 +28,21 @@ namespace BITKit.Sensors
|
||||
[Header(Constant.Header.InternalVariables)]
|
||||
// ReSharper disable once FieldCanBeMadeReadOnly.Local
|
||||
private List<Collider> detected = new();
|
||||
|
||||
private readonly Queue<Collider> triggerEnterQueue=new();
|
||||
private readonly Queue<Collider> triggerExitQueue=new();
|
||||
|
||||
private readonly Queue<Collider> triggerEnterQueue = new();
|
||||
private readonly Queue<Collider> triggerExitQueue = new();
|
||||
private bool diagnosisNextFrame;
|
||||
|
||||
|
||||
private void OnTriggerEnter(Collider _collider)
|
||||
{
|
||||
triggerEnterQueue.Enqueue(_collider);
|
||||
if(immediately)Rebuild();
|
||||
if (immediately) Rebuild();
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider _collider)
|
||||
{
|
||||
triggerExitQueue.Enqueue(_collider);
|
||||
if(immediately)Rebuild();
|
||||
if (immediately) Rebuild();
|
||||
}
|
||||
|
||||
private void OnCollisionEnter(Collision collision)
|
||||
@@ -63,24 +64,17 @@ namespace BITKit.Sensors
|
||||
|
||||
public IEnumerable<Transform> Get()
|
||||
{
|
||||
if(BITAppForUnity.IsPlaying is false)return ArraySegment<Transform>.Empty;
|
||||
try
|
||||
{
|
||||
return detected.Select(x => x.transform).ToArray();
|
||||
return detected.Select(x => x.transform).ToArray();
|
||||
}
|
||||
catch (MissingReferenceException)
|
||||
{
|
||||
List<Transform> list = new();
|
||||
foreach (var x in detected)
|
||||
{
|
||||
try
|
||||
{
|
||||
list.Add(x.transform);
|
||||
}
|
||||
catch (MissingReferenceException){}
|
||||
}
|
||||
return list.ToArray();
|
||||
detected = detected.Where(x => x).ToList();
|
||||
}
|
||||
}
|
||||
return detected.Select(x => x.transform).ToArray();
|
||||
}
|
||||
|
||||
//public bool IsValid(Collider _collider) => ignores.Contains(_collider.gameObject) is false;
|
||||
public bool IsValid(Collider _collider)
|
||||
@@ -177,6 +171,7 @@ namespace BITKit.Sensors
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
if (!agent || detectedContainer is null) return;
|
||||
if (BITAppForUnity.IsPlaying is false) return;
|
||||
detectedContainer.Clear();
|
||||
foreach (var x in agent.Get())
|
||||
{
|
||||
|
@@ -13,6 +13,19 @@ namespace BITKit.UX
|
||||
public string message = "message";
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class UXAlertPopup : IUXPopup
|
||||
{
|
||||
public void Popup(string content, float duration = 3f)
|
||||
{
|
||||
Alert.Print(new AlertMessage()
|
||||
{
|
||||
title = "Alert",
|
||||
message = content
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static class Alert
|
||||
{
|
||||
public static void Print(AlertMessage message)
|
||||
|
@@ -22,7 +22,7 @@ namespace BITKit.UX
|
||||
this.visualElement = visualElement;
|
||||
contextLabel = visualElement.Q<Label>(UXConstant.ContextLabel);
|
||||
titleLabel = visualElement.Q<Label>(UXConstant.TitleLabel);
|
||||
numberLabel = visualElement.Q<Label>(UXConstant.TitleLabel);
|
||||
numberLabel = visualElement.Q<Label>(UXConstant.NumberLabel);
|
||||
descriptionLabel = visualElement.Q<Label>(UXConstant.DescriptionLabel);
|
||||
button = visualElement.Q<Button>(UXConstant.MainButton);
|
||||
secButton = visualElement.Q<Button>(UXConstant.SecButton);
|
||||
|
83
Assets/BITKit/Unity/Scripts/UX/Popup/UXPopup.cs
Normal file
83
Assets/BITKit/Unity/Scripts/UX/Popup/UXPopup.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using BITKit;
|
||||
using BITKit.UX;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace BITKit.UX
|
||||
{
|
||||
[Serializable]
|
||||
public class UXPopupSelector:IUXPopup
|
||||
{
|
||||
[SerializeReference,SubclassSelector] private IReference popupPath;
|
||||
public void Popup(string content, float duration = 3)
|
||||
{
|
||||
UXPopup.Dictionary[popupPath.Value].Popup(content,duration);
|
||||
}
|
||||
}
|
||||
public sealed class UXPopup : MonoBehaviour,IUXPopup
|
||||
{
|
||||
internal static readonly Dictionary<string,UXPopup> Dictionary=new();
|
||||
|
||||
[SerializeField] private UIDocument document;
|
||||
[SerializeReference, SubclassSelector] private IReference containerPath;
|
||||
[SerializeReference, SubclassSelector] private IReference popupPath;
|
||||
[SerializeField] private VisualTreeAsset popupTemplate;
|
||||
|
||||
private VisualElement container;
|
||||
|
||||
private readonly List<ViewModel> instances = new();
|
||||
|
||||
private class ViewModel
|
||||
{
|
||||
public VisualElement visualElement;
|
||||
public float exitTime;
|
||||
public bool disposed;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
container = document.rootVisualElement.Q<VisualElement>(containerPath.Value);
|
||||
|
||||
Dictionary.Add(popupPath.Value,this);
|
||||
|
||||
destroyCancellationToken.Register(() => Dictionary.Remove(popupPath.Value));
|
||||
|
||||
container.Clear();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
foreach (var x in instances.Where(x=>Time.time > x.exitTime))
|
||||
{
|
||||
x.visualElement.RemoveFromHierarchy();
|
||||
x.visualElement.SetOpacity(
|
||||
Mathf.MoveTowards(x.visualElement.GetOpacity(),0,Time.deltaTime)
|
||||
);
|
||||
x.disposed = x.visualElement.GetOpacity() is 0;
|
||||
}
|
||||
instances.RemoveAll(x =>x.disposed);
|
||||
|
||||
container.SetActive(container.childCount > 0);
|
||||
}
|
||||
|
||||
public void Popup(string content, float duration = 3)
|
||||
{
|
||||
var visualElement =new UXContainer(container.Create<VisualElement>(popupTemplate.CloneTree))
|
||||
{
|
||||
contextLabel =
|
||||
{
|
||||
text = content
|
||||
}
|
||||
};
|
||||
instances.Add(new ViewModel()
|
||||
{
|
||||
visualElement = visualElement,
|
||||
exitTime = Time.time + duration
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@@ -192,7 +192,7 @@ namespace BITKit
|
||||
// }
|
||||
} while (property.NextVisible(false));
|
||||
|
||||
foreach (var method in serializedObject.targetObject.GetType().GetMethods())
|
||||
foreach (var method in serializedObject.targetObject.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
|
||||
{
|
||||
if (method.GetCustomAttribute<BITAttribute>() is null) continue;
|
||||
if (method.GetParameters().Length is not 0) continue;
|
||||
|
@@ -614,6 +614,10 @@ namespace BITKit
|
||||
{
|
||||
self.style.display = new(active ? DisplayStyle.Flex : DisplayStyle.None);
|
||||
}
|
||||
public static void SetVisible(this VisualElement self, bool visible)
|
||||
{
|
||||
self.style.visibility = new(visible ? Visibility.Visible : Visibility.Hidden);
|
||||
}
|
||||
public static float GetOpacity(this VisualElement self) => self.style.opacity.value;
|
||||
public static void SetOpacity(this VisualElement self, float value) => self.style.opacity = new(value);
|
||||
public static void ScrollToBottom(this ScrollView self)
|
||||
|
@@ -119,6 +119,8 @@ namespace BITKit
|
||||
}
|
||||
public double Interval=1;
|
||||
private double allowUpdateTime=0;
|
||||
public bool AllowUpdateWithoutReset => BITApp.Time.TimeAsDouble >= allowUpdateTime;
|
||||
public double Remaining => allowUpdateTime - BITApp.Time.TimeAsDouble;
|
||||
public bool AllowUpdate
|
||||
{
|
||||
get
|
||||
@@ -128,7 +130,7 @@ namespace BITKit
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public bool AllowUpdateWithoutReset => BITApp.Time.TimeAsDouble >= allowUpdateTime;
|
||||
|
||||
public void Reset(bool immediately = false)
|
||||
{
|
||||
allowUpdateTime = BITApp.Time.TimeAsDouble + (immediately ? 0 : Interval);
|
||||
|
@@ -26,6 +26,8 @@ namespace BITKit.Vehicles
|
||||
|
||||
public sealed class Vehicle : EntityBehavior
|
||||
{
|
||||
[Header(Constant.Header.Services)] public bool Enabled;
|
||||
|
||||
[Header(Constant.Header.Settings)] public float maxMotorTorque = 64;
|
||||
[SerializeField] private float maxSteeringAngle = 45;
|
||||
[SerializeField] private float brakeTorque;
|
||||
@@ -98,6 +100,8 @@ namespace BITKit.Vehicles
|
||||
}
|
||||
public override void OnUpdate(float deltaTime)
|
||||
{
|
||||
if (Enabled is false) return;
|
||||
|
||||
var torque = maxMotorTorque *(optionalVertical.Allow ? optionalVertical.Value : vertical);
|
||||
var steel =maxSteeringAngle * (optionalHorizontal.Allow ? optionalHorizontal.Value : horizontal);
|
||||
axisInfos.ForEach(x =>
|
||||
|
Reference in New Issue
Block a user