update CCK to 3.10, fixing unity 2021 crash :)
This commit is contained in:
parent
48a978fa2a
commit
d11e0fb3a9
492 changed files with 2165204 additions and 437687 deletions
|
@ -3,10 +3,13 @@ using UnityEngine;
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class AnimatorDriver : StateMachineBehaviour
|
||||
[HelpURL("https://developers.abinteractive.net/cck/")]
|
||||
public class AnimatorDriver : StateMachineBehaviour, ICCK_Component
|
||||
{
|
||||
public List<AnimatorDriverTask> EnterTasks = new List<AnimatorDriverTask>();
|
||||
public List<AnimatorDriverTask> ExitTasks = new List<AnimatorDriverTask>();
|
||||
|
||||
public bool localOnly = false;
|
||||
|
||||
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
|
@ -124,10 +127,10 @@ namespace ABI.CCK.Components
|
|||
valB = bValue;
|
||||
break;
|
||||
case SourceType.Random:
|
||||
valB = Random.Range(bValue, aMax);
|
||||
valB = Random.Range(bValue, bMax);
|
||||
break;
|
||||
case SourceType.Parameter:
|
||||
switch (aParamType)
|
||||
switch (bParamType)
|
||||
{
|
||||
default:
|
||||
valB = 0f;
|
||||
|
@ -201,7 +204,7 @@ namespace ABI.CCK.Components
|
|||
animator.SetFloat(targetName, res);
|
||||
break;
|
||||
case ParameterType.Int:
|
||||
animator.SetInteger(targetName, (int) res);
|
||||
animator.SetInteger(targetName, Mathf.RoundToInt(res));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
126
Assets/ABI.CCK/Components/BodyControl.cs
Executable file
126
Assets/ABI.CCK/Components/BodyControl.cs
Executable file
|
@ -0,0 +1,126 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
[HelpURL("https://developers.abinteractive.net/cck/")]
|
||||
public class BodyControl : StateMachineBehaviour, ICCK_Component
|
||||
{
|
||||
#region UnityEvents
|
||||
|
||||
// Events for third party components to hook into
|
||||
public static readonly UnityEvent<Animator, BodyControl> OnInitialized = new();
|
||||
public static readonly UnityEvent<Animator, BodyControlTask> OnExecuteEnterTask = new();
|
||||
public static readonly UnityEvent<Animator, BodyControlTask> OnExecuteExitTask = new();
|
||||
|
||||
#endregion
|
||||
|
||||
public List<BodyControlTask> EnterTasks = new();
|
||||
public List<BodyControlTask> ExitTasks = new();
|
||||
|
||||
private bool _initialized;
|
||||
|
||||
#region Unity Events
|
||||
|
||||
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
if (!_initialized) Initialize(animator);
|
||||
foreach (BodyControlTask task in EnterTasks)
|
||||
{
|
||||
task.Execute(animator);
|
||||
OnExecuteEnterTask.Invoke(animator, task);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
if (!_initialized) Initialize(animator);
|
||||
foreach (BodyControlTask task in ExitTasks)
|
||||
{
|
||||
task.Execute(animator);
|
||||
OnExecuteExitTask.Invoke(animator, task);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void Initialize(Animator animator)
|
||||
{
|
||||
_initialized = true;
|
||||
OnInitialized.Invoke(animator, this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Editor Methods
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
var seenTargets = new HashSet<BodyControlTask.BodyMask>();
|
||||
|
||||
for (int i = EnterTasks.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (!seenTargets.Add(EnterTasks[i].target))
|
||||
EnterTasks.RemoveAt(i);
|
||||
}
|
||||
seenTargets.Clear();
|
||||
|
||||
for (int i = ExitTasks.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (!seenTargets.Add(ExitTasks[i].target))
|
||||
ExitTasks.RemoveAt(i);
|
||||
}
|
||||
seenTargets.Clear();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class BodyControlTask
|
||||
{
|
||||
public enum BodyMask
|
||||
{
|
||||
Head,
|
||||
Pelvis,
|
||||
LeftArm,
|
||||
RightArm,
|
||||
LeftLeg,
|
||||
RightLeg,
|
||||
Locomotion,
|
||||
// TODO: Add FingerTracking masks when GS is ready
|
||||
}
|
||||
|
||||
public BodyMask target = BodyMask.Head;
|
||||
[Range(0f, 1f)] public float targetWeight = 1f;
|
||||
public float transitionDuration = 0f;
|
||||
|
||||
// Type
|
||||
public bool isBlend = false;
|
||||
|
||||
public void Execute(Animator animator)
|
||||
{
|
||||
// switch (target)
|
||||
// {
|
||||
// case BodyMask.Head:
|
||||
// break;
|
||||
// case BodyMask.Pelvis:
|
||||
// break;
|
||||
// case BodyMask.LeftArm:
|
||||
// break;
|
||||
// case BodyMask.RightArm:
|
||||
// break;
|
||||
// case BodyMask.LeftLeg:
|
||||
// break;
|
||||
// case BodyMask.RightLeg:
|
||||
// break;
|
||||
// case BodyMask.Locomotion:
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/ABI.CCK/Components/BodyControl.cs.meta
Executable file
11
Assets/ABI.CCK/Components/BodyControl.cs.meta
Executable file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 28af9fcbea0c32d4baddcf00cc581d7f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 8d4eaf52fbae23548874e96ac0d52276, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -2,12 +2,13 @@
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRAction : MonoBehaviour
|
||||
[AddComponentMenu("")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/")]
|
||||
public class CVRAction : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
[Header("Meta")]
|
||||
public string actionName;
|
||||
[Header("Objects")]
|
||||
public GameObject[] actionObjects;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
[AddComponentMenu("")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/pointer/")]
|
||||
public class CVRAdvancedAvatarSettingsPointer : CVRPointer
|
||||
{
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
if (isActiveAndEnabled)
|
||||
{
|
||||
Gizmos.color = Color.cyan;
|
||||
Matrix4x4 rotationMatrix = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one);
|
||||
Gizmos.matrix = rotationMatrix;
|
||||
Gizmos.DrawSphere(Vector3.zero, 0.015f);
|
||||
}
|
||||
if (!isActiveAndEnabled)
|
||||
return;
|
||||
|
||||
Gizmos.color = Color.cyan;
|
||||
Matrix4x4 rotationMatrix = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one);
|
||||
Gizmos.matrix = rotationMatrix;
|
||||
Gizmos.DrawSphere(Vector3.zero, 0.015f);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,28 +1,29 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRAdvancedAvatarSettingsTrigger : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Advanced Avatar Trigger")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/aas-trigger/")]
|
||||
[DisallowMultipleComponent]
|
||||
public class CVRAdvancedAvatarSettingsTrigger : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public Vector3 areaSize = new Vector3(0.05f, 0.05f, 0.05f);
|
||||
public Vector3 areaOffset = Vector3.zero;
|
||||
public string settingName;
|
||||
public float settingValue = 0;
|
||||
public float settingValue;
|
||||
|
||||
public bool useAdvancedTrigger = false;
|
||||
public bool useAdvancedTrigger;
|
||||
public bool isLocalInteractable = true;
|
||||
public bool isNetworkInteractable = true;
|
||||
[SerializeField]
|
||||
public List<CVRPointer> allowedPointer = new List<CVRPointer>();
|
||||
public bool allowParticleInteraction;
|
||||
|
||||
public string[] allowedTypes = new string[0];
|
||||
public bool allowParticleInteraction = false;
|
||||
[SerializeField] public List<CVRPointer> allowedPointer = new List<CVRPointer>();
|
||||
public string[] allowedTypes = Array.Empty<string>();
|
||||
|
||||
public List<CVRAdvancedAvatarSettingsTriggerTask> enterTasks = new List<CVRAdvancedAvatarSettingsTriggerTask>();
|
||||
public List<CVRAdvancedAvatarSettingsTriggerTask> exitTasks = new List<CVRAdvancedAvatarSettingsTriggerTask>();
|
||||
|
||||
public List<CVRAdvancedAvatarSettingsTriggerTaskStay> stayTasks = new List<CVRAdvancedAvatarSettingsTriggerTaskStay>();
|
||||
|
||||
public enum SampleDirection
|
||||
|
@ -36,166 +37,181 @@ namespace ABI.CCK.Components
|
|||
}
|
||||
|
||||
public SampleDirection sampleDirection = SampleDirection.XPositive;
|
||||
|
||||
|
||||
public void Trigger()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void EnterTrigger()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void ExitTrigger()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void StayTrigger(float percent = 0f)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void OnDrawGizmosSelected()
|
||||
{
|
||||
if (isActiveAndEnabled)
|
||||
if (!isActiveAndEnabled)
|
||||
return;
|
||||
|
||||
Gizmos.color = Color.cyan;
|
||||
Matrix4x4 rotationMatrix = Matrix4x4.TRS(transform.position, transform.rotation, transform.lossyScale);
|
||||
Gizmos.matrix = rotationMatrix;
|
||||
|
||||
Collider collider = gameObject.GetComponent<Collider>();
|
||||
if (collider == null)
|
||||
{
|
||||
Gizmos.color = Color.cyan;
|
||||
Matrix4x4 rotationMatrix = Matrix4x4.TRS(transform.position, transform.rotation, transform.lossyScale);
|
||||
Gizmos.matrix = rotationMatrix;
|
||||
Gizmos.DrawCube(areaOffset, areaSize);
|
||||
|
||||
Vector3 bounds = new Vector3(areaSize.x * 0.5f, areaSize.y * 0.5f, areaSize.z * 0.5f);
|
||||
|
||||
if (stayTasks.Count > 0)
|
||||
if (OnlyHasDistanceTask())
|
||||
{
|
||||
Gizmos.DrawWireCube(areaOffset, areaSize);
|
||||
Gizmos.DrawSphere(Vector3.zero, areaSize.x);
|
||||
Gizmos.DrawWireSphere(Vector3.zero, areaSize.x);
|
||||
}
|
||||
else
|
||||
{
|
||||
Gizmos.DrawCube(areaOffset, areaSize);
|
||||
}
|
||||
}
|
||||
|
||||
switch (sampleDirection)
|
||||
{
|
||||
case SampleDirection.XPositive:
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(bounds.x, 0f, bounds.z) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, -bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(bounds.x, 0f, bounds.z) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(bounds.x, bounds.y, 0f) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, bounds.y, -bounds.z) + areaOffset,
|
||||
new Vector3(bounds.x, bounds.y, 0f) + areaOffset
|
||||
);
|
||||
break;
|
||||
case SampleDirection.XNegative:
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(bounds.x, bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(-bounds.x, 0f, bounds.z) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(bounds.x, -bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(-bounds.x, 0f, bounds.z) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(bounds.x, bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(-bounds.x, bounds.y, 0f) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(bounds.x, bounds.y, -bounds.z) + areaOffset,
|
||||
new Vector3(-bounds.x, bounds.y, 0f) + areaOffset
|
||||
);
|
||||
break;
|
||||
case SampleDirection.YPositive:
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, -bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(0f, bounds.y, bounds.z) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(bounds.x, -bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(0f, bounds.y, bounds.z) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, -bounds.y, -bounds.z) + areaOffset,
|
||||
new Vector3(-bounds.x, bounds.y, 0f) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, -bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(-bounds.x, bounds.y, 0f) + areaOffset
|
||||
);
|
||||
break;
|
||||
case SampleDirection.YNegative:
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(0f, -bounds.y, bounds.z) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(bounds.x, bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(0f, -bounds.y, bounds.z) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, bounds.y, -bounds.z) + areaOffset,
|
||||
new Vector3(-bounds.x, -bounds.y, 0f) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(-bounds.x, -bounds.y, 0f) + areaOffset
|
||||
);
|
||||
break;
|
||||
case SampleDirection.ZPositive:
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, bounds.y, -bounds.z) + areaOffset,
|
||||
new Vector3(0f, bounds.y, bounds.z) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(bounds.x, bounds.y, -bounds.z) + areaOffset,
|
||||
new Vector3(0f, bounds.y, bounds.z) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, bounds.y, -bounds.z) + areaOffset,
|
||||
new Vector3(-bounds.x, 0f, bounds.z) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, -bounds.y, -bounds.z) + areaOffset,
|
||||
new Vector3(-bounds.x, 0f, bounds.z) + areaOffset
|
||||
);
|
||||
break;
|
||||
case SampleDirection.ZNegative:
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(0f, bounds.y, -bounds.z) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(bounds.x, bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(0f, bounds.y, -bounds.z) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(-bounds.x, 0f, -bounds.z) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, -bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(-bounds.x, 0f, -bounds.z) + areaOffset
|
||||
);
|
||||
break;
|
||||
}
|
||||
Vector3 bounds = new Vector3(areaSize.x * 0.5f, areaSize.y * 0.5f, areaSize.z * 0.5f);
|
||||
|
||||
if (stayTasks.Count > 0 && !OnlyHasDistanceTask())
|
||||
{
|
||||
Gizmos.DrawWireCube(areaOffset, areaSize);
|
||||
|
||||
switch (sampleDirection)
|
||||
{
|
||||
case SampleDirection.XPositive:
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(bounds.x, 0f, bounds.z) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, -bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(bounds.x, 0f, bounds.z) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(bounds.x, bounds.y, 0f) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, bounds.y, -bounds.z) + areaOffset,
|
||||
new Vector3(bounds.x, bounds.y, 0f) + areaOffset
|
||||
);
|
||||
break;
|
||||
case SampleDirection.XNegative:
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(bounds.x, bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(-bounds.x, 0f, bounds.z) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(bounds.x, -bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(-bounds.x, 0f, bounds.z) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(bounds.x, bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(-bounds.x, bounds.y, 0f) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(bounds.x, bounds.y, -bounds.z) + areaOffset,
|
||||
new Vector3(-bounds.x, bounds.y, 0f) + areaOffset
|
||||
);
|
||||
break;
|
||||
case SampleDirection.YPositive:
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, -bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(0f, bounds.y, bounds.z) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(bounds.x, -bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(0f, bounds.y, bounds.z) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, -bounds.y, -bounds.z) + areaOffset,
|
||||
new Vector3(-bounds.x, bounds.y, 0f) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, -bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(-bounds.x, bounds.y, 0f) + areaOffset
|
||||
);
|
||||
break;
|
||||
case SampleDirection.YNegative:
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(0f, -bounds.y, bounds.z) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(bounds.x, bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(0f, -bounds.y, bounds.z) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, bounds.y, -bounds.z) + areaOffset,
|
||||
new Vector3(-bounds.x, -bounds.y, 0f) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(-bounds.x, -bounds.y, 0f) + areaOffset
|
||||
);
|
||||
break;
|
||||
case SampleDirection.ZPositive:
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, bounds.y, -bounds.z) + areaOffset,
|
||||
new Vector3(0f, bounds.y, bounds.z) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(bounds.x, bounds.y, -bounds.z) + areaOffset,
|
||||
new Vector3(0f, bounds.y, bounds.z) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, bounds.y, -bounds.z) + areaOffset,
|
||||
new Vector3(-bounds.x, 0f, bounds.z) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, -bounds.y, -bounds.z) + areaOffset,
|
||||
new Vector3(-bounds.x, 0f, bounds.z) + areaOffset
|
||||
);
|
||||
break;
|
||||
case SampleDirection.ZNegative:
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(0f, bounds.y, -bounds.z) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(bounds.x, bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(0f, bounds.y, -bounds.z) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(-bounds.x, 0f, -bounds.z) + areaOffset
|
||||
);
|
||||
Gizmos.DrawLine(
|
||||
new Vector3(-bounds.x, -bounds.y, bounds.z) + areaOffset,
|
||||
new Vector3(-bounds.x, 0f, -bounds.z) + areaOffset
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool OnlyHasDistanceTask()
|
||||
{
|
||||
return enterTasks.Count == 0 && exitTasks.Count == 0 && stayTasks.Count > 0 && stayTasks.FindAll(x =>
|
||||
x.updateMethod != CVRAdvancedAvatarSettingsTriggerTaskStay.UpdateMethod.SetFromDistance).Count == 0;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
[Serializable]
|
||||
public class CVRAdvancedAvatarSettingsTriggerTask
|
||||
{
|
||||
public string settingName;
|
||||
public float settingValue = 0f;
|
||||
public float delay = 0f;
|
||||
public float holdTime = 0f;
|
||||
|
||||
|
||||
public enum UpdateMethod
|
||||
{
|
||||
Override = 1,
|
||||
|
@ -204,23 +220,24 @@ namespace ABI.CCK.Components
|
|||
Toggle = 4
|
||||
}
|
||||
|
||||
public CVRAdvancedAvatarSettingsTriggerTask.UpdateMethod updateMethod = UpdateMethod.Override;
|
||||
public UpdateMethod updateMethod = UpdateMethod.Override;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
|
||||
[Serializable]
|
||||
public class CVRAdvancedAvatarSettingsTriggerTaskStay
|
||||
{
|
||||
public string settingName;
|
||||
public float minValue = 0f;
|
||||
public float maxValue = 1f;
|
||||
|
||||
|
||||
public enum UpdateMethod
|
||||
{
|
||||
SetFromPosition = 1,
|
||||
Add = 2,
|
||||
Subtract = 3,
|
||||
SetFromDistance = 4
|
||||
}
|
||||
|
||||
public CVRAdvancedAvatarSettingsTriggerTaskStay.UpdateMethod updateMethod = UpdateMethod.SetFromPosition;
|
||||
|
||||
public UpdateMethod updateMethod = UpdateMethod.SetFromPosition;
|
||||
}
|
||||
}
|
|
@ -1,26 +1,15 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRAdvancedAvatarSettingsTriggerHelper : MonoBehaviour
|
||||
[AddComponentMenu("")] // hidden from the Add Component menu
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/aas-trigger-helper/")]
|
||||
public class CVRAdvancedAvatarSettingsTriggerHelper : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public List<CVRAdvancedAvatarSettingsTrigger> triggers = new List<CVRAdvancedAvatarSettingsTrigger>();
|
||||
|
||||
public void onEnter(int i)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void onExit(int i)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void onStay(int i)
|
||||
{
|
||||
|
||||
}
|
||||
//public List<CVRAdvancedAvatarSettingsTrigger> triggers = new List<CVRAdvancedAvatarSettingsTrigger>();
|
||||
// public void onEnter(int i) { }
|
||||
// public void onExit(int i) { }
|
||||
// public void onStay(int i) { }
|
||||
}
|
||||
}
|
|
@ -1,9 +1,12 @@
|
|||
using System.Collections.Generic;
|
||||
using ABI.CCK.Scripts;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRAnimatorDriver : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Animator Driver")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/animator-driver/")]
|
||||
public class CVRAnimatorDriver : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public float animatorParameter01;
|
||||
public float animatorParameter02;
|
||||
|
@ -22,25 +25,22 @@ namespace ABI.CCK.Components
|
|||
public float animatorParameter15;
|
||||
public float animatorParameter16;
|
||||
|
||||
[HideInInspector]
|
||||
public List<Animator> animators = new List<Animator>();
|
||||
[HideInInspector]
|
||||
public List<string> animatorParameters = new List<string>();
|
||||
[HideInInspector]
|
||||
public List<int> animatorParameterType = new List<int>();
|
||||
public List<Animator> animators = new();
|
||||
public List<string> animatorParameters = new();
|
||||
public List<int> animatorParameterType = new(); // why do we store these? we could cache on start
|
||||
|
||||
private void OnDidApplyAnimationProperties()
|
||||
{
|
||||
if (animators.Count >= 1) ApplyAnimatorChange(animators[ 0], animatorParameters[ 0], animatorParameterType[ 0], animatorParameter01);
|
||||
if (animators.Count >= 2) ApplyAnimatorChange(animators[ 1], animatorParameters[ 1], animatorParameterType[ 1], animatorParameter02);
|
||||
if (animators.Count >= 3) ApplyAnimatorChange(animators[ 2], animatorParameters[ 2], animatorParameterType[ 2], animatorParameter03);
|
||||
if (animators.Count >= 4) ApplyAnimatorChange(animators[ 3], animatorParameters[ 3], animatorParameterType[ 3], animatorParameter04);
|
||||
if (animators.Count >= 5) ApplyAnimatorChange(animators[ 4], animatorParameters[ 4], animatorParameterType[ 4], animatorParameter05);
|
||||
if (animators.Count >= 6) ApplyAnimatorChange(animators[ 5], animatorParameters[ 5], animatorParameterType[ 5], animatorParameter06);
|
||||
if (animators.Count >= 7) ApplyAnimatorChange(animators[ 6], animatorParameters[ 6], animatorParameterType[ 6], animatorParameter07);
|
||||
if (animators.Count >= 8) ApplyAnimatorChange(animators[ 7], animatorParameters[ 7], animatorParameterType[ 7], animatorParameter08);
|
||||
if (animators.Count >= 9) ApplyAnimatorChange(animators[ 8], animatorParameters[ 8], animatorParameterType[ 8], animatorParameter09);
|
||||
if (animators.Count >= 10) ApplyAnimatorChange(animators[ 9], animatorParameters[ 9], animatorParameterType[ 9], animatorParameter10);
|
||||
if (animators.Count >= 1) ApplyAnimatorChange(animators[0], animatorParameters[0], animatorParameterType[0], animatorParameter01);
|
||||
if (animators.Count >= 2) ApplyAnimatorChange(animators[1], animatorParameters[1], animatorParameterType[1], animatorParameter02);
|
||||
if (animators.Count >= 3) ApplyAnimatorChange(animators[2], animatorParameters[2], animatorParameterType[2], animatorParameter03);
|
||||
if (animators.Count >= 4) ApplyAnimatorChange(animators[3], animatorParameters[3], animatorParameterType[3], animatorParameter04);
|
||||
if (animators.Count >= 5) ApplyAnimatorChange(animators[4], animatorParameters[4], animatorParameterType[4], animatorParameter05);
|
||||
if (animators.Count >= 6) ApplyAnimatorChange(animators[5], animatorParameters[5], animatorParameterType[5], animatorParameter06);
|
||||
if (animators.Count >= 7) ApplyAnimatorChange(animators[6], animatorParameters[6], animatorParameterType[6], animatorParameter07);
|
||||
if (animators.Count >= 8) ApplyAnimatorChange(animators[7], animatorParameters[7], animatorParameterType[7], animatorParameter08);
|
||||
if (animators.Count >= 9) ApplyAnimatorChange(animators[8], animatorParameters[8], animatorParameterType[8], animatorParameter09);
|
||||
if (animators.Count >= 10) ApplyAnimatorChange(animators[9], animatorParameters[9], animatorParameterType[9], animatorParameter10);
|
||||
if (animators.Count >= 11) ApplyAnimatorChange(animators[10], animatorParameters[10], animatorParameterType[10], animatorParameter11);
|
||||
if (animators.Count >= 12) ApplyAnimatorChange(animators[11], animatorParameters[11], animatorParameterType[11], animatorParameter12);
|
||||
if (animators.Count >= 13) ApplyAnimatorChange(animators[12], animatorParameters[12], animatorParameterType[12], animatorParameter13);
|
||||
|
@ -49,24 +49,71 @@ namespace ABI.CCK.Components
|
|||
if (animators.Count >= 16) ApplyAnimatorChange(animators[15], animatorParameters[15], animatorParameterType[15], animatorParameter16);
|
||||
}
|
||||
|
||||
private void ApplyAnimatorChange(Animator animator, string parameterName, int parameterType, float parameterValue)
|
||||
private void ApplyAnimatorChange(Animator animator, string parameterName, int parameterType,
|
||||
float parameterValue)
|
||||
{
|
||||
if (parameterName != "-none-")
|
||||
if (parameterName == CVRCommon.NONE_OR_EMPTY)
|
||||
return;
|
||||
|
||||
switch (parameterType)
|
||||
{
|
||||
switch (parameterType)
|
||||
case 0:
|
||||
animator.SetFloat(parameterName, parameterValue);
|
||||
break;
|
||||
case 1:
|
||||
animator.SetInteger(parameterName, Mathf.RoundToInt(parameterValue));
|
||||
break;
|
||||
case 2:
|
||||
animator.SetBool(parameterName, parameterValue > 0.5f);
|
||||
break;
|
||||
case 3:
|
||||
if (parameterValue > 0.5f) animator.SetTrigger(parameterName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
if (animators.Count > 16) // cap at 16
|
||||
animators.RemoveRange(16, animators.Count - 16);
|
||||
|
||||
// keep the list count in sync by adding/removing elements as needed
|
||||
|
||||
if (animatorParameters.Count > animators.Count)
|
||||
animatorParameters.RemoveRange(animators.Count, animatorParameters.Count - animators.Count);
|
||||
else while (animatorParameters.Count < animators.Count) animatorParameters.Add(CVRCommon.NONE_OR_EMPTY);
|
||||
|
||||
if (animatorParameterType.Count > animators.Count)
|
||||
animatorParameterType.RemoveRange(animators.Count, animatorParameterType.Count - animators.Count);
|
||||
else while (animatorParameterType.Count < animators.Count) animatorParameterType.Add(-1); // -1 is invalid
|
||||
|
||||
// update the parameter type list
|
||||
for (int i = 0; i < animators.Count; i++)
|
||||
{
|
||||
Animator animator = animators[i];
|
||||
string parameterName = animatorParameters[i];
|
||||
|
||||
if (animator == null || parameterName == CVRCommon.NONE_OR_EMPTY)
|
||||
{
|
||||
case 0:
|
||||
animator.SetFloat(parameterName, parameterValue);
|
||||
break;
|
||||
case 1:
|
||||
animator.SetInteger(parameterName, (int) parameterValue);
|
||||
break;
|
||||
case 2:
|
||||
animator.SetBool(parameterName, parameterValue > 0.5f);
|
||||
break;
|
||||
case 3:
|
||||
if (parameterValue > 0.5f) animator.SetTrigger(parameterName);
|
||||
break;
|
||||
animatorParameterType[i] = -1;
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (AnimatorControllerParameter parameter in animator.parameters)
|
||||
{
|
||||
if (parameter.name != parameterName) continue;
|
||||
|
||||
// 0 = float, 1 = int, 2 = bool, 3 = trigger
|
||||
animatorParameterType[i] = parameter.type switch
|
||||
{
|
||||
AnimatorControllerParameterType.Float => 0,
|
||||
AnimatorControllerParameterType.Int => 1,
|
||||
AnimatorControllerParameterType.Bool => 2,
|
||||
AnimatorControllerParameterType.Trigger => 3,
|
||||
_ => -1 // invalid
|
||||
};
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
using System;
|
||||
using ABI.CCK.Scripts;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRAssetInfo : MonoBehaviour
|
||||
[AddComponentMenu("")]
|
||||
[DisallowMultipleComponent]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/asset-info/")]
|
||||
public class CVRAssetInfo : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public enum AssetType
|
||||
{
|
||||
|
@ -13,12 +14,31 @@ namespace ABI.CCK.Components
|
|||
World = 2,
|
||||
Spawnable = 3
|
||||
}
|
||||
|
||||
|
||||
public AssetType type;
|
||||
public string objectId;
|
||||
|
||||
[HideInInspector]
|
||||
public string randomNum;
|
||||
|
||||
[HideInInspector]
|
||||
public string unityVersion;
|
||||
|
||||
[HideInInspector]
|
||||
public string cckVersion;
|
||||
|
||||
// just to make sure
|
||||
private void OnValidate() => Reset();
|
||||
private void Reset()
|
||||
{
|
||||
unityVersion = Application.unityVersion;
|
||||
cckVersion = $"{CVRCommon.CCK_VERSION_NUMBER}:{CVRCommon.CCK_BUILD_NUMBER}";
|
||||
if (TryGetComponent(out CVRAvatar _))
|
||||
type = AssetType.Avatar;
|
||||
if (TryGetComponent(out CVRWorld _))
|
||||
type = AssetType.World;
|
||||
if (TryGetComponent(out CVRSpawnable _))
|
||||
type = AssetType.Spawnable;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,9 @@ using UnityEngine.Events;
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRAttachment : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Attachment")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/attachment/")]
|
||||
public class CVRAttachment : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
[System.Flags]
|
||||
public enum AttachmentType
|
||||
|
|
|
@ -1,74 +1,95 @@
|
|||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRAudioDriver : MonoBehaviour
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/audio-driver/")]
|
||||
public class CVRAudioDriver : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public AudioSource audioSource;
|
||||
[SerializeField]
|
||||
|
||||
[SerializeField]
|
||||
public List<AudioClip> audioClips = new List<AudioClip>();
|
||||
public int selectedAudioClip = 0;
|
||||
public int selectedAudioClip;
|
||||
public bool playOnSwitch = true;
|
||||
|
||||
private int _selectedAudioClip = 0;
|
||||
private int _selectedAudioClip;
|
||||
|
||||
private void OnDidApplyAnimationProperties()
|
||||
{
|
||||
if (selectedAudioClip != _selectedAudioClip)
|
||||
{
|
||||
if(SetAudioClip(selectedAudioClip) && playOnSwitch) PlaySound();
|
||||
}
|
||||
}
|
||||
#region Unity Events
|
||||
|
||||
private void OnValidate() => CheckAndUpdateAudioClip(); // Editor testing
|
||||
private void OnDidApplyAnimationProperties() => CheckAndUpdateAudioClip();
|
||||
|
||||
private bool SetAudioClip(int index)
|
||||
{
|
||||
if (index < audioClips.Count)
|
||||
{
|
||||
if (audioClips[index] != null && audioSource != null)
|
||||
{
|
||||
audioSource.clip = audioClips[index];
|
||||
_selectedAudioClip = selectedAudioClip;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
return false;
|
||||
}
|
||||
#region Public Methods
|
||||
|
||||
[PublicAPI]
|
||||
public void PlaySound(int index)
|
||||
{
|
||||
if (SetAudioClip(index)) PlaySound();
|
||||
}
|
||||
=> SetAndMaybePlay(index);
|
||||
|
||||
[PublicAPI]
|
||||
public void PlaySound()
|
||||
{
|
||||
if (audioSource != null) audioSource.Play();
|
||||
if (audioSource != null && audioSource.isActiveAndEnabled)
|
||||
audioSource.Play();
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public void PlayNext()
|
||||
{
|
||||
if (_selectedAudioClip + 1 >= audioClips.Count)
|
||||
{
|
||||
PlaySound(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
PlaySound(_selectedAudioClip + 1);
|
||||
}
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public void PlayPrev()
|
||||
{
|
||||
if (_selectedAudioClip == 0)
|
||||
{
|
||||
PlaySound(audioClips.Count - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
PlaySound(_selectedAudioClip - 1);
|
||||
}
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public void SelectRandomSound()
|
||||
=> SetAndMaybePlay(Random.Range(0, audioClips.Count));
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void CheckAndUpdateAudioClip()
|
||||
{
|
||||
if (SetAudioClip(Random.Range(0, audioClips.Count)) && playOnSwitch) PlaySound();
|
||||
if (selectedAudioClip != _selectedAudioClip)
|
||||
SetAndMaybePlay(selectedAudioClip);
|
||||
}
|
||||
|
||||
private void SetAndMaybePlay(int index)
|
||||
{
|
||||
if (SetAudioClip(index) && playOnSwitch)
|
||||
PlaySound();
|
||||
}
|
||||
|
||||
private bool SetAudioClip(int index)
|
||||
{
|
||||
_selectedAudioClip = index;
|
||||
|
||||
if (index >= audioClips.Count
|
||||
|| index < 0)
|
||||
return false;
|
||||
|
||||
if (audioClips[index] == null
|
||||
|| audioSource == null)
|
||||
return false;
|
||||
|
||||
audioSource.clip = audioClips[index];
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -3,7 +3,9 @@ using UnityEngine;
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRAudioMaterialParser : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Audio Material Parser")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/audio-material-parser/")]
|
||||
public class CVRAudioMaterialParser : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public bool useSeparateAudioSources = false;
|
||||
|
||||
|
|
|
@ -1,58 +1,224 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ABI.CCK.Scripts;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Animations;
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
[RequireComponent(typeof(CVRAssetInfo))]
|
||||
[RequireComponent(typeof(Animator))]
|
||||
[ExecuteInEditMode]
|
||||
public class CVRAvatar : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Avatar")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/avatar/")]
|
||||
[RequireComponent(typeof(Animator))]
|
||||
public class CVRAvatar : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public enum CVRAvatarVoiceParent
|
||||
#region Editor Methods
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
Head = 0,
|
||||
LeftHand = 2,
|
||||
RightHand = 3,
|
||||
Hips = 4
|
||||
if (GetComponent<CVRAssetInfo>() != null) return;
|
||||
CVRAssetInfo info = gameObject.AddComponent<CVRAssetInfo>();
|
||||
info.type = CVRAssetInfo.AssetType.Avatar;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CVRAvatarEnums
|
||||
|
||||
public enum CVRAvatarVoiceParent { Head = 0, LeftHand = 2, RightHand = 3, Hips = 4 }
|
||||
public enum CVRAvatarVisemeMode { Visemes = 0, SingleBlendshape = 1, JawBone = 2 }
|
||||
|
||||
#endregion
|
||||
|
||||
#region General Avatar Settings
|
||||
//[Space] [Header("General Avatar Settings")] [Space]
|
||||
|
||||
[Space] [Header("General avatar settings")] [Space]
|
||||
public Vector3 viewPosition = new Vector3(0, 0.1f, 0);
|
||||
public Vector3 voicePosition = new Vector3(0, 0.1f, 0);
|
||||
public Vector3 voicePosition = new Vector3(0, 0.15f, 0);
|
||||
public CVRAvatarVoiceParent voiceParent = CVRAvatarVoiceParent.Head;
|
||||
public bool useEyeMovement = true;
|
||||
public bool useBlinkBlendshapes;
|
||||
public bool useVisemeLipsync;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Avatar Customization
|
||||
//[Space] [Header("Avatar Customization")] [Space]
|
||||
|
||||
public AnimatorOverrideController overrides;
|
||||
public SkinnedMeshRenderer bodyMesh;
|
||||
|
||||
public string[] blinkBlendshape = new string[4];
|
||||
/// <summary>
|
||||
/// Interval to change targets for the eye movement in seconds
|
||||
/// </summary>
|
||||
[SerializeField] public Vector2 eyeMovementInterval = new(5f, 10f);
|
||||
|
||||
#endregion
|
||||
|
||||
public enum CVRAvatarVisemeMode
|
||||
#region Eye Look Settings
|
||||
|
||||
/// <summary>
|
||||
/// Whether to use Eye Movement or not
|
||||
/// </summary>
|
||||
[SerializeField] public bool useEyeMovement = true;
|
||||
|
||||
/// <summary>
|
||||
/// Structure holding the detailed information for the eye movement
|
||||
/// </summary>
|
||||
[SerializeField] public EyeMovementInfo eyeMovementInfo = new EyeMovementInfo();
|
||||
|
||||
// Limits for the eye movement interval
|
||||
[NonSerialized] public const float EyeMovementMinIntervalLimit = 1f;
|
||||
[NonSerialized] public const float EyeMovementMaxIntervalLimit = 30f;
|
||||
|
||||
// Limits for the eye angles (uses the same as the default eye muscle values in unity)
|
||||
[NonSerialized] public const float DefaultEyeAngleLimitDown = -10;
|
||||
[NonSerialized] public const float DefaultEyeAngleLimitUp = 15;
|
||||
[NonSerialized] public const float DefaultEyeAngleLimitIn = -20;
|
||||
[NonSerialized] public const float DefaultEyeAngleLimitOut = 20;
|
||||
|
||||
// Limits for the eye angles when we need uniform limits (useful for the blend shape type)
|
||||
[NonSerialized] public const float DefaultUniformAngleLimit = 25;
|
||||
|
||||
[Serializable] public enum CVRAvatarEyeLookMode
|
||||
{
|
||||
Visemes = 0,
|
||||
SingleBlendshape = 1,
|
||||
JawBone = 2
|
||||
/// <summary>
|
||||
/// Eye movement muscle setup
|
||||
/// </summary>
|
||||
Muscle = 0,
|
||||
/// <summary>
|
||||
/// Disabled eye movement setup
|
||||
/// </summary>
|
||||
None = 1,
|
||||
/// <summary>
|
||||
/// Eye movement transforms setup
|
||||
/// </summary>
|
||||
Transform = 2,
|
||||
/// <summary>
|
||||
/// Eye movement blendshape setup
|
||||
/// </summary>
|
||||
Blendshape = 3,
|
||||
}
|
||||
|
||||
public CVRAvatarVisemeMode visemeMode = CVRAvatarVisemeMode.Visemes;
|
||||
|
||||
public int visemeSmoothing = 50;
|
||||
|
||||
public string[] visemeBlendshapes = new string[15];
|
||||
|
||||
[Space] [Header("Avatar customization")] [Space]
|
||||
public AnimatorOverrideController overrides;
|
||||
|
||||
public bool enableAdvancedTagging = false;
|
||||
public List<CVRAvatarAdvancedTaggingEntry> advancedTaggingList = new List<CVRAvatarAdvancedTaggingEntry>();
|
||||
|
||||
public bool avatarUsesAdvancedSettings = false;
|
||||
public CVRAdvancedAvatarSettings avatarSettings = null;
|
||||
|
||||
void OnDrawGizmosSelected()
|
||||
[Serializable] public struct EyeMovementInfo
|
||||
{
|
||||
var scale = transform.localScale;
|
||||
/// <summary>
|
||||
/// Type of eye movement. It will dictate which fields will be used.
|
||||
/// </summary>
|
||||
[SerializeField] [NotKeyable] public CVRAvatarEyeLookMode type;
|
||||
|
||||
/// <summary>
|
||||
/// Relevant to: Transforms and Blendshapes
|
||||
/// Eyes info for the eyes, not all fields will be used
|
||||
/// </summary>
|
||||
[SerializeReference] public EyeMovementInfoEye[] eyes;
|
||||
}
|
||||
|
||||
[Serializable] public class EyeMovementInfoEye
|
||||
{
|
||||
/// <summary>
|
||||
/// Relevant to: Transforms and Blendshapes
|
||||
/// Whether the eye is Left or not (this is only used to manage the in/out limit direction)
|
||||
/// </summary>
|
||||
[SerializeField] public bool isLeft;
|
||||
|
||||
/// <summary>
|
||||
/// Transforms - Transform of the eye bone
|
||||
/// Blendshapes - Transform where the eye should be
|
||||
/// </summary>
|
||||
[SerializeField] [NotKeyable] public Transform eyeTransform;
|
||||
|
||||
/// <summary>
|
||||
/// Blendshapes - Skinned mesh renderer for the renderer that has the blendshapes to be driven
|
||||
/// </summary>
|
||||
[SerializeField] [NotKeyable] public SkinnedMeshRenderer eyeSkinnedMeshRenderer;
|
||||
|
||||
/// <summary>
|
||||
/// Transforms - Angle limits for the transforms in degrees
|
||||
/// Blendshapes - Min/Max angle limits for which the blendshapes should be set to 100
|
||||
/// </summary>
|
||||
[SerializeField] public float eyeAngleLimitDown;
|
||||
[SerializeField] public float eyeAngleLimitUp;
|
||||
[SerializeField] public float eyeAngleLimitIn;
|
||||
[SerializeField] public float eyeAngleLimitOut;
|
||||
|
||||
/// <summary>
|
||||
/// Blendshapes - Blenshapes to be used for the blendshape eye movement
|
||||
/// </summary>
|
||||
[SerializeField] [NotKeyable] public string eyeBlendShapeUp;
|
||||
[SerializeField] [NotKeyable] public string eyeBlendShapeDown;
|
||||
[SerializeField] [NotKeyable] public string eyeBlendShapeIn;
|
||||
[SerializeField] [NotKeyable] public string eyeBlendShapeOut;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Eye Blink Settings
|
||||
|
||||
/// <summary>
|
||||
/// Whether to use blendshapes to blink or not
|
||||
/// </summary>
|
||||
[SerializeField] public bool useBlinkBlendshapes;
|
||||
|
||||
/// <summary>
|
||||
/// Which blendshapes to use when blinking (they're all used at the same time)
|
||||
/// </summary>
|
||||
[SerializeField] public string[] blinkBlendshape = new string[4];
|
||||
|
||||
/// <summary>
|
||||
/// Time interval between blinks in seconds.
|
||||
/// </summary>
|
||||
[SerializeField] public Vector2 blinkGap = new(3.0f, 8.0f);
|
||||
[NonSerialized] public const float BlinkMinGapLimit = 0.1f;
|
||||
[NonSerialized] public const float BlinkMaxGapLimit = 30f;
|
||||
|
||||
/// <summary>
|
||||
/// Duration of the blink in seconds.
|
||||
/// </summary>
|
||||
[SerializeField] public Vector2 blinkDuration = new(0.25f, 0.35f);
|
||||
[NonSerialized] public const float BlinkMinDurationLimit = 0.1f;
|
||||
[NonSerialized] public const float BlinkMaxDurationLimit = 3f;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Lip Sync Settings
|
||||
//[Space] [Header("Lip Sync Settings")] [Space]
|
||||
|
||||
public bool useVisemeLipsync;
|
||||
public CVRAvatarVisemeMode visemeMode = CVRAvatarVisemeMode.Visemes;
|
||||
[Range(1, 100)] public int visemeSmoothing = 50;
|
||||
public string[] visemeBlendshapes = new string[15];
|
||||
|
||||
#endregion
|
||||
|
||||
#region First Person Render Settings (Deprecated)
|
||||
#if UNITY_EDITOR // This is a deprecated feature, so lets not included in builds
|
||||
[NotKeyable] public bool enableCustomFPR;
|
||||
public List<CVRAvatarFPREntry> fprSettingsList;
|
||||
#endif
|
||||
#endregion
|
||||
|
||||
#region Advanced Tagging
|
||||
//[Space] [Header("Advanced Tagging")] [Space]
|
||||
|
||||
[NotKeyable]
|
||||
public bool enableAdvancedTagging;
|
||||
public List<CVRAvatarAdvancedTaggingEntry> advancedTaggingList = new List<CVRAvatarAdvancedTaggingEntry>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Advanced Settings
|
||||
//[Space] [Header("Advanced Settings")] [Space]
|
||||
|
||||
[NotKeyable]
|
||||
public bool avatarUsesAdvancedSettings;
|
||||
public CVRAdvancedAvatarSettings avatarSettings;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Unity Methods
|
||||
|
||||
private void OnDrawGizmosSelected()
|
||||
{
|
||||
Vector3 scale = transform.localScale;
|
||||
scale.x = 1 / scale.x;
|
||||
scale.y = 1 / scale.y;
|
||||
scale.z = 1 / scale.z;
|
||||
|
@ -64,17 +230,127 @@ namespace ABI.CCK.Components
|
|||
Gizmos.DrawSphere(transform.TransformPoint(Vector3.Scale(voicePosition, scale)), 0.01f);
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
#endregion
|
||||
|
||||
#region Parameter Sync Usage
|
||||
#if UNITY_EDITOR
|
||||
|
||||
public (int, int) GetParameterSyncUsage()
|
||||
{
|
||||
CVRAssetInfo info = gameObject.GetComponent<CVRAssetInfo>();
|
||||
info.type = CVRAssetInfo.AssetType.Avatar;
|
||||
if (avatarSettings?.settings == null)
|
||||
return (0, 0);
|
||||
|
||||
var animatorParameterNames = new HashSet<string>();
|
||||
int syncedValuesOverrides = 0, syncedBooleansOverrides = 0;
|
||||
int syncedValuesAASAutoGen = 0, syncedBooleansAASAutoGen = 0;
|
||||
|
||||
// Count override controller (real count)
|
||||
if (overrides != null && overrides.runtimeAnimatorController != null)
|
||||
{
|
||||
foreach (AnimatorControllerParameter parameter in CVRCommon.GetParametersFromController(
|
||||
overrides.runtimeAnimatorController, CVRCommon.NonCoreFilter, CVRCommon.NonLocalFilter))
|
||||
{
|
||||
if (!animatorParameterNames.Add(parameter.name))
|
||||
continue;
|
||||
|
||||
if (parameter.type == AnimatorControllerParameterType.Bool)
|
||||
syncedBooleansOverrides++;
|
||||
else if (parameter.type != AnimatorControllerParameterType.Trigger)
|
||||
syncedValuesOverrides++;
|
||||
}
|
||||
}
|
||||
|
||||
animatorParameterNames.Clear();
|
||||
|
||||
// Count baseController (part of autogen)
|
||||
if (avatarSettings.baseController != null)
|
||||
{
|
||||
foreach (AnimatorControllerParameter parameter in CVRCommon.GetParametersFromController(
|
||||
avatarSettings.baseController, CVRCommon.NonCoreFilter, CVRCommon.NonLocalFilter))
|
||||
{
|
||||
if (!animatorParameterNames.Add(parameter.name))
|
||||
continue;
|
||||
|
||||
if (parameter.type == AnimatorControllerParameterType.Bool)
|
||||
syncedBooleansAASAutoGen++;
|
||||
else if (parameter.type != AnimatorControllerParameterType.Trigger)
|
||||
syncedValuesAASAutoGen++;
|
||||
}
|
||||
}
|
||||
|
||||
// Count menu entries (part of autogen, not real)
|
||||
foreach (CVRAdvancedSettingsEntry entry in avatarSettings.settings)
|
||||
{
|
||||
if (IsValidParameter(entry.machineName) && animatorParameterNames.Add(entry.machineName))
|
||||
{
|
||||
switch (entry.type)
|
||||
{
|
||||
case CVRAdvancedSettingsEntry.SettingsType.Toggle:
|
||||
if (entry.setting.usedType == CVRAdvancesAvatarSettingBase.ParameterType.Bool)
|
||||
syncedBooleansAASAutoGen += 1;
|
||||
else
|
||||
syncedValuesAASAutoGen += 1;
|
||||
break;
|
||||
case CVRAdvancedSettingsEntry.SettingsType.Color:
|
||||
IncrementSyncValuesForEntry(entry, animatorParameterNames, ref syncedValuesAASAutoGen, "-r", "-g", "-b");
|
||||
break;
|
||||
case CVRAdvancedSettingsEntry.SettingsType.Joystick2D:
|
||||
case CVRAdvancedSettingsEntry.SettingsType.InputVector2:
|
||||
IncrementSyncValuesForEntry(entry, animatorParameterNames, ref syncedValuesAASAutoGen, "-x", "-y");
|
||||
break;
|
||||
case CVRAdvancedSettingsEntry.SettingsType.Joystick3D:
|
||||
case CVRAdvancedSettingsEntry.SettingsType.InputVector3:
|
||||
IncrementSyncValuesForEntry(entry, animatorParameterNames, ref syncedValuesAASAutoGen, "-x", "-y", "-z");
|
||||
break;
|
||||
case CVRAdvancedSettingsEntry.SettingsType.Slider:
|
||||
case CVRAdvancedSettingsEntry.SettingsType.InputSingle:
|
||||
case CVRAdvancedSettingsEntry.SettingsType.Dropdown:
|
||||
default:
|
||||
syncedValuesAASAutoGen += 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int realUsage = syncedValuesOverrides * 32 + Mathf.CeilToInt(syncedBooleansOverrides / 8f) * 8;
|
||||
int autogenUsage = syncedValuesAASAutoGen * 32 + Mathf.CeilToInt(syncedBooleansAASAutoGen / 8f) * 8;
|
||||
|
||||
return (realUsage, autogenUsage);
|
||||
}
|
||||
|
||||
}
|
||||
private static bool IsValidParameter(string parameterName)
|
||||
{
|
||||
return !string.IsNullOrEmpty(parameterName) && !CVRCommon.CoreParameters.Contains(parameterName) &&
|
||||
!parameterName.StartsWith(CVRCommon.LOCAL_PARAMETER_PREFIX);
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
private static void IncrementSyncValuesForEntry(CVRAdvancedSettingsEntry entry, HashSet<string> animatorParameters, ref int syncedValues, params string[] suffixes)
|
||||
{
|
||||
int newSyncedValues = suffixes.Count(suffix => animatorParameters.Add(entry.machineName + suffix));
|
||||
syncedValues += newSyncedValues;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region First Person Render Class
|
||||
|
||||
[Serializable]
|
||||
public class CVRAvatarFPREntry
|
||||
{
|
||||
public bool visibility = true;
|
||||
public Transform transform;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Advanced Tagging Class
|
||||
|
||||
[Serializable]
|
||||
public class CVRAvatarAdvancedTaggingEntry
|
||||
{
|
||||
[Flags]
|
||||
public enum Tags
|
||||
{
|
||||
LoudAudio = 1,
|
||||
|
@ -88,10 +364,10 @@ namespace ABI.CCK.Components
|
|||
Nudity = 256,
|
||||
Horror = 512
|
||||
}
|
||||
|
||||
public Tags tags = 0;
|
||||
|
||||
public GameObject gameObject;
|
||||
public GameObject fallbackGameObject;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
|
@ -1,11 +1,17 @@
|
|||
using UnityEngine;
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRAvatarPickupMarker : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Avatar Pickup Marker")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/")]
|
||||
public class CVRAvatarPickupMarker : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public string avatarGuid;
|
||||
|
||||
|
||||
#region Unity Events
|
||||
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
Gizmos.color = Color.magenta;
|
||||
|
@ -23,5 +29,23 @@ namespace ABI.CCK.Components
|
|||
Gizmos.matrix = rotationMatrix;
|
||||
Gizmos.DrawWireSphere(new Vector3(0, 1.11f, 0), 0.31f);
|
||||
}
|
||||
|
||||
#endregion Unity Events
|
||||
|
||||
#region Public Methods
|
||||
|
||||
[PublicAPI]
|
||||
public void ShowAvatarDetailsPage()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public void ChangeAvatar()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
54
Assets/ABI.CCK/Components/CVRBaseLuaBehaviour.cs
Executable file
54
Assets/ABI.CCK/Components/CVRBaseLuaBehaviour.cs
Executable file
|
@ -0,0 +1,54 @@
|
|||
using System;
|
||||
using ABI.CCK.Components.ScriptableObjects;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Animations;
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Common things that both CVRLuaClientBehaviour, and CVRLuaServerBehaviour use.
|
||||
///
|
||||
/// ********************************
|
||||
/// * Do not use if you're a user. *
|
||||
/// ********************************
|
||||
///
|
||||
/// Use CVRLuaClientBehaviour if you're making a client-side script.
|
||||
/// - or -
|
||||
/// Use CVRLuaServerBehaviour if you're making a server-side script.
|
||||
/// </summary>
|
||||
public abstract class CVRBaseLuaBehaviour : MonoBehaviour
|
||||
{
|
||||
public string ScriptName => asset == null ? string.Empty : asset.name;
|
||||
public string ScriptText => asset == null ? string.Empty : asset.m_ScriptText;
|
||||
public string ScriptPath => asset == null ? string.Empty : asset.m_ScriptPath;
|
||||
|
||||
/// <summary>
|
||||
/// Whether a script is only supposed to run locally or not.
|
||||
/// Avatars: The script only runs on the avatar's wearer client
|
||||
/// Props: The script only runs on prop spawner's client
|
||||
/// World: Ignores this setting for now
|
||||
/// </summary>
|
||||
[SerializeField] [NotKeyable]
|
||||
public bool localOnly = true;
|
||||
|
||||
/// <summary>
|
||||
/// The actual text-asset that we get the content of the script from.
|
||||
/// </summary>
|
||||
public CVRLuaScript asset;
|
||||
|
||||
/// <summary>
|
||||
/// A thing in the scene we want to link to this script.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public struct BoundObject
|
||||
{
|
||||
public string name;
|
||||
public UnityEngine.Object boundThing;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A list of things in the scene we want to link to this script.
|
||||
/// </summary>
|
||||
public BoundObject[] boundObjects;
|
||||
}
|
||||
}
|
11
Assets/ABI.CCK/Components/CVRBaseLuaBehaviour.cs.meta
Executable file
11
Assets/ABI.CCK/Components/CVRBaseLuaBehaviour.cs.meta
Executable file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: de2e0e3526ad8ea45a48ed7a7b5a7b5c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,9 +1,68 @@
|
|||
using UnityEngine;
|
||||
|
||||
[AddComponentMenu("ChilloutVR/CVR Blitter")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/blitter/")]
|
||||
public class CVRBlitter : MonoBehaviour
|
||||
{
|
||||
[SerializeField] RenderTexture originTexture = null;
|
||||
[SerializeField] RenderTexture destinationTexture = null;
|
||||
[SerializeField] Material blitMaterial = null;
|
||||
public RenderTexture originTexture;
|
||||
public RenderTexture destinationTexture;
|
||||
public Material blitMaterial;
|
||||
|
||||
public bool clearEveryFrame;
|
||||
}
|
||||
|
||||
private bool _isInitialized;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_isInitialized = true;
|
||||
OnEnable();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (!_isInitialized) return;
|
||||
Camera.onPreRender += MyOnPreRender;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
Camera.onPreRender -= MyOnPreRender;
|
||||
}
|
||||
|
||||
private void MyOnPreRender(Camera cam)
|
||||
{
|
||||
if (!enabled)
|
||||
return;
|
||||
|
||||
// Don't blit unless it's the main camera
|
||||
if (cam != Camera.main)
|
||||
return;
|
||||
|
||||
if (originTexture == null
|
||||
|| destinationTexture == null
|
||||
|| blitMaterial == null)
|
||||
{
|
||||
enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (clearEveryFrame)
|
||||
{
|
||||
RenderTexture rt = RenderTexture.active;
|
||||
RenderTexture.active = destinationTexture;
|
||||
GL.Clear(true, true, Color.clear);
|
||||
RenderTexture.active = rt;
|
||||
}
|
||||
|
||||
if (originTexture == destinationTexture)
|
||||
{
|
||||
RenderTexture temp = RenderTexture.GetTemporary(destinationTexture.descriptor);
|
||||
Graphics.Blit(originTexture, temp, blitMaterial);
|
||||
Graphics.CopyTexture(temp, destinationTexture);
|
||||
RenderTexture.ReleaseTemporary(temp);
|
||||
return;
|
||||
}
|
||||
|
||||
Graphics.Blit(originTexture, destinationTexture, blitMaterial);
|
||||
}
|
||||
}
|
|
@ -1,19 +1,15 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRBuilderSpawnable : MonoBehaviour
|
||||
[AddComponentMenu("")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/")]
|
||||
public class CVRBuilderSpawnable : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
private void Reset()
|
||||
{
|
||||
if (GetComponent<CVRSpawnable>() != null)
|
||||
{
|
||||
Invoke("DestroyThis", 0);
|
||||
}
|
||||
}
|
||||
void DestroyThis() {
|
||||
DestroyImmediate(this);
|
||||
DestroyImmediate(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,7 +3,9 @@ using UnityEngine;
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRCameraHelper : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Camera Helper")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/")]
|
||||
public class CVRCameraHelper : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public Camera cam;
|
||||
public bool setAsMirroringCamera;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.PlayerLoop;
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRCustomRenderTextureUpdater : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Custom Render Texture Updater")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/custom-render-texture-updater/")]
|
||||
public class CVRCustomRenderTextureUpdater : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public CustomRenderTexture customRenderTexture;
|
||||
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRDescription : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Description")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/")]
|
||||
public class CVRDescription : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public string description;
|
||||
public string url;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
using System.ComponentModel;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
[ExecuteInEditMode]
|
||||
[AddComponentMenu("Scripts/CVR Distance Constraint")]
|
||||
public class CVRDistanceConstrain : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Distance Constraint")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/")]
|
||||
public class CVRDistanceConstrain : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public Transform target;
|
||||
public float minDistance = 0;
|
||||
|
|
|
@ -4,7 +4,9 @@ using UnityEngine;
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRDistanceLod : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Distance Lod")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/distance-lod/")]
|
||||
public class CVRDistanceLod : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public bool distance3D = false;
|
||||
public List<CVRDistanceLodGroup> Groups = new List<CVRDistanceLodGroup>();
|
||||
|
|
|
@ -3,7 +3,9 @@ using UnityEngine;
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRFaceTracking : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Face Tracking")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/face-tracking/")]
|
||||
public class CVRFaceTracking : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public bool UseFacialTracking = true;
|
||||
public float BlendShapeStrength = 100f;
|
||||
|
@ -41,8 +43,11 @@ namespace ABI.CCK.Components
|
|||
}
|
||||
}
|
||||
|
||||
public void FindVisemes()
|
||||
public void AutoSelectFaceTrackingShapes()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.Undo.RecordObject(this, "CVR Auto Select Face Tracking");
|
||||
#endif
|
||||
for (int i = 0; i < FaceBlendShapeNames.Length; i++)
|
||||
{
|
||||
for (int j = 0; j < BlendShapeNames.Count; ++j)
|
||||
|
|
|
@ -2,10 +2,14 @@
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
[AddComponentMenu("ChilloutVR/CVR GI Material Updater")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/gi-material-updater/")]
|
||||
[RequireComponent(typeof(Renderer))]
|
||||
public class CVRGIMaterialUpdater : MonoBehaviour
|
||||
public class CVRGIMaterialUpdater : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[SerializeField] bool updateEveryFrame;
|
||||
#pragma warning restore 649
|
||||
private Renderer _renderer;
|
||||
|
||||
private void Start()
|
||||
|
@ -18,6 +22,5 @@ namespace ABI.CCK.Components
|
|||
if (_renderer == null || !updateEveryFrame) return;
|
||||
_renderer.UpdateGIMaterials();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,32 +1,79 @@
|
|||
using System;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
using UnityEngine;
|
||||
using UnityEngine.Animations;
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRGlobalMaterialPropertyUpdater : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Global Material Property Updater")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/global-material-property-updater/")]
|
||||
public class CVRGlobalMaterialPropertyUpdater : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public Material material;
|
||||
|
||||
public enum PropertyType
|
||||
{
|
||||
// For legacy reasons, this was used for Int type in shader. Needed for legacy content.
|
||||
// In reality it represents a float, and should be handled like a float.
|
||||
// Newer content will use paramFloat for Int shader types (because it's what it is)
|
||||
paramInt = 0,
|
||||
paramFloat = 1,
|
||||
paramVector4 = 2
|
||||
paramVector4 = 2,
|
||||
// The true Integer, this was added in unity 2021. The shader type is Integer
|
||||
paramInteger = 3,
|
||||
}
|
||||
|
||||
[SerializeField, NotKeyable]
|
||||
public Material material;
|
||||
|
||||
[SerializeField, NotKeyable]
|
||||
public string propertyName;
|
||||
|
||||
[SerializeField, NotKeyable]
|
||||
public PropertyType propertyType = PropertyType.paramFloat;
|
||||
|
||||
// Variables only used to populate the cvr interactable set property value
|
||||
[NonSerialized]
|
||||
public int intValue;
|
||||
|
||||
[NonSerialized]
|
||||
public float floatValue;
|
||||
|
||||
[NonSerialized]
|
||||
public Vector4 vector4Value;
|
||||
[NonSerialized]
|
||||
public int integerValue;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
|
||||
// Animatable parameters, value changes to these will trigger material updates
|
||||
[SerializeField, CVRInteractableActionOperation.HideFromSetPropertyByValue]
|
||||
public int intValueAnimatable;
|
||||
[SerializeField, CVRInteractableActionOperation.HideFromSetPropertyByValue]
|
||||
public float floatValueAnimatable;
|
||||
[SerializeField, CVRInteractableActionOperation.HideFromSetPropertyByValue]
|
||||
public Vector4 vector4ValueAnimatable;
|
||||
[SerializeField, CVRInteractableActionOperation.HideFromSetPropertyByValue]
|
||||
public int integerValueAnimatable;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void OnValidate() {
|
||||
|
||||
if (material == null || material.shader.FindPropertyIndex(propertyName) < 0 || AnimationMode.InAnimationMode()) return;
|
||||
|
||||
// Fetch the default value from the material
|
||||
switch (propertyType) {
|
||||
case PropertyType.paramInt:
|
||||
intValueAnimatable = material!.GetInt(propertyName);
|
||||
break;
|
||||
case PropertyType.paramFloat:
|
||||
floatValueAnimatable = material!.GetFloat(propertyName);
|
||||
break;
|
||||
case PropertyType.paramVector4:
|
||||
vector4ValueAnimatable = material!.GetVector(propertyName);
|
||||
break;
|
||||
case PropertyType.paramInteger:
|
||||
integerValueAnimatable = material!.GetInteger(propertyName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -3,7 +3,9 @@ using UnityEngine;
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRGlobalShaderUpdater : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Global Shader Updater")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/global-shader-updater/")]
|
||||
public class CVRGlobalShaderUpdater : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public bool updateValues = true;
|
||||
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRHapticAreaChest : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Haptic Area Chest")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/haptic-chest-area/")]
|
||||
public class CVRHapticAreaChest : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public Vector3 chestAreaSize = new Vector3(0.05f, 0.05f, 0.05f);
|
||||
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRHapticZone : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Haptic Zone")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/haptic-zone/")]
|
||||
public class CVRHapticZone : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public enum TriggerForm
|
||||
{
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
@ -7,8 +5,10 @@ using UnityEngine.Events;
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
[AddComponentMenu("ChilloutVR/CVR Interactable")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/interactable/")]
|
||||
[System.Serializable]
|
||||
public class CVRInteractable : MonoBehaviour
|
||||
public class CVRInteractable : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public string tooltip;
|
||||
public List<CVRInteractableAction> actions = new List<CVRInteractableAction>();
|
||||
|
@ -29,24 +29,86 @@ namespace ABI.CCK.Components
|
|||
{
|
||||
if (operation.type == CVRInteractableActionOperation.ActionType.TeleportPlayer)
|
||||
{
|
||||
Gizmos.color = Color.green;
|
||||
if(operation.gameObjectVal == null) continue;
|
||||
Gizmos.DrawLine(transform.position, operation.gameObjectVal.transform.position);
|
||||
DrawArrow(operation.gameObjectVal.transform.position, new Vector3(0, operation.gameObjectVal.transform.eulerAngles.y, 0), 1);
|
||||
|
||||
Transform target = operation.gameObjectVal.transform;
|
||||
Vector3 position = target.position;
|
||||
|
||||
// connection line
|
||||
Gizmos.color = Color.yellow;
|
||||
Gizmos.DrawLine(transform.position, position);
|
||||
|
||||
// alignment is set to none
|
||||
if (operation.floatVal == 3)
|
||||
{
|
||||
Gizmos.color = Color.blue;
|
||||
Gizmos.DrawWireSphere(position, 0.1f);
|
||||
continue;
|
||||
}
|
||||
|
||||
// relative teleport sets forward direction
|
||||
Vector3 targetDirection;
|
||||
if (operation.boolVal)
|
||||
{
|
||||
Gizmos.color = Color.cyan;
|
||||
targetDirection = transform.InverseTransformDirection(transform.forward);
|
||||
targetDirection = target.TransformDirection(targetDirection);
|
||||
}
|
||||
else
|
||||
{
|
||||
Gizmos.color = Color.blue;
|
||||
targetDirection = target.forward;
|
||||
}
|
||||
|
||||
if (operation.floatVal == 0) targetDirection = Vector3.ProjectOnPlane(targetDirection, Vector3.up).normalized;
|
||||
|
||||
DrawArrow(position, targetDirection, 1);
|
||||
|
||||
// up direction, when gravity, aligns to sampled gravity on teleport
|
||||
Gizmos.color = operation.floatVal == 2 ? Color.magenta : Color.green;
|
||||
|
||||
switch (operation.floatVal)
|
||||
{
|
||||
case 0: // World Up
|
||||
DrawArrow(position, Vector3.up, 1);
|
||||
break;
|
||||
case 1: // Target Up
|
||||
case 2: // Gravity
|
||||
DrawArrow(position, target.up, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (operation.type == CVRInteractableActionOperation.ActionType.SitAtPosition)
|
||||
{
|
||||
if(operation.targets.Count > 0 && operation.targets[0] == null)
|
||||
continue;
|
||||
|
||||
// Exit position
|
||||
Gizmos.color = Color.blue;
|
||||
|
||||
Transform exitTransform = operation.targets[0].transform;
|
||||
Vector3 exitPosition = exitTransform.position;
|
||||
|
||||
Gizmos.DrawLine(transform.position, exitPosition);
|
||||
DrawArrow(exitPosition,
|
||||
exitTransform.forward, 0.5f);
|
||||
|
||||
Gizmos.color = Color.yellow;
|
||||
DrawArrow(exitPosition,
|
||||
exitTransform.up, 0.5f);
|
||||
|
||||
if (operation.gameObjectVal == null)
|
||||
continue;
|
||||
|
||||
Gizmos.color = Color.blue;
|
||||
if(operation.targets.Count > 0 && operation.targets[0] == null) continue;
|
||||
Gizmos.DrawLine(transform.position, operation.targets[0].transform.position);
|
||||
DrawArrow(operation.targets[0].transform.position, new Vector3(0, operation.targets[0].transform.eulerAngles.y, 0), 0.5f);
|
||||
|
||||
if (operation.gameObjectVal == null) continue;
|
||||
var position = operation.gameObjectVal.transform;
|
||||
// Sitting position
|
||||
Transform position = operation.gameObjectVal.transform;
|
||||
Gizmos.DrawLine(transform.position, position.position);
|
||||
Matrix4x4 rotationMatrix = Matrix4x4.TRS(position.position, position.rotation, Vector3.one);
|
||||
Gizmos.matrix = rotationMatrix;
|
||||
|
||||
// Draws sitting cube person
|
||||
Gizmos.matrix = Matrix4x4.TRS(position.position, position.rotation, Vector3.one);
|
||||
Gizmos.DrawWireCube(new Vector3(+0.12f, -0.2f, 0.05f), new Vector3(0.1f, 0.4f, 0.1f));
|
||||
Gizmos.DrawWireCube(new Vector3(-0.12f, -0.2f, 0.05f), new Vector3(0.1f, 0.4f, 0.1f));
|
||||
Gizmos.DrawWireCube(new Vector3(+0.12f, 0.05f, -0.2f), new Vector3(0.1f, 0.1f, 0.6f));
|
||||
|
@ -62,24 +124,24 @@ namespace ABI.CCK.Components
|
|||
}
|
||||
}
|
||||
|
||||
private void DrawArrow(Vector3 position, Vector3 angle, float size)
|
||||
private void DrawArrow(Vector3 position, Vector3 direction, float size)
|
||||
{
|
||||
var a1 = position + new Vector3(0, 0.1f * size, 0);
|
||||
var a2 = RotatePointAroundPivot(position + new Vector3(0.1f * size, 0, 0), position, angle);
|
||||
var a3 = position + new Vector3(0, -0.1f * size, 0);
|
||||
var a4 = RotatePointAroundPivot(position + new Vector3(-0.1f * size, 0, 0), position, angle);
|
||||
var a1 = RotatePointAroundPivot(position + new Vector3(0, 0.1f * size, 0), position, direction);
|
||||
var a2 = RotatePointAroundPivot(position + new Vector3(0.1f * size, 0, 0), position, direction);
|
||||
var a3 = RotatePointAroundPivot(position + new Vector3(0, -0.1f * size, 0), position, direction);
|
||||
var a4 = RotatePointAroundPivot(position + new Vector3(-0.1f * size, 0, 0), position, direction);
|
||||
|
||||
var b1 = RotatePointAroundPivot(position + new Vector3(0, 0.1f * size, 0.3f * size), position, angle);
|
||||
var b2 = RotatePointAroundPivot(position + new Vector3(0.1f * size, 0, 0.3f * size), position, angle);
|
||||
var b3 = RotatePointAroundPivot(position + new Vector3(0, -0.1f * size, 0.3f * size), position, angle);
|
||||
var b4 = RotatePointAroundPivot(position + new Vector3(-0.1f * size, 0, 0.3f * size), position, angle);
|
||||
var b1 = RotatePointAroundPivot(position + new Vector3(0, 0.1f * size, 0.3f * size), position, direction);
|
||||
var b2 = RotatePointAroundPivot(position + new Vector3(0.1f * size, 0, 0.3f * size), position, direction);
|
||||
var b3 = RotatePointAroundPivot(position + new Vector3(0, -0.1f * size, 0.3f * size), position, direction);
|
||||
var b4 = RotatePointAroundPivot(position + new Vector3(-0.1f * size, 0, 0.3f * size), position, direction);
|
||||
|
||||
var c1 = RotatePointAroundPivot(position + new Vector3(0, 0.2f * size, 0.3f * size), position, angle);
|
||||
var c2 = RotatePointAroundPivot(position + new Vector3(0.2f * size, 0, 0.3f * size), position, angle);
|
||||
var c3 = RotatePointAroundPivot(position + new Vector3(0, -0.2f * size, 0.3f * size), position, angle);
|
||||
var c4 = RotatePointAroundPivot(position + new Vector3(-0.2f * size, 0, 0.3f * size), position, angle);
|
||||
var c1 = RotatePointAroundPivot(position + new Vector3(0, 0.2f * size, 0.3f * size), position, direction);
|
||||
var c2 = RotatePointAroundPivot(position + new Vector3(0.2f * size, 0, 0.3f * size), position, direction);
|
||||
var c3 = RotatePointAroundPivot(position + new Vector3(0, -0.2f * size, 0.3f * size), position, direction);
|
||||
var c4 = RotatePointAroundPivot(position + new Vector3(-0.2f * size, 0, 0.3f * size), position, direction);
|
||||
|
||||
var d = RotatePointAroundPivot(position + new Vector3(0, 0, 0.5f * size), position, angle);
|
||||
var d = RotatePointAroundPivot(position + new Vector3(0, 0, 0.5f * size), position, direction);
|
||||
|
||||
Gizmos.DrawLine(position, a1);
|
||||
Gizmos.DrawLine(position, a2);
|
||||
|
@ -102,10 +164,11 @@ namespace ABI.CCK.Components
|
|||
Gizmos.DrawLine(c4, d);
|
||||
}
|
||||
|
||||
private Vector3 RotatePointAroundPivot(Vector3 point, Vector3 pivot, Vector3 angles)
|
||||
private Vector3 RotatePointAroundPivot(Vector3 point, Vector3 pivot, Vector3 direction)
|
||||
{
|
||||
var dir = point - pivot; // get point direction relative to pivot
|
||||
dir = Quaternion.Euler(angles) * dir; // rotate it
|
||||
Quaternion rotation = Quaternion.LookRotation(direction, Vector3.up);
|
||||
dir = rotation * dir; // rotate it
|
||||
point = dir + pivot; // calculate rotated point
|
||||
return point; // return it
|
||||
}
|
||||
|
|
|
@ -7,46 +7,66 @@ namespace ABI.CCK.Components
|
|||
[System.Serializable]
|
||||
public class CVRInteractableAction
|
||||
{
|
||||
#region Filtering Attribute Classes
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
||||
public class AllowSpawnable : Attribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
||||
public class AllowWorld : Attribute { }
|
||||
|
||||
#endregion
|
||||
|
||||
public enum ActionRegister
|
||||
{
|
||||
OnGrab = 1,
|
||||
OnDrop = 2,
|
||||
OnInteractDown = 3,
|
||||
OnInteractUp = 4,
|
||||
OnEnterTrigger = 5,
|
||||
OnExitTrigger = 6,
|
||||
OnEnterCollider = 7,
|
||||
OnExitCollider = 8,
|
||||
OnEnable = 9,
|
||||
OnDisable = 10,
|
||||
OnTimer = 11,
|
||||
OnParticleHit = 12,
|
||||
OnVariableBufferUpdate = 13,
|
||||
OnVariableBufferComparision = 14,
|
||||
OnCron = 15,
|
||||
OnPointerEnter = 16,
|
||||
OnWorldTrigger = 17,
|
||||
OnCustomTrigger = 18,
|
||||
OnInputDown = 19,
|
||||
OnInputUp = 20,
|
||||
OnAPFTrigger = 21,
|
||||
OnAPFBoolChange = 22,
|
||||
OnAPFIntChange = 23,
|
||||
OnAPFFloatChange = 24,
|
||||
OnAPFStringChange = 27,
|
||||
OnGazeEnter = 25,
|
||||
OnGazeExit = 26
|
||||
[AllowWorld, AllowSpawnable] OnGrab = 1,
|
||||
[AllowWorld, AllowSpawnable] OnDrop = 2,
|
||||
[AllowWorld, AllowSpawnable] OnInteractDown = 3,
|
||||
[AllowWorld, AllowSpawnable] OnInteractUp = 4,
|
||||
[AllowWorld] OnEnterTrigger = 5,
|
||||
[AllowWorld] OnExitTrigger = 6,
|
||||
[AllowWorld] OnEnterCollider = 7,
|
||||
[AllowWorld] OnExitCollider = 8,
|
||||
[AllowWorld] OnPlayerTriggerEnter = 29,
|
||||
[AllowWorld] OnPlayerTriggerExit = 30,
|
||||
[AllowWorld] OnPlayerColliderEnter = 31,
|
||||
[AllowWorld] OnPlayerColliderExit = 32,
|
||||
[AllowWorld] OnEnable = 9,
|
||||
[AllowWorld] OnDisable = 10,
|
||||
[AllowWorld] OnTimer = 11,
|
||||
[AllowWorld] OnParticleHit = 12,
|
||||
[AllowWorld] OnVariableBufferUpdate = 13,
|
||||
[AllowWorld] OnVariableBufferComparision = 14,
|
||||
[AllowWorld] OnCron = 15,
|
||||
[AllowWorld] OnPointerEnter = 16,
|
||||
[AllowWorld] OnPointerExit = 28,
|
||||
[AllowWorld, AllowSpawnable] OnWorldTrigger = 17,
|
||||
[AllowWorld, AllowSpawnable] OnCustomTrigger = 18,
|
||||
[AllowWorld, AllowSpawnable] OnInputDown = 19,
|
||||
[AllowWorld, AllowSpawnable] OnInputUp = 20,
|
||||
[AllowWorld] OnAPFTrigger = 21,
|
||||
[AllowWorld] OnAPFBoolChange = 22,
|
||||
[AllowWorld] OnAPFIntChange = 23,
|
||||
[AllowWorld] OnAPFFloatChange = 24,
|
||||
[AllowWorld] OnAPFStringChange = 27,
|
||||
[AllowWorld] OnHoverEnter = 25, // used to be OnGazeEnter
|
||||
[AllowWorld] OnHoverExit = 26, // used to be OnGazeExit
|
||||
[AllowWorld] OnBecameVisible = 33,
|
||||
[AllowWorld] OnBecameInvisible = 34,
|
||||
// must be called via StateMachineCallbackSender StateMachineBehaviour
|
||||
[AllowWorld, AllowSpawnable] OnStateMachineEnter = 35,
|
||||
[AllowWorld, AllowSpawnable] OnStateMachineExit = 36
|
||||
}
|
||||
|
||||
public enum ExecutionType
|
||||
{
|
||||
LocalNotNetworked = 1,
|
||||
GlobalNetworked = 2,
|
||||
GlobalNetworkedBuffered = 4,
|
||||
GlobalInstanceOwnerOnly = 3,
|
||||
GlobalInstanceOwnerOnlyBuffered = 5,
|
||||
GlobalNetworkedAllInstanceModerators = 6,
|
||||
GlobalNetworkedAllInstanceModeratorsBuffered = 7
|
||||
[AllowWorld, AllowSpawnable] LocalNotNetworked = 1,
|
||||
[AllowWorld] GlobalNetworked = 2,
|
||||
[AllowWorld] GlobalNetworkedBuffered = 4,
|
||||
[AllowWorld] GlobalInstanceOwnerOnly = 3,
|
||||
[AllowWorld] GlobalInstanceOwnerOnlyBuffered = 5,
|
||||
[AllowWorld] GlobalNetworkedAllInstanceModerators = 6,
|
||||
[AllowWorld] GlobalNetworkedAllInstanceModeratorsBuffered = 7
|
||||
}
|
||||
|
||||
public float delay = 0f;
|
||||
|
@ -54,7 +74,7 @@ namespace ABI.CCK.Components
|
|||
public List<CVRInteractableActionOperation> operations = new List<CVRInteractableActionOperation>();
|
||||
|
||||
public ActionRegister actionType = ActionRegister.OnInteractDown;
|
||||
public ExecutionType execType = ExecutionType.GlobalNetworked;
|
||||
public ExecutionType execType = ExecutionType.LocalNotNetworked;
|
||||
|
||||
public LayerMask layerMask = 0;
|
||||
|
||||
|
@ -62,6 +82,7 @@ namespace ABI.CCK.Components
|
|||
public float floatVal2 = 0;
|
||||
public float floatVal3 = 0;
|
||||
public bool boolVal;
|
||||
public bool boolVal2;
|
||||
public CVRVariableBuffer varBufferVal;
|
||||
public CVRVariableBuffer varBufferVal2;
|
||||
public string stringVal = "";
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
|
@ -8,45 +8,59 @@ namespace ABI.CCK.Components
|
|||
[System.Serializable]
|
||||
public class CVRInteractableActionOperation
|
||||
{
|
||||
#region Filtering Attribute Classes
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
||||
public class AllowSpawnable : Attribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
||||
public class AllowWorld : Attribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
||||
public class HideFromSetPropertyByValue : Attribute { }
|
||||
|
||||
#endregion
|
||||
|
||||
public enum ActionType
|
||||
{
|
||||
SetGameObjectActive = 1,
|
||||
//SetComponentActive = 2,
|
||||
SetAnimatorFloatValue = 3,
|
||||
SetAnimatorBoolValue = 4,
|
||||
SetAnimatorIntValue = 17,
|
||||
TriggerAnimatorTrigger = 18,
|
||||
SpawnObject = 5,
|
||||
TeleportPlayer = 6,
|
||||
TeleportObject = 7,
|
||||
ToggleAnimatorBoolValue = 8,
|
||||
SetAnimatorFloatRandom = 9,
|
||||
SetAnimatorBoolRandom = 10,
|
||||
SetAnimatorIntRandom = 19,
|
||||
SetAnimatorFloatByVar = 11,
|
||||
SetAnimatorIntByVar = 20,
|
||||
VariableBufferArithmetic = 12,
|
||||
DisplayWorldDetailPage = 13,
|
||||
DisplayInstanceDetailPage = 14,
|
||||
DisplayAvatarDetailPage = 15,
|
||||
DisplaySpawnableDetailPage = 37,
|
||||
SitAtPosition = 16,
|
||||
MethodCall = 21,
|
||||
SetSpawnableValue = 22,
|
||||
PlayAudio = 23,
|
||||
StopAudio = 24,
|
||||
SetAnimatorBoolByAPF= 25,
|
||||
SetAnimatorIntByAPF = 26,
|
||||
SetAnimatorFloatByAPF = 27,
|
||||
SetVariableBufferByAPF= 28,
|
||||
UpdateAPFTrigger = 29,
|
||||
UpdateAPFBool = 30,
|
||||
UpdateAPFInt = 31,
|
||||
UpdateAPFFloat = 32,
|
||||
UpdateAPFString = 33,
|
||||
SetPropertyByApf = 34,
|
||||
SetPropertyByValue = 35,
|
||||
DeleteGameObject = 36,
|
||||
[AllowWorld, AllowSpawnable] SetGameObjectActive = 1,
|
||||
[AllowWorld, AllowSpawnable] SetComponentActive = 2,
|
||||
[AllowWorld, AllowSpawnable] SetAnimatorFloatValue = 3,
|
||||
[AllowWorld, AllowSpawnable] SetAnimatorBoolValue = 4,
|
||||
[AllowWorld, AllowSpawnable] SetAnimatorIntValue = 17,
|
||||
[AllowWorld, AllowSpawnable] TriggerAnimatorTrigger = 18,
|
||||
[AllowWorld] SpawnObject = 5,
|
||||
[AllowWorld, AllowSpawnable] TeleportPlayer = 6,
|
||||
[AllowWorld, AllowSpawnable] TeleportObject = 7,
|
||||
[AllowWorld, AllowSpawnable] ToggleAnimatorBoolValue = 8,
|
||||
[AllowWorld, AllowSpawnable] SetAnimatorFloatRandom = 9,
|
||||
[AllowWorld, AllowSpawnable] SetAnimatorBoolRandom = 10,
|
||||
[AllowWorld, AllowSpawnable] SetAnimatorIntRandom = 19,
|
||||
[AllowWorld, AllowSpawnable] SetAnimatorFloatByVar = 11,
|
||||
[AllowWorld, AllowSpawnable] SetAnimatorIntByVar = 20,
|
||||
[AllowWorld, AllowSpawnable] VariableBufferArithmetic = 12,
|
||||
[AllowWorld, AllowSpawnable] DisplayWorldDetailPage = 13,
|
||||
[AllowWorld, AllowSpawnable] DisplayInstanceDetailPage = 14,
|
||||
[AllowWorld, AllowSpawnable] DisplayAvatarDetailPage = 15,
|
||||
[AllowWorld, AllowSpawnable] DisplaySpawnableDetailPage = 37,
|
||||
[AllowWorld, AllowSpawnable] SitAtPosition = 16,
|
||||
[AllowWorld, AllowSpawnable] MethodCall = 21,
|
||||
[AllowWorld, AllowSpawnable] SetSpawnableValue = 22,
|
||||
[AllowWorld, AllowSpawnable] PlayAudio = 23,
|
||||
[AllowWorld, AllowSpawnable] StopAudio = 24,
|
||||
[AllowWorld, AllowSpawnable] SetAnimatorBoolByAPF = 25,
|
||||
[AllowWorld, AllowSpawnable] SetAnimatorIntByAPF = 26,
|
||||
[AllowWorld, AllowSpawnable] SetAnimatorFloatByAPF = 27,
|
||||
[AllowWorld, AllowSpawnable] SetVariableBufferByAPF= 28,
|
||||
[AllowWorld, AllowSpawnable] UpdateAPFTrigger = 29,
|
||||
[AllowWorld, AllowSpawnable] UpdateAPFBool = 30,
|
||||
[AllowWorld, AllowSpawnable] UpdateAPFInt = 31,
|
||||
[AllowWorld, AllowSpawnable] UpdateAPFFloat = 32,
|
||||
[AllowWorld, AllowSpawnable] UpdateAPFString = 33,
|
||||
[AllowWorld, AllowSpawnable] SetPropertyByApf = 34,
|
||||
[AllowWorld, AllowSpawnable] SetPropertyByValue = 35,
|
||||
[AllowWorld, AllowSpawnable] DeleteGameObject = 36,
|
||||
[AllowWorld, AllowSpawnable] LuaFunctionCall = 38,
|
||||
}
|
||||
|
||||
public ActionType type = ActionType.SetGameObjectActive;
|
||||
|
|
11
Assets/ABI.CCK/Components/CVRLuaClientBehaviour.cs
Executable file
11
Assets/ABI.CCK/Components/CVRLuaClientBehaviour.cs
Executable file
|
@ -0,0 +1,11 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a Lua script that runs entirely on your side of the connection (client-side).
|
||||
/// </summary>
|
||||
public class CVRLuaClientBehaviour : CVRBaseLuaBehaviour
|
||||
{
|
||||
}
|
||||
}
|
11
Assets/ABI.CCK/Components/CVRLuaClientBehaviour.cs.meta
Executable file
11
Assets/ABI.CCK/Components/CVRLuaClientBehaviour.cs.meta
Executable file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 70e2beb286f4c1b4690755891d0604a5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 8d4eaf52fbae23548874e96ac0d52276, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -3,7 +3,9 @@ using UnityEngine;
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRMaterialDriver : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Material Driver")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/material-driver/")]
|
||||
public class CVRMaterialDriver : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public float material01X;
|
||||
public float material01Y;
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRMaterialUpdater : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Material Updater")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/material-updater/")]
|
||||
public class CVRMaterialUpdater : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public enum UpdateType
|
||||
{
|
||||
|
@ -13,39 +14,42 @@ namespace ABI.CCK.Components
|
|||
|
||||
public UpdateType updateType = UpdateType.Update;
|
||||
|
||||
private Renderer renderer;
|
||||
private Renderer render;
|
||||
private Vector3 lastPos;
|
||||
private Vector3 velocity;
|
||||
private Vector3 lastRot;
|
||||
private Vector3 angularVelocity;
|
||||
private static readonly int _cvrVelocity = Shader.PropertyToID("_CVR_Velocity");
|
||||
private static readonly int _cvrAngularVelocity = Shader.PropertyToID("_CVR_Angular_Velocity");
|
||||
|
||||
private void Start()
|
||||
{
|
||||
renderer = GetComponent<Renderer>();
|
||||
render = GetComponent<Renderer>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (updateType == UpdateType.FixedUpdate || renderer == null) return;
|
||||
if (updateType == UpdateType.FixedUpdate || render == null) return;
|
||||
ProcessUpdate();
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (updateType == UpdateType.Update || renderer == null) return;
|
||||
if (updateType == UpdateType.Update || render == null) return;
|
||||
ProcessUpdate();
|
||||
}
|
||||
|
||||
private void ProcessUpdate()
|
||||
{
|
||||
velocity = (lastPos - transform.position) / (updateType == UpdateType.Update?Time.deltaTime:Time.fixedDeltaTime);
|
||||
angularVelocity = transform.rotation.eulerAngles - lastRot;
|
||||
Quaternion rotation = transform.rotation;
|
||||
angularVelocity = rotation.eulerAngles - lastRot;
|
||||
|
||||
renderer.material.SetVector("_CVR_Velocity", velocity);
|
||||
renderer.material.SetVector("_CVR_Angular_Velocity", angularVelocity);
|
||||
render.material.SetVector(_cvrVelocity, velocity);
|
||||
render.material.SetVector(_cvrAngularVelocity, angularVelocity);
|
||||
|
||||
lastPos = transform.position;
|
||||
lastRot = transform.rotation.eulerAngles;
|
||||
lastRot = rotation.eulerAngles;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,25 +1,384 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using ABI.CCK.Components;
|
||||
using UnityEngine;
|
||||
|
||||
#pragma warning disable
|
||||
// https://web.archive.org/web/20210507003436/http://wiki.unity3d.com/index.php/MirrorReflection4
|
||||
|
||||
public class CVRMirror : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Mirror")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/mirror/")]
|
||||
[ExecuteInEditMode]
|
||||
public class CVRMirror : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public enum MirrorClearFlags {Skybox = 1, Color = 2}
|
||||
|
||||
// General
|
||||
public bool m_DisablePixelLights = true;
|
||||
public int m_TextureSize = 256;
|
||||
public float m_ClipPlaneOffset = 0.07f;
|
||||
public int m_framesNeededToUpdate = 0;
|
||||
|
||||
public int m_TextureSize = 4096;
|
||||
public LayerMask m_ReflectLayers = -1;
|
||||
|
||||
private Dictionary<Camera, Camera> m_ReflectionCameras = new Dictionary<Camera, Camera>();
|
||||
|
||||
private RenderTexture m_ReflectionTextureLeft = null;
|
||||
private RenderTexture m_ReflectionTextureRight = null;
|
||||
private int m_OldReflectionTextureSize = 0;
|
||||
|
||||
private int m_frameCounter = 0;
|
||||
|
||||
private static bool s_InsideRendering = false;
|
||||
}
|
||||
|
||||
// Optimization
|
||||
public bool m_UseOcclusionCulling;
|
||||
|
||||
// Advanced
|
||||
public MirrorClearFlags m_ClearFlags = MirrorClearFlags.Skybox;
|
||||
public Material m_CustomSkybox;
|
||||
public Color m_CustomColor = new Color(19, 30, 47);
|
||||
|
||||
// Advanced / Why ??
|
||||
public float m_ClipPlaneOffset = 0.001f;
|
||||
public int m_framesNeededToUpdate;
|
||||
|
||||
// Legacy behaviour forces player layers on + UI off
|
||||
public bool m_ignoreLegacyBehaviour;
|
||||
|
||||
private Camera m_ReflectionCamera;
|
||||
private RenderTexture m_ReflectionTextureLeft;
|
||||
private RenderTexture m_ReflectionTextureRight;
|
||||
private MaterialPropertyBlock m_PropertyBlock;
|
||||
|
||||
private Renderer m_MirrorRenderer;
|
||||
|
||||
private int m_frameCounter;
|
||||
private static bool s_InsideRendering;
|
||||
|
||||
// mirror mesh normal in local coordinates
|
||||
private Vector3 mirrorNormal = Vector3.zero;
|
||||
|
||||
// configurable by player in-game
|
||||
private int usedTextureSize = 4096;
|
||||
private int usedMsaa = 0;
|
||||
|
||||
private static Shader mirrorShader;
|
||||
private static readonly int _propertyLeft = Shader.PropertyToID("_ReflectionTexLeft");
|
||||
private static readonly int _propertyRight = Shader.PropertyToID("_ReflectionTexRight");
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void Reset()
|
||||
{
|
||||
// Ensure new content is not "legacy".
|
||||
m_ignoreLegacyBehaviour = true;
|
||||
}
|
||||
|
||||
public void OnValidate()
|
||||
{
|
||||
// prevent against infinite reimport when viewing prefabs
|
||||
if (!gameObject.scene.IsValid())
|
||||
return;
|
||||
|
||||
CleanupMirrorObjects();
|
||||
|
||||
m_MirrorRenderer = GetComponent<Renderer>();
|
||||
if (!m_MirrorRenderer)
|
||||
{
|
||||
enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (mirrorShader == null)
|
||||
mirrorShader = Shader.Find("FX/MirrorReflection");
|
||||
|
||||
m_PropertyBlock ??= new MaterialPropertyBlock();
|
||||
|
||||
var materials = m_MirrorRenderer.sharedMaterials;
|
||||
foreach (Material mat in materials)
|
||||
{
|
||||
if (mat == null) continue;
|
||||
if (mat.shader.name is "FX/MirrorReflection" or "Alpha Blend Interactive/MirrorReflection")
|
||||
mat.shader = mirrorShader;
|
||||
}
|
||||
m_MirrorRenderer.sharedMaterials = materials;
|
||||
}
|
||||
#endif
|
||||
|
||||
private void Start()
|
||||
{
|
||||
LegacyBehaviourIfNeeded();
|
||||
|
||||
// Prevent mirrors from reflecting others
|
||||
// This is a reserved layer, no prior content should be using it
|
||||
gameObject.layer = 14;
|
||||
m_ReflectLayers &= ~(1 << 14);
|
||||
|
||||
mirrorShader = Shader.Find("FX/MirrorReflection");
|
||||
m_PropertyBlock ??= new MaterialPropertyBlock();
|
||||
|
||||
m_MirrorRenderer = GetComponent<Renderer>();
|
||||
if (!m_MirrorRenderer)
|
||||
{
|
||||
enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
var materials = m_MirrorRenderer.sharedMaterials;
|
||||
foreach (Material mat in materials)
|
||||
{
|
||||
if (mat == null) continue;
|
||||
if (mat.shader.name is "FX/MirrorReflection" or "Alpha Blend Interactive/MirrorReflection")
|
||||
mat.shader = mirrorShader;
|
||||
}
|
||||
m_MirrorRenderer.sharedMaterials = materials;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
CleanupMirrorObjects();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (m_ReflectionCamera == null)
|
||||
return;
|
||||
|
||||
if (Application.isEditor)
|
||||
DestroyImmediate(m_ReflectionCamera.gameObject);
|
||||
else
|
||||
Destroy(m_ReflectionCamera.gameObject);
|
||||
}
|
||||
|
||||
private void LegacyBehaviourIfNeeded()
|
||||
{
|
||||
if (m_ignoreLegacyBehaviour)
|
||||
return;
|
||||
|
||||
// Older worlds should still force player-layers on for compatability.
|
||||
// CCK Mirror prefab didn't reflect local player, so user content only worked cause of this!
|
||||
|
||||
m_UseOcclusionCulling = false;
|
||||
|
||||
m_ClipPlaneOffset = 0.001f; // exposed in CCK
|
||||
m_ReflectLayers &= ~(1 << 5);
|
||||
m_ReflectLayers &= ~(1 << 15);
|
||||
m_ReflectLayers |= 1 << 8;
|
||||
m_ReflectLayers |= 1 << 9;
|
||||
m_ReflectLayers |= 1 << 10;
|
||||
}
|
||||
|
||||
// This is called when it's known that the object will be rendered by some
|
||||
// camera. We render reflections and do other updates here.
|
||||
// Because the script executes in edit mode, reflections for the scene view
|
||||
// camera will just work!
|
||||
public void OnWillRenderObject()
|
||||
{
|
||||
if (!enabled || !m_MirrorRenderer || !m_MirrorRenderer.sharedMaterial || !m_MirrorRenderer.enabled)
|
||||
return;
|
||||
|
||||
// Previously was RootLogic.Instance.activeCamera;
|
||||
// Camera.current produces correct reflection with *any* camera, be it photo camera, in-world camera, camera on an avatar, or anything else
|
||||
// TODO: consider a marker or settings component (i.e. CVRCameraSettings) that would allow excluding mirrors from camera render (useful on both avatars and worlds)
|
||||
Camera cam = Camera.current;
|
||||
if (!cam)
|
||||
return;
|
||||
|
||||
// Safeguard from recursive reflections.
|
||||
if (s_InsideRendering) return;
|
||||
s_InsideRendering = true;
|
||||
|
||||
if (m_frameCounter > 0)
|
||||
{
|
||||
m_frameCounter--;
|
||||
return;
|
||||
}
|
||||
m_frameCounter = m_framesNeededToUpdate;
|
||||
|
||||
mirrorNormal = Vector3.up;
|
||||
MeshFilter meshFilter = GetComponent<MeshFilter>();
|
||||
Mesh mesh = meshFilter != null ? meshFilter.sharedMesh : null;
|
||||
if (mesh != null && mesh.normals.Length > 0)
|
||||
mirrorNormal = mesh.normals[0];
|
||||
|
||||
// Optionally disable pixel lights for reflection
|
||||
int oldPixelLightCount = QualitySettings.pixelLightCount;
|
||||
if (m_DisablePixelLights)
|
||||
QualitySettings.pixelLightCount = 0;
|
||||
|
||||
try
|
||||
{
|
||||
RenderCamera(cam, m_MirrorRenderer, Camera.StereoscopicEye.Left, ref m_ReflectionTextureLeft);
|
||||
m_PropertyBlock.SetTexture(_propertyLeft, m_ReflectionTextureLeft);
|
||||
|
||||
if (!cam.stereoEnabled) return;
|
||||
RenderCamera(cam, m_MirrorRenderer, Camera.StereoscopicEye.Right, ref m_ReflectionTextureRight);
|
||||
m_PropertyBlock.SetTexture(_propertyRight, m_ReflectionTextureRight);
|
||||
}
|
||||
finally
|
||||
{
|
||||
s_InsideRendering = false;
|
||||
m_MirrorRenderer.SetPropertyBlock(m_PropertyBlock);
|
||||
if (m_DisablePixelLights) // Restore pixel light count
|
||||
QualitySettings.pixelLightCount = oldPixelLightCount;
|
||||
}
|
||||
}
|
||||
|
||||
private void RenderCamera(Camera cam, Renderer rend, Camera.StereoscopicEye eye,
|
||||
ref RenderTexture reflectionTexture)
|
||||
{
|
||||
// find out the reflection plane: position and normal in world space
|
||||
Vector3 pos = transform.position;
|
||||
Vector3 normal = transform.TransformDirection(mirrorNormal);
|
||||
|
||||
CreateMirrorObjects(cam, eye, ref reflectionTexture);
|
||||
|
||||
CopyCameraProperties(cam, m_ReflectionCamera);
|
||||
|
||||
m_ReflectionCamera.useOcclusionCulling = m_UseOcclusionCulling;
|
||||
m_ReflectionCamera.depthTextureMode = cam.depthTextureMode | DepthTextureMode.Depth;
|
||||
m_ReflectionCamera.stereoTargetEye = StereoTargetEyeMask.None;
|
||||
m_ReflectionCamera.cullingMask = m_ReflectLayers.value;
|
||||
|
||||
// Render reflection
|
||||
// Reflect camera around reflection plane
|
||||
float d = -Vector3.Dot(normal, pos) - m_ClipPlaneOffset;
|
||||
Vector4 reflectionPlane = new Vector4(normal.x, normal.y, normal.z, d);
|
||||
|
||||
Matrix4x4 reflection = Matrix4x4.zero;
|
||||
CalculateReflectionMatrix(ref reflection, reflectionPlane);
|
||||
|
||||
Matrix4x4 worldToCameraMatrix;
|
||||
if (cam.stereoEnabled)
|
||||
worldToCameraMatrix = cam.GetStereoViewMatrix(eye) * reflection;
|
||||
else
|
||||
worldToCameraMatrix = cam.worldToCameraMatrix * reflection;
|
||||
|
||||
m_ReflectionCamera.targetTexture = reflectionTexture;
|
||||
|
||||
Matrix4x4 cameraSideReflection = Matrix4x4.zero;
|
||||
CalculateReflectionMatrix(ref cameraSideReflection, new Vector4(1, 0, 0, 0));
|
||||
worldToCameraMatrix = cameraSideReflection * worldToCameraMatrix;
|
||||
|
||||
m_ReflectionCamera.worldToCameraMatrix = worldToCameraMatrix;
|
||||
|
||||
// Setup oblique projection matrix so that near plane is our reflection
|
||||
// plane. This way we clip everything below/above it for free.
|
||||
Vector4 clipPlane = CameraSpacePlane(worldToCameraMatrix, pos, normal, 1.0f);
|
||||
|
||||
m_ReflectionCamera.projectionMatrix = cameraSideReflection *
|
||||
(cam.stereoEnabled
|
||||
? cam.GetStereoProjectionMatrix(eye)
|
||||
: cam.projectionMatrix) * cameraSideReflection.inverse;
|
||||
|
||||
m_ReflectionCamera.projectionMatrix = m_ReflectionCamera.CalculateObliqueMatrix(clipPlane);
|
||||
|
||||
m_ReflectionCamera.Render();
|
||||
}
|
||||
|
||||
// Cleanup all the objects we possibly have created
|
||||
private void CleanupMirrorObjects()
|
||||
{
|
||||
if (m_ReflectionTextureLeft)
|
||||
{
|
||||
RenderTexture.ReleaseTemporary(m_ReflectionTextureLeft);
|
||||
m_ReflectionTextureLeft = null;
|
||||
}
|
||||
if (m_ReflectionTextureRight)
|
||||
{
|
||||
RenderTexture.ReleaseTemporary(m_ReflectionTextureRight);
|
||||
m_ReflectionTextureRight = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void CopyCameraProperties(Camera src, Camera dest)
|
||||
{
|
||||
if (dest == null)
|
||||
return;
|
||||
|
||||
dest.CopyFrom(src);
|
||||
|
||||
if (m_ClearFlags == MirrorClearFlags.Skybox)
|
||||
{
|
||||
dest.clearFlags = CameraClearFlags.Skybox;
|
||||
Skybox mysky = dest.GetComponent<Skybox>();
|
||||
if (!mysky || !m_CustomSkybox)
|
||||
{
|
||||
mysky.enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
mysky.enabled = true;
|
||||
mysky.material = m_CustomSkybox;
|
||||
}
|
||||
}
|
||||
else if (m_ClearFlags == MirrorClearFlags.Color)
|
||||
{
|
||||
dest.clearFlags = CameraClearFlags.Color;
|
||||
dest.backgroundColor = m_CustomColor;
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateMirrorObjects(Camera currentCamera, Camera.StereoscopicEye eye,
|
||||
ref RenderTexture reflectionTexture)
|
||||
{
|
||||
// Calculate target resolution
|
||||
int currentTextureWidth = Mathf.RoundToInt(Math.Min(usedTextureSize, currentCamera.pixelWidth));
|
||||
int currentTextureHeight = Mathf.RoundToInt(Math.Min(usedTextureSize, currentCamera.pixelHeight));
|
||||
|
||||
var targetMsaa = usedMsaa;
|
||||
if (targetMsaa == 0)
|
||||
{
|
||||
RenderTexture targetTexture = currentCamera.targetTexture;
|
||||
if (targetTexture != null)
|
||||
targetMsaa = targetTexture.antiAliasing;
|
||||
else
|
||||
targetMsaa = QualitySettings.antiAliasing == 0 ? 1 : QualitySettings.antiAliasing;
|
||||
}
|
||||
|
||||
// Unity is good at caching rendertextures, so releasing it here and then immediately re-allocating a texture with the same resolution is fast
|
||||
// If the resolution is different, a new texture will be allocated and the old one will be freed
|
||||
if (reflectionTexture)
|
||||
RenderTexture.ReleaseTemporary(reflectionTexture);
|
||||
|
||||
// Additionally, releasing it here (instead of after mirror rendering is done) allows it to survive turning away from the mirror,
|
||||
// so that turning away from and back towards a mirror does not lead to lag spikes
|
||||
|
||||
// Reflection render texture
|
||||
reflectionTexture = RenderTexture.GetTemporary(currentTextureWidth, currentTextureHeight, 24,
|
||||
RenderTextureFormat.ARGBHalf,
|
||||
RenderTextureReadWrite.Default, targetMsaa, RenderTextureMemoryless.None, VRTextureUsage.None);
|
||||
reflectionTexture.name = "__MirrorReflection" + eye.ToString() + GetInstanceID();
|
||||
|
||||
// Camera for reflection
|
||||
if (m_ReflectionCamera == null)
|
||||
{
|
||||
GameObject go = new GameObject("Mirror Reflection Camera id" + GetInstanceID(),
|
||||
typeof(Camera), typeof(Skybox), typeof(FlareLayer));
|
||||
// Parent it to the mirror for easy cleanup in case of destroyed mirror
|
||||
go.transform.SetParent(transform);
|
||||
m_ReflectionCamera = go.GetComponent<Camera>();
|
||||
// Reflection camera transform is irrelevant because it has matrices set explicitly
|
||||
m_ReflectionCamera.enabled = false;
|
||||
go.hideFlags = HideFlags.DontSave | HideFlags.HideInHierarchy;
|
||||
}
|
||||
}
|
||||
|
||||
// Given position/normal of the plane, calculates plane in camera space.
|
||||
private Vector4 CameraSpacePlane(Matrix4x4 worldToCameraMatrix, Vector3 pos, Vector3 normal, float sideSign)
|
||||
{
|
||||
Vector3 offsetPos = pos + normal * m_ClipPlaneOffset;
|
||||
Vector3 cpos = worldToCameraMatrix.MultiplyPoint(offsetPos);
|
||||
Vector3 cnormal = worldToCameraMatrix.MultiplyVector(normal).normalized * sideSign;
|
||||
return new Vector4(cnormal.x, cnormal.y, cnormal.z, -Vector3.Dot(cpos, cnormal));
|
||||
}
|
||||
|
||||
// Calculates reflection matrix around the given plane
|
||||
private static void CalculateReflectionMatrix(ref Matrix4x4 reflectionMat, Vector4 plane)
|
||||
{
|
||||
reflectionMat.m00 = (1F - 2F * plane[0] * plane[0]);
|
||||
reflectionMat.m01 = (-2F * plane[0] * plane[1]);
|
||||
reflectionMat.m02 = (-2F * plane[0] * plane[2]);
|
||||
reflectionMat.m03 = (-2F * plane[3] * plane[0]);
|
||||
|
||||
reflectionMat.m10 = (-2F * plane[1] * plane[0]);
|
||||
reflectionMat.m11 = (1F - 2F * plane[1] * plane[1]);
|
||||
reflectionMat.m12 = (-2F * plane[1] * plane[2]);
|
||||
reflectionMat.m13 = (-2F * plane[3] * plane[1]);
|
||||
|
||||
reflectionMat.m20 = (-2F * plane[2] * plane[0]);
|
||||
reflectionMat.m21 = (-2F * plane[2] * plane[1]);
|
||||
reflectionMat.m22 = (1F - 2F * plane[2] * plane[2]);
|
||||
reflectionMat.m23 = (-2F * plane[3] * plane[2]);
|
||||
|
||||
reflectionMat.m30 = 0F;
|
||||
reflectionMat.m31 = 0F;
|
||||
reflectionMat.m32 = 0F;
|
||||
reflectionMat.m33 = 1F;
|
||||
}
|
||||
}
|
|
@ -3,8 +3,30 @@ using UnityEngine;
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRMovementParent : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Movement Parent")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/")]
|
||||
public class CVRMovementParent : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public enum VelocityInheritanceMode
|
||||
{
|
||||
None = 0,
|
||||
Parent = 1,
|
||||
Reference = 2
|
||||
}
|
||||
|
||||
public enum OrientationMode
|
||||
{
|
||||
Disabled = 0,
|
||||
RotateWithParent = 1
|
||||
}
|
||||
|
||||
[Tooltip("Controls whether the player should rotate with the moving platform.")]
|
||||
public OrientationMode orientationMode = OrientationMode.RotateWithParent;
|
||||
|
||||
[Tooltip("Controls how the player inherits velocity from the moving platform.")]
|
||||
public VelocityInheritanceMode velocityInheritance = VelocityInheritanceMode.Reference;
|
||||
|
||||
// to make the enabled checkbox display
|
||||
private void OnEnable(){}
|
||||
}
|
||||
}
|
|
@ -3,7 +3,9 @@ using UnityEngine.AI;
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRNavController : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Nav Controller")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/nav-controller/")]
|
||||
public class CVRNavController : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public NavMeshAgent navMeshAgent;
|
||||
public Transform[] navTargetList;
|
||||
|
|
|
@ -3,7 +3,9 @@ using UnityEngine;
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRObjectLibrary : MonoBehaviour
|
||||
[AddComponentMenu("")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/")]
|
||||
public class CVRObjectLibrary : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public List<CVRObjectCatalogCategory> objectCatalogCategories = new List<CVRObjectCatalogCategory>();
|
||||
public List<CVRObjectCatalogEntry> objectCatalogEntries = new List<CVRObjectCatalogEntry>();
|
||||
|
|
|
@ -3,7 +3,9 @@ using UnityEngine;
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRObjectSync : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Object Sync")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/object-sync/")]
|
||||
public class CVRObjectSync : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
|
||||
[HideInInspector]
|
||||
|
|
|
@ -18,9 +18,9 @@ namespace ABI.CCK.Components
|
|||
|
||||
public TaskType type = TaskType.Position;
|
||||
|
||||
public Component component = null;
|
||||
public Component component;
|
||||
|
||||
public int intVal = 0;
|
||||
public int intVal;
|
||||
|
||||
public CVRSerializableObjectSyncTask getDefaultValues()
|
||||
{
|
||||
|
@ -34,28 +34,24 @@ namespace ABI.CCK.Components
|
|||
retPos.value = ((Transform) component).position.ToString("F6");
|
||||
retPos.intVal = intVal;
|
||||
return retPos;
|
||||
break;
|
||||
case TaskType.Rotation:
|
||||
var retRot = new CVRSerializableObjectSyncTask();
|
||||
retRot.type = TaskType.Rotation;
|
||||
retRot.value = ((Transform) component).eulerAngles.ToString("F3");
|
||||
retRot.intVal = intVal;
|
||||
return retRot;
|
||||
break;
|
||||
case TaskType.ActivityState:
|
||||
var retAct = new CVRSerializableObjectSyncTask();
|
||||
retAct.type = TaskType.ActivityState;
|
||||
retAct.value = ((Transform) component).gameObject.activeSelf ? "1" : "0";
|
||||
retAct.intVal = intVal;
|
||||
return retAct;
|
||||
break;
|
||||
case TaskType.PickupOwner:
|
||||
var retPick = new CVRSerializableObjectSyncTask();
|
||||
retPick.type = TaskType.PickupOwner;
|
||||
retPick.value = "";
|
||||
retPick.intVal = intVal;
|
||||
return retPick;
|
||||
break;
|
||||
case TaskType.AnimatorParameter:
|
||||
var retAniParam = new CVRSerializableObjectSyncTask();
|
||||
retAniParam.type = TaskType.AnimatorParameter;
|
||||
|
@ -80,21 +76,18 @@ namespace ABI.CCK.Components
|
|||
}
|
||||
retAniParam.intVal = intVal;
|
||||
return retAniParam;
|
||||
break;
|
||||
case TaskType.AnimatorAnimationProgress:
|
||||
var retAniProg = new CVRSerializableObjectSyncTask();
|
||||
retAniProg.type = TaskType.AnimatorAnimationProgress;
|
||||
retAniProg.value = (0f).ToString("F8");
|
||||
retAniProg.intVal = intVal;
|
||||
return retAniProg;
|
||||
break;
|
||||
case TaskType.VariableBufferValue:
|
||||
var retVar = new CVRSerializableObjectSyncTask();
|
||||
retVar.type = TaskType.VariableBufferValue;
|
||||
retVar.value = ((CVRVariableBuffer) component).defaultValue.ToString("F8");
|
||||
retVar.intVal = intVal;
|
||||
return retVar;
|
||||
break;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Animations;
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRParameterStream : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Parameter Stream")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/")]
|
||||
public class CVRParameterStream : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public enum ReferenceType
|
||||
{
|
||||
|
@ -12,12 +16,24 @@ namespace ABI.CCK.Components
|
|||
Spawnable = 2
|
||||
}
|
||||
|
||||
[NotKeyable]
|
||||
public ReferenceType referenceType = ReferenceType.World;
|
||||
|
||||
public List<CVRParameterStreamEntry> entries = new List<CVRParameterStreamEntry>();
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public List<CVRParameterStreamEntry> entries = new();
|
||||
|
||||
public bool onlyUpdateWhenHeld;
|
||||
public bool onlyUpdateWhenAttached;
|
||||
public bool onlyUpdateWhenControlled;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
// ignored, required to make the enabled checkbox display
|
||||
}
|
||||
}
|
||||
|
||||
#region CVRParameterStreamEntry Class
|
||||
|
||||
[Serializable]
|
||||
public class CVRParameterStreamEntry
|
||||
{
|
||||
public enum Type
|
||||
|
@ -47,14 +63,46 @@ namespace ABI.CCK.Components
|
|||
LocalPlayerHudEnabled = 220,
|
||||
LocalPlayerNameplatesEnabled = 230,
|
||||
LocalPlayerHeight = 240,
|
||||
LocalPlayerControllerType = 250,
|
||||
LocalPlayerLeftControllerType = 250,
|
||||
LocalPlayerRightControllerType = 251,
|
||||
LocalPlayerFullBodyEnabled = 260,
|
||||
TriggerLeftValue = 270,
|
||||
TriggerRightValue = 280,
|
||||
GripLeftValue = 290,
|
||||
GripRightValue = 300,
|
||||
GrippedObjectLeft = 310,
|
||||
GrippedObjectRight = 320
|
||||
GrippedObjectRight = 320,
|
||||
AvatarHeight = 400,
|
||||
AvatarUpright = 401,
|
||||
TransformGlobalPositionX = 500,
|
||||
TransformGlobalPositionY = 501,
|
||||
TransformGlobalPositionZ = 502,
|
||||
TransformGlobalRotationX = 510,
|
||||
TransformGlobalRotationY = 511,
|
||||
TransformGlobalRotationZ = 512,
|
||||
TransformLocalPositionX = 520,
|
||||
TransformLocalPositionY = 521,
|
||||
TransformLocalPositionZ = 522,
|
||||
TransformLocalRotationX = 530,
|
||||
TransformLocalRotationY = 531,
|
||||
TransformLocalRotationZ = 532,
|
||||
FluidVolumeSubmerged = 600,
|
||||
FluidVolumeDepth = 601,
|
||||
FluidVolumeTimeSinceEntered = 602,
|
||||
FluidVolumeTimeSinceExit = 603,
|
||||
InputCarSteering = 1000,
|
||||
InputCarAccelerate = 1001,
|
||||
InputCarBrake = 1002,
|
||||
InputCarHandbrake = 1003,
|
||||
InputCarBoost = 1004,
|
||||
InputMovementX = 1100,
|
||||
InputMovementY = 1101,
|
||||
InputLookX = 1110,
|
||||
InputLookY = 1111,
|
||||
InputJump = 1120,
|
||||
|
||||
SeedOwner = 90000,
|
||||
SeedInstance = 90001,
|
||||
}
|
||||
|
||||
public Type type = Type.TimeSeconds;
|
||||
|
@ -64,7 +112,7 @@ namespace ABI.CCK.Components
|
|||
Animator = 0,
|
||||
VariableBuffer = 1,
|
||||
AvatarAnimator = 2,
|
||||
CustomFloat = 3,
|
||||
CustomFloat = 3
|
||||
}
|
||||
|
||||
public TargetType targetType = TargetType.Animator;
|
||||
|
@ -86,15 +134,17 @@ namespace ABI.CCK.Components
|
|||
CompareMoreThenEquals = 121,
|
||||
CompareMoreThen = 131,
|
||||
Mod = 141,
|
||||
Pow = 151,
|
||||
Pow = 151
|
||||
}
|
||||
|
||||
public ApplicationType applicationType = ApplicationType.Override;
|
||||
|
||||
public float staticValue;
|
||||
|
||||
|
||||
public GameObject target;
|
||||
|
||||
public string parameterName;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
|
@ -1,15 +1,15 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRParticleSound : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Particle Sound")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/particle-sound/")]
|
||||
public class CVRParticleSound : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public ParticleSystem particleSystem;
|
||||
public new ParticleSystem particleSystem;
|
||||
|
||||
public AudioClip[] spawnSound;
|
||||
public AudioClip[] dieSound;
|
||||
|
@ -54,8 +54,7 @@ namespace ABI.CCK.Components
|
|||
|
||||
foreach (ParticleSystem.Particle activeParticle in currentParticles)
|
||||
{
|
||||
ParticleSystem.Particle foundParticle;
|
||||
if(_particles.TryGetValue(activeParticle.randomSeed, out foundParticle))
|
||||
if(_particles.TryGetValue(activeParticle.randomSeed, out _))
|
||||
{
|
||||
_particles[activeParticle.randomSeed] = activeParticle;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,9 @@ using UnityEngine;
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRPickupObject : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Pickup Object")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/pickup-object/")]
|
||||
public class CVRPickupObject : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public enum GripType
|
||||
{
|
||||
|
@ -22,11 +24,10 @@ namespace ABI.CCK.Components
|
|||
public List<SnappingReference> snappingReferences = new List<SnappingReference>();
|
||||
|
||||
public bool autoHold = false;
|
||||
public bool updateWithPhysics = true;
|
||||
|
||||
public Transform ikReference;
|
||||
|
||||
private Transform _originalParent;
|
||||
|
||||
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
if (gripType == GripType.Origin && gripOrigin != null)
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRPointer : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Pointer")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/pointer/")]
|
||||
[DisallowMultipleComponent]
|
||||
public class CVRPointer : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public string type;
|
||||
|
||||
|
|
|
@ -2,7 +2,9 @@ using UnityEngine;
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRPortalMarker : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Portal Marker")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/portal-marker/")]
|
||||
public class CVRPortalMarker : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public string worldGUID;
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRSnappingPoint : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Snapping Point")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/")]
|
||||
public class CVRSnappingPoint : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public string type;
|
||||
|
||||
|
|
|
@ -1,13 +1,24 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using ABI.CCK.Components;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRSpawnable : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Spawnable")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/spawnable/")]
|
||||
public class CVRSpawnable : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
#region Editor Methods
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
if (GetComponent<CVRAssetInfo>() != null) return;
|
||||
CVRAssetInfo info = gameObject.AddComponent<CVRAssetInfo>();
|
||||
info.type = CVRAssetInfo.AssetType.Spawnable;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public float spawnHeight = 0f;
|
||||
|
||||
public bool useAdditionalValues;
|
||||
|
@ -54,7 +65,7 @@ namespace ABI.CCK.Components
|
|||
foreach (var subSync in subSyncs)
|
||||
{
|
||||
if (subSync.precision == CVRSpawnableSubSync.SyncPrecision.Full) continue;
|
||||
if (subSync.transform == null) continue;
|
||||
if (subSync.transform == null || subSync.transform.parent == null) continue;
|
||||
|
||||
Gizmos.matrix = Matrix4x4.TRS(subSync.transform.parent.position, Quaternion.identity, subSync.transform.parent.lossyScale);
|
||||
|
||||
|
@ -77,22 +88,6 @@ namespace ABI.CCK.Components
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
if (GetComponent<CVRBuilderSpawnable>() != null)
|
||||
{
|
||||
Invoke("DestroyThis", 0);
|
||||
}
|
||||
else if (GetComponent<CVRAssetInfo>() == null)
|
||||
{
|
||||
CVRAssetInfo info = gameObject.AddComponent<CVRAssetInfo>();
|
||||
info.type = CVRAssetInfo.AssetType.Spawnable;
|
||||
}
|
||||
}
|
||||
void DestroyThis() {
|
||||
DestroyImmediate(this);
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
|
@ -153,7 +148,7 @@ namespace ABI.CCK.Components
|
|||
public string animatorParameterName;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
[Serializable]
|
||||
public class CVRSpawnableSubSync
|
||||
{
|
||||
public Transform transform;
|
||||
|
@ -169,7 +164,8 @@ namespace ABI.CCK.Components
|
|||
RotationZ = 1 << 6
|
||||
}
|
||||
|
||||
public SyncFlags syncedValues;
|
||||
// default to everything (is hardcoded, change if you change the enum)
|
||||
public SyncFlags syncedValues = (SyncFlags) 0b01111110;
|
||||
|
||||
public enum SyncPrecision
|
||||
{
|
||||
|
|
|
@ -3,7 +3,9 @@ using UnityEngine;
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRSpawnableTrigger : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Spawnable Trigger")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/spawnable-trigger/")]
|
||||
public class CVRSpawnableTrigger : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public Vector3 areaSize = new Vector3(0.05f, 0.05f, 0.05f);
|
||||
public Vector3 areaOffset = Vector3.zero;
|
||||
|
@ -59,11 +61,24 @@ namespace ABI.CCK.Components
|
|||
Gizmos.color = Color.cyan;
|
||||
Matrix4x4 rotationMatrix = Matrix4x4.TRS(transform.position, transform.rotation, transform.lossyScale);
|
||||
Gizmos.matrix = rotationMatrix;
|
||||
Gizmos.DrawCube(areaOffset, areaSize);
|
||||
|
||||
Collider collider = gameObject.GetComponent<Collider>();
|
||||
if (collider == null)
|
||||
{
|
||||
if (OnlyHasDistanceTask())
|
||||
{
|
||||
Gizmos.DrawSphere(Vector3.zero, areaSize.x);
|
||||
Gizmos.DrawWireSphere(Vector3.zero, areaSize.x);
|
||||
}
|
||||
else
|
||||
{
|
||||
Gizmos.DrawCube(areaOffset, areaSize);
|
||||
}
|
||||
}
|
||||
|
||||
Vector3 bounds = new Vector3(areaSize.x * 0.5f, areaSize.y * 0.5f, areaSize.z * 0.5f);
|
||||
|
||||
if (stayTasks.Count > 0)
|
||||
if (stayTasks.Count > 0 && !OnlyHasDistanceTask())
|
||||
{
|
||||
Gizmos.DrawWireCube(areaOffset, areaSize);
|
||||
|
||||
|
@ -181,6 +196,12 @@ namespace ABI.CCK.Components
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool OnlyHasDistanceTask()
|
||||
{
|
||||
return enterTasks.Count == 0 && exitTasks.Count == 0 && stayTasks.Count > 0 && stayTasks.FindAll(x =>
|
||||
x.updateMethod != CVRSpawnableTriggerTaskStay.UpdateMethod.SetFromDistance).Count == 0;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
|
@ -214,6 +235,7 @@ namespace ABI.CCK.Components
|
|||
SetFromPosition = 1,
|
||||
Add = 2,
|
||||
Subtract = 3,
|
||||
SetFromDistance = 4
|
||||
}
|
||||
|
||||
public CVRSpawnableTriggerTaskStay.UpdateMethod updateMethod = UpdateMethod.SetFromPosition;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRTexturePropertyParser : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/Texture Property Parser")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/texture-property-parser/")]
|
||||
public class CVRTexturePropertyParser : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public enum TextureType
|
||||
{
|
||||
|
|
|
@ -2,13 +2,10 @@
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRTimelineSync : MonoBehaviour
|
||||
[AddComponentMenu("")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/")]
|
||||
public class CVRTimelineSync : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
[AddComponentMenu("")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/")]
|
||||
public class CVRToggleStatePointer : CVRPointer
|
||||
{
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
if (isActiveAndEnabled)
|
||||
{
|
||||
Gizmos.color = Color.green;
|
||||
Matrix4x4 rotationMatrix = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one);
|
||||
Gizmos.matrix = rotationMatrix;
|
||||
Gizmos.DrawSphere(Vector3.zero, 0.015f);
|
||||
}
|
||||
if (!isActiveAndEnabled)
|
||||
return;
|
||||
|
||||
Gizmos.color = Color.green;
|
||||
Matrix4x4 rotationMatrix = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one);
|
||||
Gizmos.matrix = rotationMatrix;
|
||||
Gizmos.DrawSphere(Vector3.zero, 0.015f);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +1,10 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRToggleStateTrigger : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Toggle State Trigger")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/state-trigger/")]
|
||||
public class CVRToggleStateTrigger : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public Vector3 areaSize = new Vector3(0.05f, 0.05f, 0.05f);
|
||||
public Vector3 areaOffset = Vector3.zero;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
|
@ -13,7 +12,9 @@ using TMPro;
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRTranslatable : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Translatable")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/")]
|
||||
public class CVRTranslatable : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
|
||||
public List<ObjectTranslatable_t> Translatables = new List<ObjectTranslatable_t>();
|
||||
|
@ -87,7 +88,7 @@ namespace ABI.CCK.Components
|
|||
entity.Text = EditorGUI.TextArea(_rect, entity.Text);
|
||||
break;
|
||||
case TranslatableType.AudioClip:
|
||||
entity.Clip = (AudioClip) EditorGUI.ObjectField(_rect, entity.Clip, typeof(AudioClip));
|
||||
entity.Clip = (AudioClip) EditorGUI.ObjectField(_rect, entity.Clip, typeof(AudioClip), false);
|
||||
break;
|
||||
case TranslatableType.GameObject:
|
||||
entity.Object = (GameObject) EditorGUI.ObjectField(_rect, entity.Object, typeof(GameObject), true);
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Analytics;
|
||||
|
||||
#pragma warning disable
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRVariableBuffer : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Variable Buffer")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/variable-buffer/")]
|
||||
public class CVRVariableBuffer : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public float defaultValue = 0f;
|
||||
|
||||
|
|
|
@ -10,7 +10,9 @@ using UnityEngine.UI;
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRVideoPlayer : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR Video Player")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/video-player/")]
|
||||
public class CVRVideoPlayer : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public enum AudioMode
|
||||
{
|
||||
|
@ -105,7 +107,7 @@ namespace ABI.CCK.Components
|
|||
public AudioSource audioSource;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
[Serializable]
|
||||
public class CVRVideoPlayerPlaylist
|
||||
{
|
||||
public string playlistThumbnailUrl;
|
||||
|
@ -266,7 +268,7 @@ namespace ABI.CCK.Components
|
|||
#endif
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
[Serializable]
|
||||
public class CVRVideoPlayerPlaylistEntity
|
||||
{
|
||||
public string videoUrl;
|
||||
|
@ -276,5 +278,4 @@ namespace ABI.CCK.Components
|
|||
public string thumbnailUrl;
|
||||
public bool isCollapsed;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,15 +1 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[System.Serializable]
|
||||
public class CVRVideoPlayerPlaylistEntity
|
||||
{
|
||||
public string playerId;
|
||||
public string videoUrl;
|
||||
public string videoTitle;
|
||||
public int introEndInSeconds;
|
||||
public int creditsStartInSeconds;
|
||||
}
|
||||
|
||||
|
||||
// delete moe
|
|
@ -1,11 +1,12 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using ABI.CCK.Components;
|
||||
using UnityEngine;
|
||||
|
||||
[AddComponentMenu("")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/")]
|
||||
[System.Serializable]
|
||||
public class CVRWarpPoint : MonoBehaviour
|
||||
public class CVRWarpPoint : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
[Header("CVR Warp Point (Will teleport you to the position of this object on ui interaction.)")]
|
||||
public string warpPointName;
|
||||
public string warpPointDescription;
|
||||
}
|
||||
}
|
|
@ -1,164 +1,315 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
#if CCK_ADDIN_HIGHLIGHT_PLUS
|
||||
using HighlightPlus;
|
||||
#endif
|
||||
using UnityEditor;
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
[RequireComponent(typeof(CVRAssetInfo))]
|
||||
[ExecuteInEditMode]
|
||||
public class CVRWorld : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/CVR World")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/components/world/")]
|
||||
public class CVRWorld : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
#region Editor Methods
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
if (GetComponent<CVRAssetInfo>() != null) return;
|
||||
CVRAssetInfo info = gameObject.AddComponent<CVRAssetInfo>();
|
||||
info.type = CVRAssetInfo.AssetType.World;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CVRWorldEnums
|
||||
|
||||
public enum SpawnRule
|
||||
{
|
||||
InOrder = 1,
|
||||
Random = 2,
|
||||
Sequential = 1,
|
||||
Random = 2
|
||||
}
|
||||
|
||||
public enum RespawnBehaviour
|
||||
{
|
||||
Respawn = 1,
|
||||
Destroy = 2,
|
||||
Destroy = 2
|
||||
}
|
||||
|
||||
public GameObject[] spawns = new GameObject[0];
|
||||
public SpawnRule spawnRule = SpawnRule.Random;
|
||||
|
||||
#endregion
|
||||
|
||||
#region General Settings
|
||||
|
||||
public GameObject referenceCamera;
|
||||
public int respawnHeightY = -100;
|
||||
public RespawnBehaviour objectRespawnBehaviour = RespawnBehaviour.Destroy;
|
||||
|
||||
//[Space] [Header("Optional settings")] [Space]
|
||||
public CVRWarpPoint[] warpPoints = new CVRWarpPoint[0];
|
||||
|
||||
public GameObject[] spawns = Array.Empty<GameObject>();
|
||||
public SpawnRule spawnRule = SpawnRule.Random;
|
||||
public int respawnHeightY = -25;
|
||||
public RespawnBehaviour objectRespawnBehaviour = RespawnBehaviour.Respawn;
|
||||
|
||||
// Currently unused
|
||||
[HideInInspector] public CVRWarpPoint[] warpPoints = Array.Empty<CVRWarpPoint>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region AdvSettings World Rules
|
||||
|
||||
public bool useAdvancedSettings = false;
|
||||
|
||||
public bool allowSpawnables = true;
|
||||
public bool allowPortals = true;
|
||||
public bool allowFlying = true;
|
||||
public bool showNamePlates = true;
|
||||
public bool enableBuilder = true;
|
||||
[HideInInspector] public bool enableBuilder = true; // unused
|
||||
|
||||
#endregion
|
||||
|
||||
#region AdvSettings World Graphics
|
||||
|
||||
|
||||
#if CCK_ADDIN_HIGHLIGHT_PLUS
|
||||
public HighlightProfile highlightProfile;
|
||||
#endif
|
||||
|
||||
[Range(60f, 120f)]
|
||||
public float fov = 60f;
|
||||
public bool enableZoom = true;
|
||||
public bool enableDepthNormals;
|
||||
[FormerlySerializedAs("allowCustomFarClippingPlane")]
|
||||
public bool allowExtremeFarClippingPlane = false;
|
||||
|
||||
#endregion
|
||||
|
||||
#region AdvSettings Movement Modifiers
|
||||
|
||||
public float baseMovementSpeed = 2f;
|
||||
|
||||
public float sprintMultiplier = 2f;
|
||||
public float strafeMultiplier = 1f;
|
||||
public float crouchMultiplier = 0.5f;
|
||||
public float proneMultiplier = 0.3f;
|
||||
public float flyMultiplier = 5f;
|
||||
public float inAirMovementMultiplier = 1f;
|
||||
|
||||
public float gravity = 18f;
|
||||
public float objectGravity = 9.81f;
|
||||
public float jumpHeight = 1f;
|
||||
|
||||
public float fov = 60f;
|
||||
public bool enableZoom = true;
|
||||
|
||||
#if CCK_ADDIN_HIGHLIGHT_PLUS
|
||||
public HighlightProfile highlightProfile;
|
||||
#endif
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Friction of the air. This will be applied to the character when moving on air, including falling, being
|
||||
/// pulled by gravity, or even when floating in 0 gravity.
|
||||
/// </summary>
|
||||
[SerializeField] public float airFriction = 0.3f;
|
||||
|
||||
/// <summary>
|
||||
/// Mode to use to align players with the current gravity direction.
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
public GravityZone.PlayerAlignmentMode playerGravityAlignmentMode = GravityZone.DefaultGravityAlignmentMode;
|
||||
|
||||
/// <summary>
|
||||
/// Value used for the gravity player alignment speed when using the custom alignment mode.
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
public float playerGravityCustomAlignmentValue = GravityZone.DefaultGravityCustomAlignmentValue;
|
||||
|
||||
#endregion
|
||||
|
||||
#region AdvSettings Collision Matrix
|
||||
|
||||
public bool useCustomCollisionMatrix = false;
|
||||
|
||||
public List<CVRCollisionListWrapper> collisionMatrix = new List<CVRCollisionListWrapper>
|
||||
{
|
||||
//Internal
|
||||
new CVRCollisionListWrapper(new[]
|
||||
{ true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true }),
|
||||
new CVRCollisionListWrapper(new[]
|
||||
{ true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true }),
|
||||
new CVRCollisionListWrapper(new[]
|
||||
{ true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true }),
|
||||
new CVRCollisionListWrapper(new[]
|
||||
{ true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true }),
|
||||
new CVRCollisionListWrapper(new[]
|
||||
{ true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true }),
|
||||
new CVRCollisionListWrapper(new[]
|
||||
{ true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true }),
|
||||
new CVRCollisionListWrapper(new[]
|
||||
{ true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true }),
|
||||
new CVRCollisionListWrapper(new[]
|
||||
{ true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true }),
|
||||
new CVRCollisionListWrapper(new[]
|
||||
{ true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true }),
|
||||
new CVRCollisionListWrapper(new[]
|
||||
{ true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true }),
|
||||
new CVRCollisionListWrapper(new[]
|
||||
{ true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true }),
|
||||
new CVRCollisionListWrapper(new[]
|
||||
{ true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true }),
|
||||
new CVRCollisionListWrapper(new[]
|
||||
{ true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true }),
|
||||
new CVRCollisionListWrapper(new[]
|
||||
{ true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true }),
|
||||
new CVRCollisionListWrapper(new[]
|
||||
{ true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true }),
|
||||
new CVRCollisionListWrapper(new[]
|
||||
{ true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true }),
|
||||
//Content
|
||||
new CVRCollisionListWrapper(new[]
|
||||
{ true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true }),
|
||||
new CVRCollisionListWrapper(new[]
|
||||
{ true, true, true, true, true, true, true, true, true, true, true, true, true, true, true }),
|
||||
new CVRCollisionListWrapper(new[]
|
||||
{ true, true, true, true, true, true, true, true, true, true, true, true, true, true }),
|
||||
new CVRCollisionListWrapper(new[]
|
||||
{ true, true, true, true, true, true, true, true, true, true, true, true, true }),
|
||||
new CVRCollisionListWrapper(
|
||||
new[] { true, true, true, true, true, true, true, true, true, true, true, true }),
|
||||
new CVRCollisionListWrapper(new[] { true, true, true, true, true, true, true, true, true, true, true }),
|
||||
new CVRCollisionListWrapper(new[] { true, true, true, true, true, true, true, true, true, true }),
|
||||
new CVRCollisionListWrapper(new[] { true, true, true, true, true, true, true, true, true }),
|
||||
new CVRCollisionListWrapper(new[] { true, true, true, true, true, true, true, true }),
|
||||
new CVRCollisionListWrapper(new[] { true, true, true, true, true, true, true }),
|
||||
new CVRCollisionListWrapper(new[] { true, true, true, true, true, true }),
|
||||
new CVRCollisionListWrapper(new[] { true, true, true, true, true }),
|
||||
new CVRCollisionListWrapper(new[] { true, true, true, true }),
|
||||
new CVRCollisionListWrapper(new[] { true, true, true }),
|
||||
new CVRCollisionListWrapper(new[] { true, true }),
|
||||
new CVRCollisionListWrapper(new[] { true })
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
#region Object Library
|
||||
|
||||
public List<CVRObjectCatalogCategory> objectCatalogCategories = new List<CVRObjectCatalogCategory>();
|
||||
public List<CVRObjectCatalogEntry> objectCatalogEntries = new List<CVRObjectCatalogEntry>();
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
CVRAssetInfo info = gameObject.GetComponent<CVRAssetInfo>();
|
||||
info.type = CVRAssetInfo.AssetType.World;
|
||||
}
|
||||
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
Gizmos.color = Color.white;
|
||||
#endregion
|
||||
|
||||
if (spawns.Length == 0)
|
||||
#region Public Methods
|
||||
|
||||
public void CaptureCollisionMatrix()
|
||||
{
|
||||
for (int i = 0; i <= 31; i++)
|
||||
{
|
||||
DrawArrow(transform.position, new Vector3(0, transform.eulerAngles.y, 0), 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (GameObject spawn in spawns)
|
||||
for (int j = 0; j <= Math.Min(31 - i, 15); j++)
|
||||
{
|
||||
if (spawn != null)
|
||||
{
|
||||
DrawArrow(spawn.transform.position, new Vector3(0, spawn.transform.eulerAngles.y, 0), 1);
|
||||
}
|
||||
collisionMatrix[i][j] = !Physics.GetIgnoreLayerCollision(i, 31 - j);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Gizmos.DrawLine(transform.position, transform.position + Vector3.up);
|
||||
Gizmos.matrix = Matrix4x4.TRS(transform.position + Vector3.up, Quaternion.identity, Vector3.one);
|
||||
Gizmos.DrawFrustum(Vector3.zero, 85f, 1f, 0.1f, 1f);
|
||||
Gizmos.matrix = Matrix4x4.TRS(transform.position + Vector3.up, Quaternion.Euler(0, 90, 0), Vector3.one);
|
||||
Gizmos.DrawFrustum(Vector3.zero, 85f, 1f, 0.1f, 1f);
|
||||
Gizmos.matrix = Matrix4x4.TRS(transform.position + Vector3.up, Quaternion.Euler(0, 180, 0), Vector3.one);
|
||||
Gizmos.DrawFrustum(Vector3.zero, 85f, 1f, 0.1f, 1f);
|
||||
Gizmos.matrix = Matrix4x4.TRS(transform.position + Vector3.up, Quaternion.Euler(0, 270, 0), Vector3.one);
|
||||
Gizmos.DrawFrustum(Vector3.zero, 85f, 1f, 0.1f, 1f);
|
||||
|
||||
#if UNITY_EDITOR
|
||||
GUIStyle style = new GUIStyle();
|
||||
style.normal.textColor = Color.white;
|
||||
style.fontSize = 10;
|
||||
Handles.BeginGUI();
|
||||
Vector3 pos = transform.TransformPoint(Vector3.up);
|
||||
Vector2 pos2D = HandleUtility.WorldToGUIPoint(pos);
|
||||
GUI.Label(new Rect(pos2D.x + 20, pos2D.y - 10, 100, 20), "Portal Image will be taken from here", style);
|
||||
Handles.EndGUI();
|
||||
#endif
|
||||
}
|
||||
|
||||
private void DrawArrow(Vector3 position, Vector3 angle, float size)
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method Calls
|
||||
|
||||
public void SetBaseMovementSpeed(float value)
|
||||
{
|
||||
var a1 = position + new Vector3(0, 0.1f * size, 0);
|
||||
var a2 = RotatePointAroundPivot(position + new Vector3(0.1f * size, 0, 0), position, angle);
|
||||
var a3 = position + new Vector3(0, -0.1f * size, 0);
|
||||
var a4 = RotatePointAroundPivot(position + new Vector3(-0.1f * size, 0, 0), position, angle);
|
||||
|
||||
var b1 = RotatePointAroundPivot(position + new Vector3(0, 0.1f * size, 0.3f * size), position, angle);
|
||||
var b2 = RotatePointAroundPivot(position + new Vector3(0.1f * size, 0, 0.3f * size), position, angle);
|
||||
var b3 = RotatePointAroundPivot(position + new Vector3(0, -0.1f * size, 0.3f * size), position, angle);
|
||||
var b4 = RotatePointAroundPivot(position + new Vector3(-0.1f * size, 0, 0.3f * size), position, angle);
|
||||
|
||||
var c1 = RotatePointAroundPivot(position + new Vector3(0, 0.2f * size, 0.3f * size), position, angle);
|
||||
var c2 = RotatePointAroundPivot(position + new Vector3(0.2f * size, 0, 0.3f * size), position, angle);
|
||||
var c3 = RotatePointAroundPivot(position + new Vector3(0, -0.2f * size, 0.3f * size), position, angle);
|
||||
var c4 = RotatePointAroundPivot(position + new Vector3(-0.2f * size, 0, 0.3f * size), position, angle);
|
||||
|
||||
var d = RotatePointAroundPivot(position + new Vector3(0, 0, 0.5f * size), position, angle);
|
||||
|
||||
Gizmos.DrawLine(position, a1);
|
||||
Gizmos.DrawLine(position, a2);
|
||||
Gizmos.DrawLine(position, a3);
|
||||
Gizmos.DrawLine(position, a4);
|
||||
|
||||
Gizmos.DrawLine(a1, b1);
|
||||
Gizmos.DrawLine(a2, b2);
|
||||
Gizmos.DrawLine(a3, b3);
|
||||
Gizmos.DrawLine(a4, b4);
|
||||
|
||||
Gizmos.DrawLine(b1, c1);
|
||||
Gizmos.DrawLine(b2, c2);
|
||||
Gizmos.DrawLine(b3, c3);
|
||||
Gizmos.DrawLine(b4, c4);
|
||||
|
||||
Gizmos.DrawLine(c1, d);
|
||||
Gizmos.DrawLine(c2, d);
|
||||
Gizmos.DrawLine(c3, d);
|
||||
Gizmos.DrawLine(c4, d);
|
||||
baseMovementSpeed = value;
|
||||
ApplyMovementSettings();
|
||||
}
|
||||
|
||||
private Vector3 RotatePointAroundPivot(Vector3 point, Vector3 pivot, Vector3 angles)
|
||||
|
||||
public void SetSprintMultiplier(float value)
|
||||
{
|
||||
var dir = point - pivot; // get point direction relative to pivot
|
||||
dir = Quaternion.Euler(angles) * dir; // rotate it
|
||||
point = dir + pivot; // calculate rotated point
|
||||
return point; // return it
|
||||
sprintMultiplier = value;
|
||||
ApplyMovementSettings();
|
||||
}
|
||||
|
||||
public void SetStrafeMultiplier(float value)
|
||||
{
|
||||
strafeMultiplier = value;
|
||||
ApplyMovementSettings();
|
||||
}
|
||||
|
||||
public void SetCrouchMultiplier(float value)
|
||||
{
|
||||
crouchMultiplier = value;
|
||||
ApplyMovementSettings();
|
||||
}
|
||||
|
||||
public void SetProneMultiplier(float value)
|
||||
{
|
||||
proneMultiplier = value;
|
||||
ApplyMovementSettings();
|
||||
}
|
||||
|
||||
public void SetFlyMultiplier(float value)
|
||||
{
|
||||
flyMultiplier = value;
|
||||
ApplyMovementSettings();
|
||||
}
|
||||
|
||||
public void SetInAirMovementMultiplier(float value)
|
||||
{
|
||||
inAirMovementMultiplier = value;
|
||||
ApplyMovementSettings();
|
||||
}
|
||||
|
||||
public void SetJumpHeight(float value)
|
||||
{
|
||||
jumpHeight = value;
|
||||
ApplyMovementSettings();
|
||||
}
|
||||
|
||||
public void SetAirFriction(float value)
|
||||
{
|
||||
airFriction = value;
|
||||
ApplyMovementSettings();
|
||||
}
|
||||
|
||||
public void SetGravity(float value)
|
||||
{
|
||||
gravity = value;
|
||||
ApplyMovementSettings();
|
||||
}
|
||||
|
||||
public void SetObjectGravity(float value)
|
||||
{
|
||||
objectGravity = value;
|
||||
ApplyMovementSettings();
|
||||
}
|
||||
|
||||
public void SetPlayerGravityAlignmentMode(int value)
|
||||
{
|
||||
// Use `int` so they can be used via method calls
|
||||
if (Enum.IsDefined(typeof(GravityZone.PlayerAlignmentMode), value))
|
||||
{
|
||||
playerGravityAlignmentMode = (GravityZone.PlayerAlignmentMode)value;
|
||||
ApplyMovementSettings();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetPlayerGravityCustomAlignmentValue(float value)
|
||||
{
|
||||
playerGravityCustomAlignmentValue = value;
|
||||
ApplyMovementSettings();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies the current CVRWorld movement setting values to the character controller.
|
||||
/// </summary>
|
||||
public void ApplyMovementSettings() { }
|
||||
|
||||
#endregion
|
||||
|
||||
#region UnityEvents
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
// using Range attribute turns it into an ugly slider, enforced by client
|
||||
playerGravityCustomAlignmentValue = Mathf.Clamp(playerGravityCustomAlignmentValue, 0, GravityZone.MaxDegreesPerSecond);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
#region Object Library Classes
|
||||
|
||||
[Serializable]
|
||||
public class CVRObjectCatalogCategory
|
||||
{
|
||||
public string id;
|
||||
|
@ -166,7 +317,7 @@ namespace ABI.CCK.Components
|
|||
public Texture2D image;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
[Serializable]
|
||||
public class CVRObjectCatalogEntry
|
||||
{
|
||||
public string name;
|
||||
|
@ -175,4 +326,35 @@ namespace ABI.CCK.Components
|
|||
public string categoryId = "";
|
||||
public string guid = "";
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CVRCollisionListWrapper Class
|
||||
|
||||
[Serializable]
|
||||
public class CVRCollisionListWrapper
|
||||
{
|
||||
public List<bool> collisionList = new List<bool>();
|
||||
|
||||
public CVRCollisionListWrapper(IEnumerable<bool> boolList)
|
||||
{
|
||||
foreach (bool b in boolList)
|
||||
{
|
||||
collisionList.Add(b);
|
||||
}
|
||||
}
|
||||
|
||||
public bool this[int key]
|
||||
{
|
||||
get => collisionList[key];
|
||||
set => collisionList[key] = value;
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get => collisionList.Count;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class CVRWorldModifiers : MonoBehaviour
|
||||
[AddComponentMenu("")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/")]
|
||||
public class CVRWorldModifiers : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
[Space] [Header("World modification")] [Space]
|
||||
[Range(1,5)] public float voiceCommsMinDistance = 1.5f;
|
||||
|
|
|
@ -5,6 +5,8 @@ using UnityEngine.Events;
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
[AddComponentMenu("ChilloutVR/Combat System")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/")]
|
||||
public class CombatSystem : Health
|
||||
{
|
||||
[Header("General settings")]
|
||||
|
|
|
@ -3,7 +3,9 @@ using UnityEngine;
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class ControlPoint : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/Control Point")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/")]
|
||||
public class ControlPoint : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public GameInstanceController gameInstanceController;
|
||||
public string referenceID;
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class Damage : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/Damage")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/")]
|
||||
public class Damage : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public enum DamageType
|
||||
{
|
||||
|
@ -25,5 +27,11 @@ namespace ABI.CCK.Components
|
|||
public float healthMultiplier = 1f;
|
||||
public float armorMultiplier = 1f;
|
||||
public float shieldMultiplier = 1f;
|
||||
|
||||
[Header("Damage Falloff")]
|
||||
public bool enableFalloff = false;
|
||||
public float falloffDistance = 5f;
|
||||
public AnimationCurve falloffCurve = AnimationCurve.Linear(0f, 1f, 1f, 0f);
|
||||
public bool falloffEffectDamageOverTime;
|
||||
}
|
||||
}
|
30
Assets/ABI.CCK/Components/FPRExclusion.cs
Executable file
30
Assets/ABI.CCK/Components/FPRExclusion.cs
Executable file
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Manual exclusion component for the TransformHider (FPR) system.
|
||||
/// Allows you to manually hide and show renderers that would otherwise be hidden.
|
||||
/// Supports SkinnedMeshRenderer and MeshRenderer.
|
||||
/// A FPRExclusion is generated on the head bone, hidden by default, if it doesn't already exist.
|
||||
/// </summary>
|
||||
[DisallowMultipleComponent]
|
||||
public class FPRExclusion : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public bool isShown = true;
|
||||
public Transform target;
|
||||
public bool shrinkToZero = true;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[NonSerialized] // for gizmo drawing purposes only
|
||||
public readonly List<Transform> influencedTransforms = new();
|
||||
#endif
|
||||
}
|
||||
}
|
11
Assets/ABI.CCK/Components/FPRExclusion.cs.meta
Executable file
11
Assets/ABI.CCK/Components/FPRExclusion.cs.meta
Executable file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 96989618f2834a8ca3c910ce7f6f81c5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 8d4eaf52fbae23548874e96ac0d52276, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
155
Assets/ABI.CCK/Components/FluidVolume.cs
Executable file
155
Assets/ABI.CCK/Components/FluidVolume.cs
Executable file
|
@ -0,0 +1,155 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
[AddComponentMenu("ChilloutVR/Fluid Volume")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/")]
|
||||
public class FluidVolume : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public enum VolumeType
|
||||
{
|
||||
Box = 1,
|
||||
Sphere = 2
|
||||
}
|
||||
|
||||
public VolumeType volumeType = VolumeType.Box;
|
||||
|
||||
public Vector2 extend = new Vector2(10f, 10f);
|
||||
public float depth = 5f;
|
||||
public float density = 1f;
|
||||
|
||||
public bool placeFromCenter = false;
|
||||
|
||||
public enum StreamType
|
||||
{
|
||||
Directional = 1,
|
||||
Outwards = 2
|
||||
}
|
||||
|
||||
public StreamType streamType = StreamType.Directional;
|
||||
|
||||
public float streamAngle = 0f;
|
||||
public float streamStrength = 0f;
|
||||
|
||||
public ParticleSystem splashParticleSystem;
|
||||
|
||||
private BoxCollider _boxCollider;
|
||||
private SphereCollider _sphereCollider;
|
||||
private Vector3 _streamDirection = Vector3.zero;
|
||||
private Vector3 _streamDirectionSide = Vector3.zero;
|
||||
private float _streamTime = 0f;
|
||||
private Renderer _renderer;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
GameObject colliderObject = new GameObject("FluidTrigger");
|
||||
|
||||
colliderObject.layer = 4;
|
||||
|
||||
if (volumeType == VolumeType.Box)
|
||||
{
|
||||
colliderObject.transform.SetParent(transform);
|
||||
colliderObject.transform.localPosition = Vector3.zero;
|
||||
colliderObject.transform.localRotation = Quaternion.identity;
|
||||
colliderObject.transform.localScale = Vector3.one;
|
||||
_boxCollider = colliderObject.AddComponent<BoxCollider>();
|
||||
_boxCollider.isTrigger = true;
|
||||
if (placeFromCenter)
|
||||
_boxCollider.center = Vector3.zero;
|
||||
else
|
||||
_boxCollider.center = Vector3.down * depth * 0.5f;
|
||||
_boxCollider.size = new Vector3(extend.x, depth, extend.y);
|
||||
}
|
||||
|
||||
if (volumeType == VolumeType.Sphere)
|
||||
{
|
||||
colliderObject.transform.localScale = Vector3.one * Mathf.Max(transform.lossyScale.x,
|
||||
transform.lossyScale.y, transform.lossyScale.z);
|
||||
colliderObject.transform.SetParent(transform);
|
||||
colliderObject.transform.localPosition = Vector3.zero;
|
||||
colliderObject.transform.localRotation = Quaternion.identity;
|
||||
_sphereCollider = colliderObject.AddComponent<SphereCollider>();
|
||||
_sphereCollider.isTrigger = true;
|
||||
_sphereCollider.center = Vector3.zero;
|
||||
_sphereCollider.radius = depth;
|
||||
}
|
||||
|
||||
_renderer = GetComponent<Renderer>();
|
||||
if (_renderer == null) _renderer = GetComponentInChildren<Renderer>();
|
||||
|
||||
UpdateStreamDirection();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
_streamTime += streamStrength * Time.deltaTime;
|
||||
|
||||
UpdateStreamDirection();
|
||||
UpdateRenderer();
|
||||
}
|
||||
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
UpdateStreamDirection();
|
||||
UpdateRenderer(true);
|
||||
|
||||
Gizmos.color = new Color(1f, 1f, 1f, 0.4f);
|
||||
|
||||
if (volumeType == VolumeType.Box)
|
||||
{
|
||||
Gizmos.matrix = Matrix4x4.TRS(transform.position, transform.rotation, transform.lossyScale);
|
||||
if(placeFromCenter)
|
||||
Gizmos.DrawCube(Vector3.zero, new Vector3(extend.x, depth, extend.y));
|
||||
else
|
||||
Gizmos.DrawCube(Vector3.down * depth * 0.4999999f, new Vector3(extend.x, depth, extend.y));
|
||||
}
|
||||
|
||||
if (volumeType == VolumeType.Sphere)
|
||||
{
|
||||
Gizmos.matrix = Matrix4x4.TRS(transform.position, transform.rotation,
|
||||
Vector3.one * Mathf.Max(transform.lossyScale.x, transform.lossyScale.y, transform.lossyScale.z));
|
||||
Gizmos.DrawSphere(Vector3.zero, depth);
|
||||
Gizmos.DrawWireSphere(Vector3.zero, depth);
|
||||
}
|
||||
|
||||
if (streamStrength == 0f) return;
|
||||
|
||||
var size = Mathf.Min(extend.x, extend.y) * 0.1f;
|
||||
var length = size * (Mathf.Min(Mathf.Abs(streamStrength), 5f) * 0.05f);
|
||||
|
||||
var localDirection =
|
||||
transform.InverseTransformDirection(_streamDirection * (streamStrength < 0f ? -1f : 1f));
|
||||
var localDirectionSide =
|
||||
transform.InverseTransformDirection(_streamDirectionSide * (streamStrength < 0f ? -1f : 1f));
|
||||
Gizmos.DrawLine((localDirection * 2f + localDirectionSide * 2f) * -size,
|
||||
localDirection * 4f * size * length);
|
||||
Gizmos.DrawLine((localDirection * 2f + localDirectionSide * -2f) * -size,
|
||||
localDirection * 4f * size * length);
|
||||
Gizmos.DrawLine((localDirection * 2f + localDirectionSide * 2f) * -size, localDirection * -1f * size);
|
||||
Gizmos.DrawLine((localDirection * 2f + localDirectionSide * -2f) * -size, localDirection * -1f * size);
|
||||
}
|
||||
|
||||
private void UpdateRenderer(bool get = false)
|
||||
{
|
||||
if (get) _renderer = GetComponent<Renderer>();
|
||||
|
||||
if (_renderer != null)
|
||||
{
|
||||
_renderer.sharedMaterial.SetVector("_StreamDirection", _streamDirection);
|
||||
_renderer.sharedMaterial.SetFloat("_StreamStrength", streamStrength);
|
||||
_renderer.sharedMaterial.SetFloat("_StreamTime", _streamTime);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateStreamDirection()
|
||||
{
|
||||
Quaternion rot = Quaternion.AngleAxis(streamAngle, Vector3.up);
|
||||
Vector3 lDirection = rot * Vector3.forward;
|
||||
_streamDirection = transform.TransformDirection(lDirection);
|
||||
lDirection = rot * Vector3.right;
|
||||
_streamDirectionSide = transform.TransformDirection(lDirection);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/ABI.CCK/Components/FluidVolume.cs.meta
Executable file
11
Assets/ABI.CCK/Components/FluidVolume.cs.meta
Executable file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 260f38008cc04916ab827ca7d38c7865
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 8d4eaf52fbae23548874e96ac0d52276, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
25
Assets/ABI.CCK/Components/ForceApplicator.cs
Executable file
25
Assets/ABI.CCK/Components/ForceApplicator.cs
Executable file
|
@ -0,0 +1,25 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
[AddComponentMenu("ChilloutVR/Force Applicator")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/")]
|
||||
public class ForceApplicator : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public Rigidbody target;
|
||||
public Vector3 forceVector;
|
||||
public float strength;
|
||||
public bool onlyWhenSubmerged;
|
||||
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
if (isActiveAndEnabled)
|
||||
{
|
||||
Gizmos.color = Color.yellow;
|
||||
Matrix4x4 rotationMatrix = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one);
|
||||
Gizmos.matrix = rotationMatrix;
|
||||
Gizmos.DrawLine(Vector3.zero, forceVector * Mathf.Max(strength * 0.001f, 0.25f));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/ABI.CCK/Components/ForceApplicator.cs.meta
Executable file
11
Assets/ABI.CCK/Components/ForceApplicator.cs.meta
Executable file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cfa2d3fd5b564c4f923e1963652b46a3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 8d4eaf52fbae23548874e96ac0d52276, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -5,7 +5,9 @@ using UnityEngine.Events;
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class GameInstanceController: MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/Game Instance Controller")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/")]
|
||||
public class GameInstanceController: MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public string referenceID;
|
||||
|
||||
|
@ -38,7 +40,9 @@ namespace ABI.CCK.Components
|
|||
{
|
||||
Score = 0,
|
||||
Time = 1,
|
||||
TimeAndScore = 2,
|
||||
TimeOrScore = 2,
|
||||
Elimination = 3,
|
||||
TimeOrElimination = 4,
|
||||
}
|
||||
|
||||
public EndCondition endCondition = EndCondition.Score;
|
||||
|
|
125
Assets/ABI.CCK/Components/GravityZone.cs
Executable file
125
Assets/ABI.CCK/Components/GravityZone.cs
Executable file
|
@ -0,0 +1,125 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
[AddComponentMenu("ChilloutVR/Gravity Zone")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/")]
|
||||
public class GravityZone : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public enum ZoneShape
|
||||
{
|
||||
Box = 1,
|
||||
Sphere = 2,
|
||||
Capsule = 3,
|
||||
Cylinder = 4,
|
||||
HalfSphere = 5,
|
||||
QuarterSphere = 6,
|
||||
HalfCapsule = 7,
|
||||
QuarterCapsule = 8,
|
||||
HalfCylinder = 9,
|
||||
QuarterCylinder = 10,
|
||||
Custom = 11
|
||||
}
|
||||
|
||||
public ZoneShape zoneShape = ZoneShape.Box;
|
||||
public Mesh customZoneShapeMesh; // used for custom shape
|
||||
|
||||
public Vector3 center;
|
||||
public Vector3 size = Vector3.one;
|
||||
|
||||
public enum GravityDirection
|
||||
{
|
||||
DirectionX = 1,
|
||||
DirectionY = 2,
|
||||
DirectionZ = 3,
|
||||
TowardsCenter = 4,
|
||||
}
|
||||
|
||||
public GravityDirection gravityDirection = GravityDirection.DirectionY;
|
||||
|
||||
public enum GravityMix
|
||||
{
|
||||
Override = 1,
|
||||
Additive = 2
|
||||
}
|
||||
|
||||
public GravityMix gravityMix = GravityMix.Override;
|
||||
|
||||
public int priority = 0;
|
||||
|
||||
public enum GravityType
|
||||
{
|
||||
Absolute = 1,
|
||||
Relative = 2
|
||||
}
|
||||
|
||||
public GravityType gravityType = GravityType.Absolute;
|
||||
|
||||
private const float MaxGravityStrength = 10000f;
|
||||
public float strength = 9.81f;
|
||||
|
||||
[Flags]
|
||||
public enum GravityEffect
|
||||
{
|
||||
Objects = 1,
|
||||
Players = 2
|
||||
}
|
||||
|
||||
public GravityEffect gravityEffect = GravityEffect.Objects | GravityEffect.Players;
|
||||
|
||||
public AnimationCurve gravityFalloff = AnimationCurve.Linear(0f, 1f, 1f, 1f);
|
||||
|
||||
/// <summary>
|
||||
/// Player alignment mode options for gravity zone.
|
||||
/// </summary>
|
||||
public enum PlayerAlignmentMode
|
||||
{
|
||||
/// <summary>
|
||||
/// It will align the player respecting the gravity strength. When using this setting the alignment speed
|
||||
/// can be overwritten by the player settings. This is recommended unless there is a strong reason not to.
|
||||
/// </summary>
|
||||
Auto = 0,
|
||||
/// <summary>
|
||||
/// The player will not be aligned with gravity. And will have the same controls are in 0 g.
|
||||
/// </summary>
|
||||
Disabled = 1,
|
||||
/// <summary>
|
||||
/// The player will be aligned instantly with the gravity.
|
||||
/// </summary>
|
||||
Instantly = 2,
|
||||
/// <summary>
|
||||
/// The player will be aligned at a constant speed of degrees per second set on the custom value.
|
||||
/// </summary>
|
||||
Custom = 3,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Max value for playerCustomAlignmentDegreesPerSecond.
|
||||
/// </summary>
|
||||
public const float MaxDegreesPerSecond = 3600f;
|
||||
|
||||
public const PlayerAlignmentMode DefaultGravityAlignmentMode = PlayerAlignmentMode.Auto;
|
||||
|
||||
public const float DefaultGravityCustomAlignmentValue = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Mode to use to align players with the current gravity direction.
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
public PlayerAlignmentMode playerGravityAlignmentMode = DefaultGravityAlignmentMode;
|
||||
|
||||
/// <summary>
|
||||
/// Value used for the gravity player alignment speed when using the custom alignment mode.
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
public float playerGravityCustomAlignmentValue = DefaultGravityCustomAlignmentValue;
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
// using Range attribute turns it into an ugly slider, enforced by client
|
||||
strength = Mathf.Clamp(strength, -MaxGravityStrength, MaxGravityStrength);
|
||||
playerGravityCustomAlignmentValue = Mathf.Clamp(playerGravityCustomAlignmentValue, 0, MaxDegreesPerSecond);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/ABI.CCK/Components/GravityZone.cs.meta
Executable file
11
Assets/ABI.CCK/Components/GravityZone.cs.meta
Executable file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2e5dd14312614cdb815c6c1e216cf10c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 8d4eaf52fbae23548874e96ac0d52276, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -3,12 +3,14 @@ using UnityEngine;
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class GunController : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/Gun Controller")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/")]
|
||||
public class GunController : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
[ReadOnly]
|
||||
public string referenceID;
|
||||
|
||||
public ParticleSystem particleSystem;
|
||||
public new ParticleSystem particleSystem;
|
||||
public List<AudioClip> shootSounds = new List<AudioClip>();
|
||||
public List<AudioClip> reloadSounds = new List<AudioClip>();
|
||||
public List<AudioClip> emptyShootSounds = new List<AudioClip>();
|
||||
|
|
8
Assets/ABI.CCK/Components/Interface.meta
Executable file
8
Assets/ABI.CCK/Components/Interface.meta
Executable file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 163bc28eb81fee94bab103ae6f31a73d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/ABI.CCK/Components/Interface/ICCK_Component.cs
Executable file
9
Assets/ABI.CCK/Components/Interface/ICCK_Component.cs
Executable file
|
@ -0,0 +1,9 @@
|
|||
namespace ABI.CCK.Components
|
||||
{
|
||||
// TODO: Replace with Attribute, we dont need to use an interface for this
|
||||
public interface ICCK_Component
|
||||
{
|
||||
// This is a marker interface, it has no members.
|
||||
// CVRComponentRegistry & CVR_GizmoFix
|
||||
}
|
||||
}
|
11
Assets/ABI.CCK/Components/Interface/ICCK_Component.cs.meta
Executable file
11
Assets/ABI.CCK/Components/Interface/ICCK_Component.cs.meta
Executable file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f02e3db2e5f95054d92b7ff0d550ae8b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -5,7 +5,9 @@ using UnityEngine.Events;
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class ObjectHealth : Health
|
||||
[AddComponentMenu("ChilloutVR/Object Health")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/")]
|
||||
public class ObjectHealth : Health, ICCK_Component
|
||||
{
|
||||
public enum DownBehavior
|
||||
{
|
||||
|
@ -25,6 +27,7 @@ namespace ABI.CCK.Components
|
|||
[Header("Events")]
|
||||
public UnityEvent downEvent = new UnityEvent();
|
||||
public UnityEvent respawnEvent = new UnityEvent();
|
||||
//public new UnityEvent damageReceivedEvent = new UnityEvent();
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
|
|
80
Assets/ABI.CCK/Components/PhysicsInfluencer.cs
Executable file
80
Assets/ABI.CCK/Components/PhysicsInfluencer.cs
Executable file
|
@ -0,0 +1,80 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
[AddComponentMenu("ChilloutVR/Physics Influencer")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/")]
|
||||
[RequireComponent(typeof(Rigidbody), typeof(Collider))]
|
||||
public class PhysicsInfluencer : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public bool guiCenterOfMassFoldout;
|
||||
public bool changeCenterOfMass;
|
||||
|
||||
public Transform centerOfMass;
|
||||
public bool updateContinuously;
|
||||
|
||||
|
||||
public bool guiBuoyancyFoldout;
|
||||
public bool enableBuoyancy = false;
|
||||
|
||||
public float density;
|
||||
public float volume;
|
||||
|
||||
public float airDrag = 0f;
|
||||
public float airAngularDrag = 0.05f;
|
||||
|
||||
public float fluidDrag = 3f;
|
||||
public float fluidAngularDrag = 1f;
|
||||
|
||||
|
||||
public bool guiGravityFoldout;
|
||||
public bool enableLocalGravity;
|
||||
|
||||
public bool forceAlignUpright;
|
||||
|
||||
|
||||
public bool guiMovementParentFoldout;
|
||||
public bool enableMovementParent;
|
||||
|
||||
public bool ignoreForcesWhileParented;
|
||||
|
||||
private Rigidbody _rigidbody;
|
||||
private Collider[] _colliders;
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
UpdateDensity();
|
||||
}
|
||||
|
||||
public void UpdateDensity()
|
||||
{
|
||||
_rigidbody = GetComponent<Rigidbody>();
|
||||
|
||||
float mass = _rigidbody.mass;
|
||||
_rigidbody.SetDensity(1f);
|
||||
volume = _rigidbody.mass;
|
||||
density = (mass / 1000f) / volume;
|
||||
|
||||
_rigidbody.mass = mass;
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
_rigidbody = GetComponent<Rigidbody>();
|
||||
|
||||
if (changeCenterOfMass && centerOfMass != null)
|
||||
{
|
||||
_rigidbody.centerOfMass = transform.InverseTransformPoint(centerOfMass.position);
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/ABI.CCK/Components/PhysicsInfluencer.cs.meta
Executable file
11
Assets/ABI.CCK/Components/PhysicsInfluencer.cs.meta
Executable file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d9078deea7194f13a9264e906ab6e576
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 8d4eaf52fbae23548874e96ac0d52276, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -4,7 +4,9 @@ using UnityEngine;
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class PlayerMaterialParser : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/Player Material Parser")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/")]
|
||||
public class PlayerMaterialParser : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public Material targetMaterial;
|
||||
|
||||
|
|
|
@ -5,7 +5,9 @@ using UnityEngine.UI;
|
|||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class ScoreBoardController : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/Score Board Controller")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/")]
|
||||
public class ScoreBoardController : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public GameInstanceController gameInstanceController;
|
||||
|
||||
|
|
8
Assets/ABI.CCK/Components/ScriptableObjects.meta
Executable file
8
Assets/ABI.CCK/Components/ScriptableObjects.meta
Executable file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: db2945a9a68885940a8e5e258278ba60
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
64
Assets/ABI.CCK/Components/ScriptableObjects/CVRLuaScript.cs
Executable file
64
Assets/ABI.CCK/Components/ScriptableObjects/CVRLuaScript.cs
Executable file
|
@ -0,0 +1,64 @@
|
|||
using System.IO;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
using UnityEngine;
|
||||
|
||||
namespace ABI.CCK.Components.ScriptableObjects
|
||||
{
|
||||
public class CVRLuaScript : UnityEngine.ScriptableObject
|
||||
{
|
||||
#region Constants and Statics
|
||||
|
||||
public const string kLuaScriptIdentifier = "cvr_lua_script";
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public static Texture2D s_LuaScriptIcon => _luaScriptIcon
|
||||
? _luaScriptIcon
|
||||
: _luaScriptIcon =
|
||||
AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/ABI.CCK/GUIAssets/LuaScriptThumbnail2.png");
|
||||
|
||||
private static Texture2D _luaScriptIcon;
|
||||
#endif
|
||||
#endregion
|
||||
|
||||
public string m_ScriptPath;
|
||||
public string m_ScriptText;
|
||||
|
||||
// helper methods or something
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[CustomEditor(typeof(CVRLuaScript))]
|
||||
public class CVRLuaScriptEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
CVRLuaScript asset = target as CVRLuaScript;
|
||||
if (asset is null)
|
||||
return;
|
||||
|
||||
EditorGUILayout.LabelField("Name", asset.name);
|
||||
EditorGUILayout.LabelField("Script Path", asset.m_ScriptPath);
|
||||
if (!string.IsNullOrEmpty(asset.m_ScriptText)) EditorGUILayout.TextArea(asset.m_ScriptText);
|
||||
|
||||
GUI.enabled = true;
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
if (GUILayout.Button("Open in External Editor"))
|
||||
{
|
||||
string assetPath = AssetDatabase.GetAssetPath(asset);
|
||||
var fullPath = Path.GetFullPath(assetPath);
|
||||
EditorUtility.OpenWithDefaultApp(fullPath);
|
||||
}
|
||||
|
||||
//TODO
|
||||
// if (GUILayout.Button("Obfuscate Script"))
|
||||
// Debug.Log("Obfuscating script...");
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
GUI.enabled = false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
11
Assets/ABI.CCK/Components/ScriptableObjects/CVRLuaScript.cs.meta
Executable file
11
Assets/ABI.CCK/Components/ScriptableObjects/CVRLuaScript.cs.meta
Executable file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f9d2209bbfb16ab4d91c3f7e94fcaf7e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 016a3f6a44983164e9ffa8e5e466016d, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,10 +1,15 @@
|
|||
using UnityEngine;
|
||||
using JetBrains.Annotations;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class SpawnablePickupMarker : MonoBehaviour
|
||||
[AddComponentMenu("ChilloutVR/Spawnable Pickup Marker")]
|
||||
[HelpURL("https://developers.abinteractive.net/cck/")]
|
||||
public class SpawnablePickupMarker : MonoBehaviour, ICCK_Component
|
||||
{
|
||||
public string spawnableGuid;
|
||||
|
||||
#region Unity Events
|
||||
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
|
@ -23,5 +28,23 @@ namespace ABI.CCK.Components
|
|||
Gizmos.matrix = rotationMatrix;
|
||||
Gizmos.DrawWireSphere(new Vector3(0, 1.11f, 0), 0.31f);
|
||||
}
|
||||
|
||||
#endregion Unity Events
|
||||
|
||||
#region Public Methods
|
||||
|
||||
[PublicAPI]
|
||||
public void ShowSpawnableDetailsPage()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public void SelectSpawnableForSpawn()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
105
Assets/ABI.CCK/Components/StateMachineCallbackSender.cs
Executable file
105
Assets/ABI.CCK/Components/StateMachineCallbackSender.cs
Executable file
|
@ -0,0 +1,105 @@
|
|||
using JetBrains.Annotations;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace ABI.CCK.Components
|
||||
{
|
||||
public class StateMachineCallbackSender : StateMachineBehaviour
|
||||
{
|
||||
#region UnityEvents
|
||||
|
||||
[PublicAPI] public static readonly UnityEvent<Animator, StateMachineCallbackSender> OnInitialized = new();
|
||||
[PublicAPI] public static readonly UnityEvent<Animator, StateMachineCallbackSender> OnExecuteEnterTask = new();
|
||||
[PublicAPI] public static readonly UnityEvent<Animator, StateMachineCallbackSender> OnExecuteExitTask = new();
|
||||
|
||||
#endregion
|
||||
|
||||
public bool localOnly = true;
|
||||
|
||||
private bool _initialized;
|
||||
|
||||
#region Unity Events
|
||||
|
||||
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
if (!_initialized) Initialize(animator);
|
||||
OnExecuteEnterTask.Invoke(animator, this);
|
||||
}
|
||||
|
||||
public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
if (!_initialized) Initialize(animator);
|
||||
OnExecuteExitTask.Invoke(animator, this);
|
||||
}
|
||||
|
||||
#endregion Unity Events
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void Initialize(Animator animator)
|
||||
{
|
||||
_initialized = true;
|
||||
OnInitialized.Invoke(animator, this);
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[CustomEditor(typeof(StateMachineCallbackSender))]
|
||||
public class StateMachineCallbackSenderEditor : Editor
|
||||
{
|
||||
private StateMachineCallbackSender _sender;
|
||||
|
||||
private bool _showLocalOnlyHelp;
|
||||
|
||||
private SerializedProperty _localOnly;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_sender = (StateMachineCallbackSender)target;
|
||||
if (_sender == null)
|
||||
return;
|
||||
|
||||
_localOnly = serializedObject.FindProperty("localOnly");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
if (_sender == null)
|
||||
return;
|
||||
|
||||
serializedObject.Update();
|
||||
|
||||
using (new EditorGUILayout.VerticalScope(new GUIStyle() { padding = new RectOffset(10, 10, 10, 10) }))
|
||||
{
|
||||
DrawLocalOnlyToggle();
|
||||
EditorGUILayout.HelpBox(
|
||||
"This behaviour will send the following state machine callbacks to any listening receviers: OnStateMachineEnter, OnStateMachineExit",
|
||||
MessageType.Info);
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
private void DrawLocalOnlyToggle()
|
||||
{
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
EditorGUILayout.PropertyField(_localOnly);
|
||||
if (GUILayout.Button("?", GUILayout.Width(25)))
|
||||
_showLocalOnlyHelp = !_showLocalOnlyHelp;
|
||||
GUILayout.Space(5);
|
||||
}
|
||||
if (_showLocalOnlyHelp)
|
||||
{
|
||||
EditorGUILayout.HelpBox("When 'Local Only' is enabled, the animator driver is executed locally and not for remote users.", MessageType.Info);
|
||||
EditorGUILayout.Space(5);
|
||||
EditorGUILayout.HelpBox("Avatars: Only the wearer.\nSpawnables: Only the prop's owner.\nWorlds: This option is ignored.", MessageType.Info);
|
||||
}
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
11
Assets/ABI.CCK/Components/StateMachineCallbackSender.cs.meta
Executable file
11
Assets/ABI.CCK/Components/StateMachineCallbackSender.cs.meta
Executable file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1f35791917ec48529cb942ba2598bbd0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 8d4eaf52fbae23548874e96ac0d52276, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue