更改文件架构
This commit is contained in:
32
Packages/Common~/Scripts/Location/LocationAdditive.cs
Normal file
32
Packages/Common~/Scripts/Location/LocationAdditive.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
public class LocationAdditive : BITBehavior
|
||||
{
|
||||
Vector3 currentPosition;
|
||||
Vector3 currentEulur;
|
||||
public void AddPosition(Vector3 value)
|
||||
{
|
||||
currentPosition += value;
|
||||
}
|
||||
public void AddEuler(Vector3 value)
|
||||
{
|
||||
currentEulur += value;
|
||||
}
|
||||
public void LateUpdate()
|
||||
{
|
||||
if (currentEulur.IsDefault() is false)
|
||||
{
|
||||
transform.localEulerAngles = currentEulur;
|
||||
currentEulur = default;
|
||||
}
|
||||
if (currentPosition.IsDefault() is false)
|
||||
{
|
||||
transform.localPosition = currentPosition;
|
||||
currentPosition = default;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Location/LocationAdditive.cs.meta
Normal file
11
Packages/Common~/Scripts/Location/LocationAdditive.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f0e3ba1501e26894d93927485d22f749
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
40
Packages/Common~/Scripts/Location/LocationMixer.cs
Normal file
40
Packages/Common~/Scripts/Location/LocationMixer.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
public class LocationMixer : BITBehavior
|
||||
{
|
||||
[System.Serializable]
|
||||
struct LocationInfo
|
||||
{
|
||||
public Location location;
|
||||
public float weight;
|
||||
}
|
||||
[SerializeField] Dictionary<int, LocationInfo> locations = new();
|
||||
public void SetLocation(Location location, int index = 0, float weight = 0)
|
||||
{
|
||||
locations.Set(index, new()
|
||||
{
|
||||
location = location,
|
||||
weight = weight
|
||||
});
|
||||
}
|
||||
void LateUpdate()
|
||||
{
|
||||
Location currentLocation = new();
|
||||
locations.ForEach(x =>
|
||||
{
|
||||
if (x.Key is 0)
|
||||
{
|
||||
currentLocation = x.Value.location * x.Value.weight;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentLocation=Location.Lerp(currentLocation,x.Value.location,x.Value.weight);
|
||||
}
|
||||
});
|
||||
transform.SetPositionAndRotation(currentLocation, currentLocation);
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Location/LocationMixer.cs.meta
Normal file
11
Packages/Common~/Scripts/Location/LocationMixer.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f25286178270714f8297b5e5fdbe6cc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user