BakeLight
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: afda85841890d5948bdf27e9b18b36eb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,130 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fba7f80db8855ce4cac9f8d14c3a995c
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 2
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 0
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 10, y: 10, z: 10, w: 10}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 4
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 1
|
||||
textureFormat: 4
|
||||
textureCompression: 2
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 1537655665
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spriteCustomMetadata:
|
||||
entries: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,130 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bc012667b957a98468907faa7f183227
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 2
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 0
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 10, y: 10, z: 10, w: 10}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 4
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 1
|
||||
textureFormat: 4
|
||||
textureCompression: 2
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 1537655665
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spriteCustomMetadata:
|
||||
entries: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -488,10 +488,10 @@ MonoBehaviour:
|
||||
maximumAngle: 55
|
||||
movementSpeed: 140
|
||||
maximumControlDistance: 4
|
||||
returnToRestOnRelease: 0
|
||||
restValue: 0
|
||||
activationThreshold: 0.85
|
||||
deactivationThreshold: 0.15
|
||||
switchThreshold: 0.5
|
||||
initialPositionIsMaximum: 0
|
||||
returnToInitialPositionAfterSwitch: 0
|
||||
automaticReturnDelay: 0.25
|
||||
leverValueChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
|
||||
@@ -19,12 +19,12 @@ public sealed class NetworkPhysicalLeverInteractable :
|
||||
|
||||
[Header("Control")]
|
||||
[SerializeField, Min(0.5f)] private float maximumControlDistance = 4f;
|
||||
[SerializeField] private bool returnToRestOnRelease;
|
||||
[SerializeField, Range(0f, 1f)] private float restValue;
|
||||
|
||||
[Header("Activation")]
|
||||
[SerializeField, Range(0f, 1f)] private float activationThreshold = 0.85f;
|
||||
[SerializeField, Range(0f, 1f)] private float deactivationThreshold = 0.15f;
|
||||
[Header("Two positions")]
|
||||
[SerializeField, Range(0.05f, 0.95f)] private float switchThreshold = 0.5f;
|
||||
[SerializeField] private bool initialPositionIsMaximum;
|
||||
[SerializeField] private bool returnToInitialPositionAfterSwitch;
|
||||
[SerializeField, Min(0f)] private float automaticReturnDelay = 0.25f;
|
||||
[SerializeField] private UnityEvent<float> leverValueChanged;
|
||||
[SerializeField] private UnityEvent<bool> leverStateChanged;
|
||||
|
||||
@@ -43,6 +43,10 @@ public sealed class NetworkPhysicalLeverInteractable :
|
||||
NetworkVariableReadPermission.Everyone,
|
||||
NetworkVariableWritePermission.Server);
|
||||
|
||||
private bool hasSnapTarget;
|
||||
private float snapTargetValue;
|
||||
private float automaticReturnTime = -1f;
|
||||
|
||||
public float Value => synchronizedValue.Value;
|
||||
public bool IsActivated => isActivated.Value;
|
||||
public bool IsControlled => controllingClientId.Value != NoController;
|
||||
@@ -66,6 +70,7 @@ public sealed class NetworkPhysicalLeverInteractable :
|
||||
private Vector3 HandleDirection => localHandleDirection.sqrMagnitude > 0.0001f
|
||||
? localHandleDirection.normalized
|
||||
: Vector3.up;
|
||||
private float InitialPositionValue => initialPositionIsMaximum ? 1f : 0f;
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
@@ -77,13 +82,18 @@ public sealed class NetworkPhysicalLeverInteractable :
|
||||
{
|
||||
if (maximumAngle < minimumAngle)
|
||||
maximumAngle = minimumAngle;
|
||||
|
||||
deactivationThreshold = Mathf.Min(deactivationThreshold, activationThreshold);
|
||||
}
|
||||
|
||||
public override void OnNetworkSpawn()
|
||||
{
|
||||
PlayerInteractionSessionRegistry.Register(this);
|
||||
|
||||
if (IsServer)
|
||||
{
|
||||
synchronizedValue.Value = InitialPositionValue;
|
||||
isActivated.Value = initialPositionIsMaximum;
|
||||
}
|
||||
|
||||
synchronizedValue.OnValueChanged += HandleValueChanged;
|
||||
isActivated.OnValueChanged += HandleActivationChanged;
|
||||
ApplyVisual(synchronizedValue.Value);
|
||||
@@ -108,17 +118,26 @@ public sealed class NetworkPhysicalLeverInteractable :
|
||||
if (!TryGetPlayerObject(controllingClientId.Value, out NetworkObject playerObject) ||
|
||||
!IsPlayerWithinControlDistance(playerObject))
|
||||
{
|
||||
controllingClientId.Value = NoController;
|
||||
EndControl();
|
||||
return;
|
||||
}
|
||||
|
||||
if (TryCalculateTargetValue(playerObject, out float targetValue))
|
||||
MoveTowardsValue(targetValue);
|
||||
|
||||
return;
|
||||
}
|
||||
else if (returnToRestOnRelease)
|
||||
|
||||
if (hasSnapTarget)
|
||||
{
|
||||
MoveTowardsValue(restValue);
|
||||
if (MoveTowardsValue(snapTargetValue))
|
||||
CompleteSnap();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (automaticReturnTime >= 0f && Time.time >= automaticReturnTime)
|
||||
BeginSnap(InitialPositionValue);
|
||||
}
|
||||
|
||||
public bool IsControlledBy(ulong clientId) =>
|
||||
@@ -137,16 +156,57 @@ public sealed class NetworkPhysicalLeverInteractable :
|
||||
ulong senderClientId,
|
||||
NetworkObject playerObject)
|
||||
{
|
||||
controllingClientId.Value = IsControlledBy(senderClientId)
|
||||
? NoController
|
||||
: senderClientId;
|
||||
if (IsControlledBy(senderClientId))
|
||||
EndControl();
|
||||
else
|
||||
BeginControl(senderClientId);
|
||||
}
|
||||
|
||||
[Rpc(SendTo.Server, InvokePermission = RpcInvokePermission.Everyone)]
|
||||
private void RequestReleaseServerRpc(RpcParams rpcParams = default)
|
||||
{
|
||||
if (IsControlledBy(rpcParams.Receive.SenderClientId))
|
||||
controllingClientId.Value = NoController;
|
||||
EndControl();
|
||||
}
|
||||
|
||||
private void BeginControl(ulong clientId)
|
||||
{
|
||||
hasSnapTarget = false;
|
||||
automaticReturnTime = -1f;
|
||||
controllingClientId.Value = clientId;
|
||||
}
|
||||
|
||||
private void EndControl()
|
||||
{
|
||||
if (!IsControlled)
|
||||
return;
|
||||
|
||||
controllingClientId.Value = NoController;
|
||||
float targetPosition = synchronizedValue.Value >= switchThreshold ? 1f : 0f;
|
||||
BeginSnap(targetPosition);
|
||||
}
|
||||
|
||||
private void BeginSnap(float targetValue)
|
||||
{
|
||||
automaticReturnTime = -1f;
|
||||
snapTargetValue = targetValue >= 0.5f ? 1f : 0f;
|
||||
hasSnapTarget = true;
|
||||
}
|
||||
|
||||
private void CompleteSnap()
|
||||
{
|
||||
hasSnapTarget = false;
|
||||
bool snappedToMaximum = snapTargetValue >= 0.5f;
|
||||
|
||||
if (isActivated.Value != snappedToMaximum)
|
||||
isActivated.Value = snappedToMaximum;
|
||||
|
||||
bool movedAwayFromInitialPosition =
|
||||
!Mathf.Approximately(snapTargetValue, InitialPositionValue);
|
||||
automaticReturnTime = returnToInitialPositionAfterSwitch &&
|
||||
movedAwayFromInitialPosition
|
||||
? Time.time + automaticReturnDelay
|
||||
: -1f;
|
||||
}
|
||||
|
||||
private bool IsPlayerWithinControlDistance(NetworkObject playerObject)
|
||||
@@ -208,7 +268,7 @@ public sealed class NetworkPhysicalLeverInteractable :
|
||||
return true;
|
||||
}
|
||||
|
||||
private void MoveTowardsValue(float targetValue)
|
||||
private bool MoveTowardsValue(float targetValue)
|
||||
{
|
||||
float angleRange = Mathf.Max(0.01f, maximumAngle - minimumAngle);
|
||||
float valueStep = movementSpeed / angleRange * Time.fixedDeltaTime;
|
||||
@@ -217,24 +277,10 @@ public sealed class NetworkPhysicalLeverInteractable :
|
||||
Mathf.Clamp01(targetValue),
|
||||
valueStep);
|
||||
|
||||
if (Mathf.Approximately(nextValue, synchronizedValue.Value))
|
||||
return;
|
||||
if (!Mathf.Approximately(nextValue, synchronizedValue.Value))
|
||||
synchronizedValue.Value = nextValue;
|
||||
|
||||
synchronizedValue.Value = nextValue;
|
||||
UpdateActivationState(nextValue);
|
||||
}
|
||||
|
||||
private void UpdateActivationState(float currentValue)
|
||||
{
|
||||
bool nextState = isActivated.Value;
|
||||
|
||||
if (!nextState && currentValue >= activationThreshold)
|
||||
nextState = true;
|
||||
else if (nextState && currentValue <= deactivationThreshold)
|
||||
nextState = false;
|
||||
|
||||
if (nextState != isActivated.Value)
|
||||
isActivated.Value = nextState;
|
||||
return Mathf.Approximately(nextValue, targetValue);
|
||||
}
|
||||
|
||||
private void HandleValueChanged(float _, float currentValue)
|
||||
@@ -259,8 +305,8 @@ public sealed class NetworkPhysicalLeverInteractable :
|
||||
[ContextMenu("Preview/Minimum")]
|
||||
private void PreviewMinimum() => ApplyVisual(0f);
|
||||
|
||||
[ContextMenu("Preview/Rest")]
|
||||
private void PreviewRest() => ApplyVisual(restValue);
|
||||
[ContextMenu("Preview/Initial Position")]
|
||||
private void PreviewInitialPosition() => ApplyVisual(InitialPositionValue);
|
||||
|
||||
[ContextMenu("Preview/Maximum")]
|
||||
private void PreviewMaximum() => ApplyVisual(1f);
|
||||
|
||||
+4664
-469
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user