您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

61 行
1.7 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.VFX;
using UnityEngine.VFX.Utility;
public abstract class VFXVolumeMixerPropertyBinderBase : VFXBinderBase
{
public enum VolumeTrigger
{
SelfTransform = 0,
MainCamera = 1,
CustomTransform =2
}
[SerializeField]
protected VolumeTrigger Trigger;
[SerializeField]
protected LayerMask Layer;
[SerializeField]
protected Transform CustomTransform;
[SerializeField, Tooltip("If Trigger set To MainCamera, Use SceneCamera in Editor to preview instead of MainCamera")]
protected bool PreviewSceneCamera = true;
protected Transform computedTransform
{
get
{
switch(Trigger)
{
default:
case VolumeTrigger.SelfTransform: return gameObject.transform;
case VolumeTrigger.MainCamera:
#if UNITY_EDITOR
if (Application.isEditor && !Application.isPlaying && UnityEditor.SceneView.lastActiveSceneView != null)
return UnityEditor.SceneView.lastActiveSceneView.camera.transform;
else
#endif
{
if (Camera.main != null)
return Camera.main.transform;
else
return null;
}
case VolumeTrigger.CustomTransform: return CustomTransform;
}
}
}
public override bool IsValid(VisualEffect component)
{
return computedTransform != null;
}
public override string ToString()
{
return "(" + Trigger + ")";
}
}