浏览代码

Cinemachine Actions : Noise / Shake / Blends (#49)

* Add SetCameraNoise / SetCustomBlends

* Set Camera Noise

* Make Noise Work

* Updated Changelog

* Set Icons + Camera Shake Action

* Update Camera Shake Behavior, + Changelog

* Default Names
/main
GitHub 4 年前
当前提交
95715a7b
共有 9 个文件被更改,包括 451 次插入0 次删除
  1. 7
      CHANGELOG.md
  2. 87
      Icons/Misc/ic-cinemachine.png
  3. 120
      Icons/Misc/ic-cinemachine.png.meta
  4. 121
      Runtime/LevelScripting/Actions/CinemachineCameraShakeAction.cs
  5. 11
      Runtime/LevelScripting/Actions/CinemachineCameraShakeAction.cs.meta
  6. 43
      Runtime/LevelScripting/Actions/CinemachineSetCameraNoiseAction.cs
  7. 11
      Runtime/LevelScripting/Actions/CinemachineSetCameraNoiseAction.cs.meta
  8. 40
      Runtime/LevelScripting/Actions/CinemachineSetCustomBlendsAction.cs
  9. 11
      Runtime/LevelScripting/Actions/CinemachineSetCustomBlendsAction.cs.meta

7
CHANGELOG.md


## 2020.2.7
#### Added
* Added Cinemachine Actions:
* `CinemachineSetCameraNoiseAction` : Defines or remove noise for a Virtual Camera
* `CinemachineSetCustomBlendsAction` : Defines custom blends for the Cinemachine Brain of the Virtual Camera Manager
* `CinemachineCameraShakeAction` : Trigger camera shakes for Cinemachine Impulse Sources
## 2020.2.6
#### Added

87
Icons/Misc/ic-cinemachine.png

之前 之后
宽度: 64  |  高度: 64  |  大小: 8.8 KiB

120
Icons/Misc/ic-cinemachine.png.meta


fileFormatVersion: 2
guid: 72000c18f026a734089f93c2c31e8e04
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
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
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: 1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: -1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Windows Store Apps
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

121
Runtime/LevelScripting/Actions/CinemachineCameraShakeAction.cs


using UnityEngine;
using Cinemachine;
using NaughtyAttributes;
namespace GameplayIngredients.Actions
{
[Callable("Cinemachine", "Misc/ic-cinemachine.png")]
public class CinemachineCameraShakeAction : ActionBase
{
public enum ImpulseLocation
{
Self,
ImpulseSource,
OtherTransform,
InstigatorPosition
}
[InfoBox("Remember to add Cinemachine Impulse listeners extensions on Virtual Cameras you want to recieve these camera shakes.")]
[NonNullCheck]
public CinemachineImpulseSource impulseSource;
[Header("Position")]
[Tooltip("Which transform to use for the source of the camera shake")]
public ImpulseLocation impulseLocation = ImpulseLocation.Self;
[ShowIf("useRemoteTransform")]
[Tooltip("The alternate transform to use to generate impulses")]
public Transform otherTransform;
bool useRemoteTransform => impulseLocation == ImpulseLocation.OtherTransform;
[Header("Impulse")]
[Tooltip("Whether the Impulse Vector will be computed in local space (or world space)")]
public bool localSpace = true;
[Tooltip("The Impulse Vector to Use")]
public Vector3 baseImpulse = Vector3.up;
[Tooltip("Whether to apply randomness as well")]
public bool randomImpulse = false;
[Tooltip("The Random Variation scale of the Impulse")]
[ShowIf("randomImpulse")]
public Vector3 variation = Vector3.one;
[Tooltip("Whether to normalize the Base+Random Impulse")]
[ShowIf("randomImpulse")]
public bool normalize = false;
[Tooltip("A random rescale of the impulse vector, after normalization")]
[ShowIf(EConditionOperator.And, "randomImpulse", "normalize")]
public Vector2 postNormalizeRemap = Vector2.one;
public override void Execute(GameObject instigator = null)
{
if(impulseSource == null)
{
Debug.LogWarning($"CinemachineCameraShakeAction : No Impulse source was provided");
return;
}
Vector3 impulse = baseImpulse;
if(randomImpulse)
{
impulse += new Vector3(Random.Range(-variation.x / 2, variation.x / 2), Random.Range(-variation.y / 2, variation.y / 2), Random.Range(-variation.z / 2, variation.z / 2));
if(normalize)
{
impulse.Normalize();
impulse *= Random.Range(postNormalizeRemap.x, postNormalizeRemap.y);
}
}
switch (impulseLocation)
{
default:
case ImpulseLocation.Self:
if (localSpace)
impulse = transform.localToWorldMatrix.MultiplyVector(impulse);
impulseSource.GenerateImpulseAt(transform.position, impulse);
break;
case ImpulseLocation.ImpulseSource:
if (localSpace)
impulse = impulseSource.transform.localToWorldMatrix.MultiplyVector(impulse);
impulseSource.GenerateImpulseAt(impulseSource.transform.position, impulse);
break;
case ImpulseLocation.OtherTransform:
if(otherTransform != null)
{
if (localSpace)
impulse = otherTransform.localToWorldMatrix.MultiplyVector(impulse);
impulseSource.GenerateImpulseAt(otherTransform.position, impulse);
}
else
{
Debug.LogWarning("CinemachineCameraShakeAction : No RemoteTransform found for setting position, using self transform instead");
if (localSpace)
impulse = transform.localToWorldMatrix.MultiplyVector(impulse);
impulseSource.GenerateImpulse(impulse);
}
break;
case ImpulseLocation.InstigatorPosition:
if(instigator != null)
{
if (localSpace)
impulse = instigator.transform.localToWorldMatrix.MultiplyVector(impulse);
impulseSource.GenerateImpulseAt(instigator.transform.position, impulse);
}
else
{
Debug.LogWarning("CinemachineCameraShakeAction : No Instigator found for setting position, using self transform instead");
if (localSpace)
impulse = transform.localToWorldMatrix.MultiplyVector(impulse);
impulseSource.GenerateImpulse(impulse);
}
break;
}
}
public override string GetDefaultName() => $"CM CameraShake at {impulseLocation}";
}
}

11
Runtime/LevelScripting/Actions/CinemachineCameraShakeAction.cs.meta


fileFormatVersion: 2
guid: 70187ee618ca24743be77142bece5954
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 72000c18f026a734089f93c2c31e8e04, type: 3}
userData:
assetBundleName:
assetBundleVariant:

43
Runtime/LevelScripting/Actions/CinemachineSetCameraNoiseAction.cs


using UnityEngine;
using Cinemachine;
using NaughtyAttributes;
namespace GameplayIngredients.Actions
{
[Callable("Cinemachine", "Misc/ic-cinemachine.png")]
public class CinemachineSetCameraNoiseAction : ActionBase
{
[SerializeField]
bool useLiveCamera;
[SerializeField, HideIf("useLiveCamera")]
CinemachineVirtualCamera targetCamera;
[SerializeField]
NoiseSettings settings;
public override void Execute(GameObject instigator = null)
{
CinemachineVirtualCamera cam = useLiveCamera ?
Manager.Get<VirtualCameraManager>().GetComponent<CinemachineBrain>().ActiveVirtualCamera as CinemachineVirtualCamera
: targetCamera;
if(cam == null)
{
Debug.Log("CinemachineSetCameraNoiseAction : Cannot find a suitable CinemachineVirtualCamera to set Noise to");
return;
}
var noise = cam.GetCinemachineComponent<CinemachineBasicMultiChannelPerlin>();
if(noise == null && settings != null)
noise = cam.AddCinemachineComponent<CinemachineBasicMultiChannelPerlin>();
noise.m_NoiseProfile = settings;
}
public override string GetDefaultName() => $"CM Set Noise ({settings.name}) for {(useLiveCamera? "Live Camera" : targetCamera?.gameObject.name)}";
}
}

11
Runtime/LevelScripting/Actions/CinemachineSetCameraNoiseAction.cs.meta


fileFormatVersion: 2
guid: 1058d44f04ffbab47bb8ae0dbe56318c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 72000c18f026a734089f93c2c31e8e04, type: 3}
userData:
assetBundleName:
assetBundleVariant:

40
Runtime/LevelScripting/Actions/CinemachineSetCustomBlendsAction.cs


using UnityEngine;
using Cinemachine;
namespace GameplayIngredients.Actions
{
[Callable("Cinemachine", "Misc/ic-cinemachine.png")]
public class CinemachineSetCustomBlendsAction : ActionBase
{
public enum Action
{
Enable,
Disable
}
[SerializeField]
Action action;
[SerializeField]
CinemachineBlenderSettings settings;
public override void Execute(GameObject instigator = null)
{
if(Manager.TryGet(out VirtualCameraManager vcm))
{
if (action == Action.Disable || settings == null)
{
vcm.Brain.m_CustomBlends = null;
}
else
{
vcm.Brain.m_CustomBlends = settings;
}
}
}
public override string GetDefaultName() => $"{action} CM Custom Blends : {settings}";
}
}

11
Runtime/LevelScripting/Actions/CinemachineSetCustomBlendsAction.cs.meta


fileFormatVersion: 2
guid: f170ba3f4d14b2e4caa58c23d452a1aa
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 72000c18f026a734089f93c2c31e8e04, type: 3}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存