Update
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 92dd769e36bd4fa4389e2236fea92cd9
|
||||
folderAsset: yes
|
||||
timeCreated: 1435613876
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4a686c3a9f8ed2d4eb8f3bf7a05ab8dd
|
||||
folderAsset: yes
|
||||
timeCreated: 1447174086
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ab2fdc170bbb884a9b388a703396cca
|
||||
folderAsset: yes
|
||||
timeCreated: 1447113239
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,221 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Invector
|
||||
{
|
||||
[CustomEditor(typeof(vCullingFadeControl))]
|
||||
public class vCullingFadeControlEditor : UnityEditor.Editor
|
||||
{
|
||||
GUISkin skin;
|
||||
vCullingFadeControl _fadeControl { get { return (vCullingFadeControl)target; } }
|
||||
private Texture2D m_Logo = null;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
m_Logo = (Texture2D)Resources.Load("icon_v2", typeof(Texture2D));
|
||||
}
|
||||
|
||||
void OnSceneGUI()
|
||||
{
|
||||
if (!_fadeControl.targetObject) return;
|
||||
var tpos = (_fadeControl.targetObject.position + _fadeControl.offset);
|
||||
Handles.color = new Color(1, 1, 1, 0.5f);
|
||||
Handles.SphereHandleCap(0, tpos, Quaternion.identity, 0.1f, EventType.Ignore);
|
||||
Ray ray = new Ray(tpos, _fadeControl.cameraTransform.position - tpos);
|
||||
Handles.DrawLine(tpos, ray.GetPoint(_fadeControl.distanceToEndFade));
|
||||
Handles.color = (_fadeControl.distanceToEndFade < _fadeControl.distanceToStartFade) ? Color.green : Color.red;
|
||||
Handles.DrawAAPolyLine(10f, new Vector3[] { ray.GetPoint(_fadeControl.distanceToEndFade), ray.GetPoint(_fadeControl.distanceToStartFade) });
|
||||
Handles.CubeHandleCap(0, ray.GetPoint(_fadeControl.distanceToEndFade), Quaternion.LookRotation(_fadeControl.cameraTransform.position - ray.GetPoint(_fadeControl.distanceToEndFade)), 0.05f, EventType.Ignore);
|
||||
Handles.ConeHandleCap(0, ray.GetPoint(_fadeControl.distanceToStartFade), Quaternion.LookRotation(ray.GetPoint(_fadeControl.distanceToStartFade) - _fadeControl.cameraTransform.position), 0.1f, EventType.Ignore);
|
||||
Handles.color = new Color(1, 1, 1, 0.5f);
|
||||
Handles.DrawLine(ray.GetPoint(_fadeControl.distanceToStartFade), _fadeControl.cameraTransform.position);
|
||||
Handles.DrawPolyLine(new Vector3[] { ray.GetPoint(_fadeControl.distanceToEndFade), ray.GetPoint(_fadeControl.distanceToStartFade) });
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
if (!skin) skin = Resources.Load("vSkin") as GUISkin;
|
||||
GUI.skin = skin;
|
||||
|
||||
GUILayout.BeginVertical("Culling Fade", "window");
|
||||
GUILayout.Label(m_Logo, GUILayout.MaxHeight(25));
|
||||
GUILayout.Space(10);
|
||||
|
||||
base.OnInspectorGUI();
|
||||
if (!Application.isPlaying)
|
||||
CheckRenderers();
|
||||
GUILayout.BeginHorizontal("box", GUILayout.ExpandHeight(false));
|
||||
|
||||
GUILayout.BeginVertical(GUILayout.ExpandHeight(false));
|
||||
if (_fadeControl.fadeMeshRenderers != null && _fadeControl.fadeMeshRenderers.Count > 0)
|
||||
{
|
||||
for (int a = 0; a < _fadeControl.fadeMeshRenderers.Count; a++)
|
||||
{
|
||||
EditorGUILayout.ObjectField("Renderer", _fadeControl.fadeMeshRenderers[a].renderer, typeof(Renderer), true);
|
||||
var renderer = _fadeControl.fadeMeshRenderers[a].renderer as MeshRenderer;
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
GUILayout.BeginVertical("window", GUILayout.ExpandHeight(false));
|
||||
|
||||
for (int b = 0; b < renderer.sharedMaterials.Length; b++)
|
||||
renderer.sharedMaterials[b] = (Material)EditorGUILayout.ObjectField(renderer.sharedMaterials[b], typeof(Material), false);
|
||||
|
||||
GUILayout.EndVertical();
|
||||
|
||||
GUILayout.BeginVertical("window", GUILayout.ExpandHeight(false));
|
||||
|
||||
for (int b = 0; b < _fadeControl.fadeMeshRenderers[a].fadeMaterials.Length; b++)
|
||||
_fadeControl.fadeMeshRenderers[a].fadeMaterials[b] = (Material)EditorGUILayout.ObjectField(_fadeControl.fadeMeshRenderers[a].fadeMaterials[b], typeof(Material), false);
|
||||
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
|
||||
if (_fadeControl.fadeSkinnedMeshRenderes != null && _fadeControl.fadeSkinnedMeshRenderes.Count > 0)
|
||||
{
|
||||
for (int a = 0; a < _fadeControl.fadeSkinnedMeshRenderes.Count; a++)
|
||||
{
|
||||
EditorGUILayout.ObjectField("Renderer", _fadeControl.fadeSkinnedMeshRenderes[a].renderer, typeof(Renderer), true);
|
||||
var renderer = _fadeControl.fadeSkinnedMeshRenderes[a].renderer as SkinnedMeshRenderer;
|
||||
GUILayout.BeginHorizontal(GUILayout.ExpandHeight(false));
|
||||
|
||||
GUILayout.BeginVertical("box", GUILayout.ExpandHeight(false));
|
||||
GUILayout.Label("Original Material");
|
||||
for (int b = 0; b < renderer.sharedMaterials.Length; b++)
|
||||
renderer.sharedMaterials[b] = (Material)EditorGUILayout.ObjectField(renderer.sharedMaterials[b], typeof(Material), false);
|
||||
|
||||
GUILayout.EndVertical();
|
||||
|
||||
GUILayout.BeginVertical("box", GUILayout.ExpandHeight(false));
|
||||
GUILayout.Label("Optional Fade");
|
||||
|
||||
for (int b = 0; b < _fadeControl.fadeSkinnedMeshRenderes[a].fadeMaterials.Length; b++)
|
||||
_fadeControl.fadeSkinnedMeshRenderes[a].fadeMaterials[b] = (Material)EditorGUILayout.ObjectField(_fadeControl.fadeSkinnedMeshRenderes[a].fadeMaterials[b], typeof(Material), false);
|
||||
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.HelpBox("Your material has to be Transparent or Fade, you will also need to change the Z-write (check documentation for more information)", MessageType.Info);
|
||||
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.EndVertical();
|
||||
if (GUI.changed)
|
||||
EditorUtility.SetDirty(_fadeControl);
|
||||
}
|
||||
|
||||
[MenuItem("Invector/Basic Locomotion/Components/Culling Fade")]
|
||||
static void MenuComponent()
|
||||
{
|
||||
Selection.activeGameObject.AddComponent<vCullingFadeControl>();
|
||||
}
|
||||
|
||||
public void CheckRenderers()
|
||||
{
|
||||
if (_fadeControl.targetObject == null) return;
|
||||
var meshRenderers = _fadeControl.targetObject.GetComponentsInChildren<MeshRenderer>(true);
|
||||
|
||||
if (_fadeControl.fadeMeshRenderers == null)
|
||||
_fadeControl.fadeMeshRenderers = new List<FadeMaterials>();
|
||||
|
||||
if (_fadeControl.fadeMeshRenderers.Count != meshRenderers.Length)
|
||||
{
|
||||
_fadeControl.fadeMeshRenderers.Resize(meshRenderers.Length);
|
||||
EditorUtility.SetDirty(_fadeControl);
|
||||
}
|
||||
|
||||
for (int i = 0; i < meshRenderers.Length; i++)
|
||||
{
|
||||
if (_fadeControl.fadeMeshRenderers[i] == null)
|
||||
_fadeControl.fadeMeshRenderers[i] = new FadeMaterials();
|
||||
if (_fadeControl.fadeMeshRenderers[i].renderer == null || (_fadeControl.fadeMeshRenderers[i].renderer != null && _fadeControl.fadeMeshRenderers[i].renderer != (meshRenderers[i] as Renderer)))
|
||||
_fadeControl.fadeMeshRenderers[i].renderer = meshRenderers[i] as Renderer;
|
||||
if (_fadeControl.fadeMeshRenderers[i].originalMaterials == null || (_fadeControl.fadeMeshRenderers[i].originalMaterials != null && _fadeControl.fadeMeshRenderers[i].originalMaterials != meshRenderers[i].sharedMaterials))
|
||||
_fadeControl.fadeMeshRenderers[i].originalMaterials = meshRenderers[i].sharedMaterials;
|
||||
if (_fadeControl.fadeMeshRenderers[i].fadeMaterials == null)
|
||||
_fadeControl.fadeMeshRenderers[i].fadeMaterials = new Material[meshRenderers[i].sharedMaterials.Length];
|
||||
else if (_fadeControl.fadeMeshRenderers[i].fadeMaterials.Length != meshRenderers[i].sharedMaterials.Length)
|
||||
Array.Resize(ref _fadeControl.fadeMeshRenderers[i].fadeMaterials, meshRenderers[i].sharedMaterials.Length);
|
||||
}
|
||||
|
||||
var skinnedRenderers = _fadeControl.targetObject.GetComponentsInChildren<SkinnedMeshRenderer>(true);
|
||||
if (_fadeControl.fadeSkinnedMeshRenderes == null)
|
||||
_fadeControl.fadeSkinnedMeshRenderes = new List<FadeMaterials>();
|
||||
if (_fadeControl.fadeSkinnedMeshRenderes.Count != skinnedRenderers.Length)
|
||||
{
|
||||
_fadeControl.fadeSkinnedMeshRenderes.Resize(skinnedRenderers.Length);
|
||||
EditorUtility.SetDirty(_fadeControl);
|
||||
}
|
||||
|
||||
for (int i = 0; i < skinnedRenderers.Length; i++)
|
||||
{
|
||||
if (_fadeControl.fadeSkinnedMeshRenderes[i] == null)
|
||||
_fadeControl.fadeSkinnedMeshRenderes[i] = new FadeMaterials();
|
||||
if (_fadeControl.fadeSkinnedMeshRenderes[i].renderer == null || (_fadeControl.fadeSkinnedMeshRenderes[i].renderer != null && _fadeControl.fadeSkinnedMeshRenderes[i].renderer != (skinnedRenderers[i] as Renderer)))
|
||||
_fadeControl.fadeSkinnedMeshRenderes[i].renderer = skinnedRenderers[i] as Renderer;
|
||||
if (_fadeControl.fadeSkinnedMeshRenderes[i].originalMaterials == null || (_fadeControl.fadeSkinnedMeshRenderes[i].originalMaterials != null && _fadeControl.fadeSkinnedMeshRenderes[i].originalMaterials != skinnedRenderers[i].sharedMaterials))
|
||||
_fadeControl.fadeSkinnedMeshRenderes[i].originalMaterials = skinnedRenderers[i].sharedMaterials;
|
||||
if (_fadeControl.fadeSkinnedMeshRenderes[i].fadeMaterials == null)
|
||||
_fadeControl.fadeSkinnedMeshRenderes[i].fadeMaterials = new Material[skinnedRenderers[i].sharedMaterials.Length];
|
||||
else if (_fadeControl.fadeSkinnedMeshRenderes[i].fadeMaterials.Length != skinnedRenderers[i].sharedMaterials.Length)
|
||||
Array.Resize(ref _fadeControl.fadeSkinnedMeshRenderes[i].fadeMaterials, skinnedRenderers[i].sharedMaterials.Length);
|
||||
}
|
||||
}
|
||||
|
||||
#region Control Zwrite of Standard Material
|
||||
[MenuItem("Assets/Change Zwrite of Standard Material")]
|
||||
private static void ChangeZWRITE()
|
||||
{
|
||||
var material = Selection.activeObject as Material;
|
||||
if (material != null)
|
||||
{
|
||||
if (material.GetInt("_ZWrite") == 0)
|
||||
material.SetInt("_ZWrite", 1);
|
||||
else
|
||||
material.SetInt("_ZWrite", 0);
|
||||
}
|
||||
}
|
||||
|
||||
[MenuItem("Assets/Change Zwrite of Standard Material", true)]
|
||||
private static bool ValidateChangeZWRITE()
|
||||
{
|
||||
var material = Selection.activeObject as Material;
|
||||
|
||||
if (material != null)
|
||||
{
|
||||
if (material.HasProperty("_ZWrite") && material.HasProperty("_Mode"))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public static class ListExtras
|
||||
{
|
||||
// list: List<T> to resize
|
||||
// size: desired new size
|
||||
// element: default value to insert
|
||||
|
||||
public static void Resize<T>(this List<T> list, int size, T element = default(T))
|
||||
{
|
||||
int count = list.Count;
|
||||
|
||||
if (size < count)
|
||||
list.RemoveRange(size, count - size);
|
||||
else if (size > count)
|
||||
{
|
||||
if (size > list.Capacity) // Optimization
|
||||
list.Capacity = size;
|
||||
|
||||
list.AddRange(Enumerable.Repeat(element, size - count));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 36123cd109b63014dbd11dde53228cec
|
||||
timeCreated: 1447113256
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,199 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Invector
|
||||
{
|
||||
public class vCullingFadeControl : MonoBehaviour
|
||||
{
|
||||
public Transform targetObject
|
||||
{
|
||||
get
|
||||
{
|
||||
Transform cT = transform;
|
||||
return cT;
|
||||
}
|
||||
}
|
||||
|
||||
public float distanceToStartFade = 0.55f;
|
||||
public float distanceToEndFade = 0.4f;
|
||||
public Vector3 offset = new Vector3(0, 1.3f, 0);
|
||||
|
||||
// [HideInInspector]
|
||||
public List<FadeMaterials> fadeMeshRenderers;
|
||||
// [HideInInspector]
|
||||
public List<FadeMaterials> fadeSkinnedMeshRenderes;
|
||||
// [HideInInspector]
|
||||
public bool usingTransp;
|
||||
|
||||
public Transform cameraTransform
|
||||
{
|
||||
get
|
||||
{
|
||||
Transform cT = transform;
|
||||
if (Camera.main != null)
|
||||
cT = Camera.main.transform;
|
||||
if (cT == transform)
|
||||
{
|
||||
Debug.LogWarning("Invector : Missing MainCamera");
|
||||
this.enabled = false;
|
||||
}
|
||||
return cT;
|
||||
}
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
foreach (FadeMaterials fd in fadeMeshRenderers)
|
||||
{
|
||||
fd.originalAlpha = new float[fd.originalMaterials.Length];
|
||||
for (int i = 0; i < fd.originalMaterials.Length; i++)
|
||||
{
|
||||
if (fd.fadeMaterials[i] == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
fd.originalAlpha[i] = fd.originalMaterials[i].color.a;
|
||||
fd.fadeMaterials[i] = fd.originalMaterials[i];
|
||||
}
|
||||
catch { }
|
||||
|
||||
}
|
||||
else try { fd.originalAlpha[i] = fd.fadeMaterials[i].color.a; } catch { }
|
||||
}
|
||||
}
|
||||
|
||||
foreach (FadeMaterials fd in fadeSkinnedMeshRenderes)
|
||||
{
|
||||
fd.originalAlpha = new float[fd.originalMaterials.Length];
|
||||
for (int i = 0; i < fd.originalMaterials.Length; i++)
|
||||
{
|
||||
if (fd.fadeMaterials[i] == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
fd.originalAlpha[i] = fd.originalMaterials[i].color.a;
|
||||
fd.fadeMaterials[i] = fd.originalMaterials[i];
|
||||
}
|
||||
catch { }
|
||||
|
||||
}
|
||||
else try { fd.originalAlpha[i] = fd.fadeMaterials[i].color.a; } catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
UpdateEffect();
|
||||
|
||||
if (usingTransp)
|
||||
ChangeAlphaFromDistance();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the effect to check if use fade or not
|
||||
/// </summary>
|
||||
private void UpdateEffect()
|
||||
{
|
||||
var currentDist = Vector3.Distance(cameraTransform.position, (targetObject.position + offset));
|
||||
if (currentDist < distanceToStartFade && !usingTransp)
|
||||
{
|
||||
usingTransp = true;
|
||||
ChangeMaterialsToFade();
|
||||
}
|
||||
else if (usingTransp && currentDist > distanceToStartFade)
|
||||
{
|
||||
usingTransp = false;
|
||||
ChangeMaterialsToOriginal();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change the Renderer Materials to Original Materials
|
||||
/// </summary>
|
||||
private void ChangeMaterialsToOriginal()
|
||||
{
|
||||
foreach (FadeMaterials fd in fadeMeshRenderers)
|
||||
try { fd.renderer.sharedMaterials = fd.originalMaterials; } catch { }
|
||||
|
||||
|
||||
foreach (FadeMaterials fd in fadeSkinnedMeshRenderes)
|
||||
try { fd.renderer.sharedMaterials = fd.originalMaterials; } catch { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Chenge the Renderer Materials to Fade Material
|
||||
/// </summary>
|
||||
private void ChangeMaterialsToFade()
|
||||
{
|
||||
|
||||
foreach (FadeMaterials fd in fadeMeshRenderers)
|
||||
try { fd.renderer.sharedMaterials = fd.fadeMaterials; } catch { }
|
||||
|
||||
|
||||
foreach (FadeMaterials fd in fadeSkinnedMeshRenderes)
|
||||
try { fd.renderer.sharedMaterials = fd.fadeMaterials; } catch { }
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change the Alpha Color material From distance
|
||||
/// </summary>
|
||||
public void ChangeAlphaFromDistance()
|
||||
{
|
||||
var currentDist = Vector3.Distance(cameraTransform.position, (targetObject.position + offset));
|
||||
// Mesh Renderer
|
||||
for (int i = 0; i < fadeMeshRenderers.Count; i++)
|
||||
{
|
||||
for (int m = 0; m < fadeMeshRenderers[i].fadeMaterials.Length; m++)
|
||||
{
|
||||
try
|
||||
{
|
||||
var multpler = fadeMeshRenderers[i].originalAlpha[m] / (distanceToStartFade - distanceToEndFade);
|
||||
var color = fadeMeshRenderers[i].renderer.sharedMaterials[m].color;
|
||||
var factor = (distanceToStartFade - distanceToEndFade) - ((distanceToStartFade - currentDist));
|
||||
color.a = multpler * factor;
|
||||
color.a = Mathf.Clamp(color.a, 0f, fadeMeshRenderers[i].originalAlpha[m]);
|
||||
fadeMeshRenderers[i].renderer.materials[m].color = color;
|
||||
}
|
||||
catch { }
|
||||
|
||||
}
|
||||
}
|
||||
//Skinned Mesh Renderer
|
||||
for (int i = 0; i < fadeSkinnedMeshRenderes.Count; i++)
|
||||
{
|
||||
for (int m = 0; m < fadeSkinnedMeshRenderes[i].fadeMaterials.Length; m++)
|
||||
{
|
||||
try
|
||||
{
|
||||
var multpler = fadeSkinnedMeshRenderes[i].originalAlpha[m] / (distanceToStartFade - distanceToEndFade);
|
||||
var color = fadeSkinnedMeshRenderes[i].renderer.sharedMaterials[m].color;
|
||||
var factor = (distanceToStartFade - distanceToEndFade) - ((distanceToStartFade - currentDist));
|
||||
color.a = multpler * factor;
|
||||
color.a = Mathf.Clamp(color.a, 0f, fadeSkinnedMeshRenderes[i].originalAlpha[m]);
|
||||
fadeSkinnedMeshRenderes[i].renderer.materials[m].color = color;
|
||||
}
|
||||
catch { }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class FadeMaterials
|
||||
{
|
||||
public Renderer renderer;
|
||||
public Material[] originalMaterials;
|
||||
public Material[] fadeMaterials;
|
||||
public float[] originalAlpha;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c58da051753b61449891e76336ede105
|
||||
timeCreated: 1447094364
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 365b00e36dcb8d349a704af253036471
|
||||
folderAsset: yes
|
||||
timeCreated: 1435613877
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,22 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
namespace Invector
|
||||
{
|
||||
public static class vScriptableObjectUtility
|
||||
{
|
||||
/// <summary>
|
||||
/// Create new asset from <see cref="ScriptableObject"/> type with unique Name at
|
||||
/// selected folder in project window. Asset creation can be cancelled by pressing
|
||||
/// escape key when asset is initially being named.
|
||||
/// </summary>
|
||||
/// <typeparam Name="T">Type of scriptable object.</typeparam>
|
||||
///
|
||||
public static void CreateAsset<T>() where T : ScriptableObject
|
||||
{
|
||||
var asset = ScriptableObject.CreateInstance<T>();
|
||||
ProjectWindowUtil.CreateAsset(asset, "New " + typeof(T).Name + ".asset");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: be1866f25fa3cec4cbe2550c33de9fa6
|
||||
timeCreated: 1435618339
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,435 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
namespace Invector.vCamera
|
||||
{
|
||||
[CustomEditor(typeof(vThirdPersonCamera),true)]
|
||||
[CanEditMultipleObjects]
|
||||
public class vThirdPersonCameraEditor : UnityEditor.Editor
|
||||
{
|
||||
protected virtual GUISkin skin { get; set; }
|
||||
protected virtual vThirdPersonCamera tpCamera { get; set; }
|
||||
protected virtual bool hasPointCopy { get; set; }
|
||||
protected virtual Vector3 pointCopy { get; set; }
|
||||
protected virtual int indexSelected { get; set; }
|
||||
protected virtual Texture2D m_Logo { get; set; }
|
||||
|
||||
protected virtual void OnSceneGUI()
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
return;
|
||||
tpCamera = (vThirdPersonCamera)target;
|
||||
|
||||
if (tpCamera.gameObject == Selection.activeGameObject)
|
||||
if (tpCamera.CameraStateList != null && tpCamera.CameraStateList.tpCameraStates != null && tpCamera.CameraStateList.tpCameraStates.Count > 0)
|
||||
{
|
||||
if (tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].cameraMode != TPCameraMode.FixedPoint) return;
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints.Count; i++)
|
||||
{
|
||||
if (indexSelected == i)
|
||||
{
|
||||
Handles.color = Color.blue;
|
||||
tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].positionPoint = tpCamera.transform.position;
|
||||
tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].eulerAngle = tpCamera.transform.eulerAngles;
|
||||
if (tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[indexSelected].freeRotation)
|
||||
{
|
||||
Handles.SphereHandleCap(0, tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].eulerAngle, Quaternion.identity, 0.5f, EventType.Ignore);
|
||||
}
|
||||
else
|
||||
{
|
||||
Handles.DrawLine(tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].positionPoint,
|
||||
tpCamera.mainTarget.position);
|
||||
}
|
||||
}
|
||||
else if (Handles.Button(tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].positionPoint, Quaternion.identity, 0.5f, 0.3f, Handles.SphereHandleCap))
|
||||
{
|
||||
indexSelected = i;
|
||||
tpCamera.indexLookPoint = i;
|
||||
tpCamera.transform.position = tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].positionPoint;
|
||||
tpCamera.transform.rotation = Quaternion.Euler(tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].eulerAngle);
|
||||
}
|
||||
Handles.color = Color.white;
|
||||
Handles.Label(tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].positionPoint, tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].pointName);
|
||||
}
|
||||
}
|
||||
catch { if (tpCamera.indexList > tpCamera.CameraStateList.tpCameraStates.Count - 1) tpCamera.indexList = tpCamera.CameraStateList.tpCameraStates.Count - 1; }
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
m_Logo = (Texture2D)Resources.Load("tp_camera", typeof(Texture2D));
|
||||
indexSelected = 0;
|
||||
tpCamera = (vThirdPersonCamera)target;
|
||||
tpCamera.indexLookPoint = 0;
|
||||
if (tpCamera.CameraStateList==null||tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].cameraMode != TPCameraMode.FixedPoint) return;
|
||||
if (tpCamera.CameraStateList != null && (tpCamera.indexList < tpCamera.CameraStateList.tpCameraStates.Count) && tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints.Count > 0)
|
||||
{
|
||||
tpCamera.transform.position = tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[0].positionPoint;
|
||||
tpCamera.transform.rotation = Quaternion.Euler(tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[0].eulerAngle);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
var oldskin = GUI.skin;
|
||||
if (!skin) skin = Resources.Load("vSkin") as GUISkin;
|
||||
GUI.skin = skin;
|
||||
|
||||
tpCamera = (vThirdPersonCamera)target;
|
||||
|
||||
EditorGUILayout.Space();
|
||||
GUILayout.BeginVertical("Third Person Camera by Invector", "window");
|
||||
GUILayout.Label(m_Logo, GUILayout.MaxHeight(25));
|
||||
GUILayout.Space(5);
|
||||
|
||||
if (tpCamera.cullingLayer == 0)
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.HelpBox("Please assign the Culling Layer to 'Default' ", MessageType.Warning);
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
|
||||
EditorGUILayout.HelpBox("The target will be assign automatically to the current Character when start, check the InitialSetup method on the Motor.", MessageType.Info);
|
||||
GUI.skin = oldskin;
|
||||
base.OnInspectorGUI();
|
||||
GUI.skin = skin;
|
||||
GUILayout.EndVertical();
|
||||
|
||||
GUILayout.BeginVertical("Camera States", "window");
|
||||
|
||||
GUILayout.Label(m_Logo, GUILayout.MaxHeight(25));
|
||||
GUILayout.Space(5);
|
||||
|
||||
EditorGUILayout.HelpBox("This settings will always load in this List, you can create more List's with different settings for another characters or scenes", MessageType.Info);
|
||||
|
||||
tpCamera.CameraStateList = (vThirdPersonCameraListData)EditorGUILayout.ObjectField("CameraState List", tpCamera.CameraStateList, typeof(vThirdPersonCameraListData), false);
|
||||
if (tpCamera.CameraStateList == null)
|
||||
{
|
||||
GUILayout.EndVertical();
|
||||
return;
|
||||
}
|
||||
GUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button(new GUIContent("New CameraState")))
|
||||
{
|
||||
if (tpCamera.CameraStateList.tpCameraStates == null)
|
||||
tpCamera.CameraStateList.tpCameraStates = new List<vThirdPersonCameraState>();
|
||||
|
||||
tpCamera.CameraStateList.tpCameraStates.Add(new vThirdPersonCameraState("New State" + tpCamera.CameraStateList.tpCameraStates.Count));
|
||||
tpCamera.indexList = tpCamera.CameraStateList.tpCameraStates.Count - 1;
|
||||
}
|
||||
|
||||
if (GUILayout.Button(new GUIContent("Delete State")) && tpCamera.CameraStateList.tpCameraStates.Count > 1 && tpCamera.indexList != 0)
|
||||
{
|
||||
tpCamera.CameraStateList.tpCameraStates.RemoveAt(tpCamera.indexList);
|
||||
if (tpCamera.indexList - 1 >= 0)
|
||||
tpCamera.indexList--;
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
if (tpCamera.CameraStateList.tpCameraStates.Count > 0)
|
||||
{
|
||||
if (tpCamera.indexList > tpCamera.CameraStateList.tpCameraStates.Count - 1) tpCamera.indexList = 0;
|
||||
tpCamera.indexList = EditorGUILayout.Popup("State", tpCamera.indexList, getListName(tpCamera.CameraStateList.tpCameraStates));
|
||||
StateData(tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList]);
|
||||
}
|
||||
|
||||
GUILayout.EndVertical();
|
||||
EditorGUILayout.Space();
|
||||
|
||||
if (GUI.changed)
|
||||
{
|
||||
EditorUtility.SetDirty(tpCamera);
|
||||
EditorUtility.SetDirty(tpCamera.CameraStateList);
|
||||
}
|
||||
GUI.skin = oldskin;
|
||||
}
|
||||
|
||||
protected virtual void StateData(vThirdPersonCameraState camState)
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
|
||||
DrawEnumField("Camera Mode", ref camState.cameraMode);
|
||||
DrawTextField("State Name",ref camState.Name);
|
||||
|
||||
if (CheckName(camState.Name, tpCamera.indexList))
|
||||
{
|
||||
EditorGUILayout.HelpBox("This name already exist, choose another one", MessageType.Error);
|
||||
}
|
||||
|
||||
switch (camState.cameraMode)
|
||||
{
|
||||
case TPCameraMode.FreeDirectional:
|
||||
FreeDirectionalMode(camState);
|
||||
break;
|
||||
case TPCameraMode.FixedAngle:
|
||||
FixedAngleMode(camState);
|
||||
break;
|
||||
case TPCameraMode.FixedPoint:
|
||||
FixedPointMode(camState);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void DrawLookPoint(vThirdPersonCameraState camState)
|
||||
{
|
||||
if (camState.lookPoints == null) camState.lookPoints = new List<LookPoint>();
|
||||
if (camState.lookPoints.Count > 0)
|
||||
{
|
||||
EditorGUILayout.HelpBox("You can create multiple camera points and change them using the TriggerChangeCameraState script.", MessageType.Info);
|
||||
|
||||
if (tpCamera.indexLookPoint > camState.lookPoints.Count - 1)
|
||||
tpCamera.indexLookPoint = 0;
|
||||
if (tpCamera.indexLookPoint < 0)
|
||||
tpCamera.indexLookPoint = camState.lookPoints.Count - 1;
|
||||
GUILayout.BeginHorizontal("box");
|
||||
GUILayout.Label("Fixed Points");
|
||||
GUILayout.FlexibleSpace();
|
||||
if (GUILayout.Button("<", GUILayout.Width(20)))
|
||||
{
|
||||
if (tpCamera.indexLookPoint - 1 < 0)
|
||||
tpCamera.indexLookPoint = camState.lookPoints.Count - 1;
|
||||
else
|
||||
tpCamera.indexLookPoint--;
|
||||
tpCamera.transform.position = camState.lookPoints[tpCamera.indexLookPoint].positionPoint;
|
||||
tpCamera.transform.rotation = Quaternion.Euler(camState.lookPoints[tpCamera.indexLookPoint].eulerAngle);
|
||||
|
||||
indexSelected = tpCamera.indexLookPoint;
|
||||
}
|
||||
GUILayout.Box((tpCamera.indexLookPoint + 1).ToString("00") + "/" + camState.lookPoints.Count.ToString("00"));
|
||||
if (GUILayout.Button(">", GUILayout.Width(20)))
|
||||
{
|
||||
if (tpCamera.indexLookPoint + 1 > camState.lookPoints.Count - 1)
|
||||
tpCamera.indexLookPoint = 0;
|
||||
else
|
||||
tpCamera.indexLookPoint++;
|
||||
tpCamera.transform.position = camState.lookPoints[tpCamera.indexLookPoint].positionPoint;
|
||||
tpCamera.transform.rotation = Quaternion.Euler(camState.lookPoints[tpCamera.indexLookPoint].eulerAngle);
|
||||
indexSelected = tpCamera.indexLookPoint;
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.BeginHorizontal("box");
|
||||
GUILayout.Label("Point Name");
|
||||
camState.lookPoints[tpCamera.indexLookPoint].pointName = GUILayout.TextField(camState.lookPoints[tpCamera.indexLookPoint].pointName, 100);
|
||||
GUILayout.EndHorizontal();
|
||||
EditorGUILayout.HelpBox("Check 'Static Camera' to create a static point and leave uncheck to look at the Player.", MessageType.Info);
|
||||
camState.lookPoints[tpCamera.indexLookPoint].freeRotation = EditorGUILayout.Toggle("Static Camera", camState.lookPoints[tpCamera.indexLookPoint].freeRotation);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
|
||||
GUILayout.BeginHorizontal("box");
|
||||
if (GUILayout.Button("New Point"))
|
||||
{
|
||||
LookPoint p = new LookPoint();
|
||||
p.pointName = "point_" + (camState.lookPoints.Count + 1).ToString("00");
|
||||
p.positionPoint = tpCamera.transform.position;
|
||||
p.eulerAngle = (tpCamera.mainTarget) ? tpCamera.mainTarget.position : (tpCamera.transform.position + tpCamera.transform.forward);
|
||||
camState.lookPoints.Add(p);
|
||||
tpCamera.indexLookPoint = camState.lookPoints.Count - 1;
|
||||
|
||||
tpCamera.transform.position = camState.lookPoints[tpCamera.indexLookPoint].positionPoint;
|
||||
indexSelected = tpCamera.indexLookPoint;
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Remove current point "))
|
||||
{
|
||||
if (camState.lookPoints.Count > 0)
|
||||
{
|
||||
camState.lookPoints.RemoveAt(tpCamera.indexLookPoint);
|
||||
tpCamera.indexLookPoint--;
|
||||
if (tpCamera.indexLookPoint > camState.lookPoints.Count - 1)
|
||||
tpCamera.indexLookPoint = 0;
|
||||
if (tpCamera.indexLookPoint < 0)
|
||||
tpCamera.indexLookPoint = camState.lookPoints.Count - 1;
|
||||
if (camState.lookPoints.Count > 0)
|
||||
tpCamera.transform.position = camState.lookPoints[tpCamera.indexLookPoint].positionPoint;
|
||||
indexSelected = tpCamera.indexLookPoint;
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
|
||||
protected virtual void FreeDirectionalMode(vThirdPersonCameraState camState)
|
||||
{
|
||||
|
||||
DrawSliderField("Forward", ref camState.forward, -1f, 1f);
|
||||
DrawSliderField("Right", ref camState.right, -3f, 3f);
|
||||
DrawFloatField("Distance",ref camState.defaultDistance);
|
||||
DrawToogleField("Use Zoom",ref camState.useZoom);
|
||||
if (camState.useZoom)
|
||||
{
|
||||
DrawFloatField("Max Distance", ref camState.maxDistance);
|
||||
DrawFloatField("Min Distance",ref camState.minDistance);
|
||||
}
|
||||
DrawFloatField("Height", ref camState.height);
|
||||
DrawSliderField("Field of View",ref camState.fov, 1, 179);
|
||||
DrawFloatField("Smooth",ref camState.smooth);
|
||||
DrawFloatField("Smooth Damp",ref camState.smoothDamp);
|
||||
DrawFloatField("Culling Height",ref camState.cullingHeight);
|
||||
DrawVector3Field("Rotation OffSet",ref camState.rotationOffSet);
|
||||
DrawFloatField("MouseSensitivity X",ref camState.xMouseSensitivity);
|
||||
DrawFloatField("MouseSensitivity Y",ref camState.yMouseSensitivity);
|
||||
MinMaxSliderField("Limit Angle X", ref camState.xMinLimit, ref camState.xMaxLimit, -360, 360);
|
||||
MinMaxSliderField("Limit Angle Y", ref camState.yMinLimit, ref camState.yMaxLimit, -180, 180);
|
||||
}
|
||||
|
||||
protected virtual void FixedAngleMode(vThirdPersonCameraState camState)
|
||||
{
|
||||
DrawFloatField("Distance",ref camState.defaultDistance);
|
||||
DrawToogleField("Use Zoom",ref camState.useZoom);
|
||||
if (camState.useZoom)
|
||||
{
|
||||
DrawFloatField("Max Distance",ref camState.maxDistance);
|
||||
DrawFloatField("Min Distance",ref camState.minDistance);
|
||||
}
|
||||
DrawFloatField("Height",ref camState.height);
|
||||
DrawSliderField("Field of View",ref camState.fov, 1, 179);
|
||||
DrawFloatField("Smooth Follow",ref camState.smooth);
|
||||
DrawFloatField("Culling Height",ref camState.cullingHeight);
|
||||
DrawSliderField("Right",ref camState.right, -3f, 3f);
|
||||
DrawSliderField("Angle X",ref camState.fixedAngle.x, -360, 360);
|
||||
DrawSliderField("Angle Y",ref camState.fixedAngle.y, -360, 360);
|
||||
}
|
||||
|
||||
protected virtual void FixedPointMode(vThirdPersonCameraState camState)
|
||||
{
|
||||
DrawFloatField("Smooth Follow",ref camState.smooth);
|
||||
DrawSliderField("Field of View",ref camState.fov, 1, 179);
|
||||
camState.fixedAngle.x = 0;
|
||||
camState.fixedAngle.y = 0;
|
||||
|
||||
DrawLookPoint(camState);
|
||||
}
|
||||
|
||||
protected virtual bool CheckName(string Name, int _index)
|
||||
{
|
||||
foreach (vThirdPersonCameraState state in tpCamera.CameraStateList.tpCameraStates)
|
||||
if (state.Name.Equals(Name) && tpCamera.CameraStateList.tpCameraStates.IndexOf(state) != _index)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#region Camera State Drawers with undo
|
||||
|
||||
protected virtual void DrawEnumField<T>(string name,ref T value)where T :System.Enum
|
||||
{
|
||||
T _value = value;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
_value = (T)EditorGUILayout.EnumPopup(name, _value);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
Undo.RecordObject(tpCamera.CameraStateList, "ChangeCameraState");
|
||||
value = _value;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void DrawTextField(string name, ref string value)
|
||||
{
|
||||
string _value = value;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
_value =EditorGUILayout.TextField(name, _value);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
Undo.RecordObject(tpCamera.CameraStateList, "ChangeCameraState");
|
||||
value = _value;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void DrawVector3Field(string name, ref Vector3 value)
|
||||
{
|
||||
Vector3 _value = value;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
_value = EditorGUILayout.Vector3Field("Rotation OffSet", _value);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
Undo.RecordObject(tpCamera.CameraStateList, "ChangeCameraState");
|
||||
value = _value;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void DrawSliderField(string name, ref float value, float min, float max)
|
||||
{
|
||||
float _value = value;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
_value = EditorGUILayout.Slider(name, _value, min, max);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
Undo.RecordObject(tpCamera.CameraStateList, "ChangeCameraState");
|
||||
value = _value;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void DrawFloatField(string name, ref float value)
|
||||
{
|
||||
float _value = value;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
_value = EditorGUILayout.FloatField(name, _value);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
Undo.RecordObject(tpCamera.CameraStateList, "ChangeCameraState");
|
||||
value = _value;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void DrawToogleField(string name, ref bool value)
|
||||
{
|
||||
bool _value = value;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
_value = EditorGUILayout.Toggle(name, _value);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
Undo.RecordObject(tpCamera.CameraStateList, "ChangeCameraState");
|
||||
value = _value;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void MinMaxSliderField(string name, ref float minVal, ref float maxVal, float minLimit, float maxLimit)
|
||||
{
|
||||
float _minVal = minVal;
|
||||
float _maxVal = maxVal;
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.Label(name);
|
||||
GUILayout.BeginHorizontal("box");
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
_minVal = EditorGUILayout.FloatField(_minVal, GUILayout.MaxWidth(60));
|
||||
EditorGUILayout.MinMaxSlider(ref _minVal, ref _maxVal, minLimit, maxLimit);
|
||||
_maxVal = EditorGUILayout.FloatField(_maxVal, GUILayout.MaxWidth(60));
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
Undo.RecordObject(tpCamera.CameraStateList, "ChangeCameraState");
|
||||
minVal = _minVal;
|
||||
maxVal = _maxVal;
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
[MenuItem("Invector/Basic Locomotion/Resources/New CameraState List Data")]
|
||||
protected static void NewCameraStateData()
|
||||
{
|
||||
vScriptableObjectUtility.CreateAsset<vThirdPersonCameraListData>();
|
||||
}
|
||||
|
||||
protected virtual string[] getListName(List<vThirdPersonCameraState> list)
|
||||
{
|
||||
string[] names = new string[list.Count];
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
names[i] = list[i].Name;
|
||||
}
|
||||
return names;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 86f967fe0faf67840993d0f39fcec5a2
|
||||
timeCreated: 1426815480
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a1bfe72fbc87d04e885296b53e91c66
|
||||
timeCreated: 1502332381
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,113 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Invector.vCamera
|
||||
{
|
||||
public static class vThirdPersonCameraExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Lerp between CameraStates
|
||||
/// </summary>
|
||||
/// <param name="to"></param>
|
||||
/// <param name="from"></param>
|
||||
/// <param name="time"></param>
|
||||
public static void Slerp(this vThirdPersonCameraState to, vThirdPersonCameraState from, float time)
|
||||
{
|
||||
to.Name = from.Name;
|
||||
to.forward = Mathf.Lerp(to.forward, from.forward, time);
|
||||
to.right = Mathf.Lerp(to.right, from.right, time);
|
||||
to.defaultDistance = Mathf.Lerp(to.defaultDistance, from.defaultDistance, time);
|
||||
to.maxDistance = Mathf.Lerp(to.maxDistance, from.maxDistance, time);
|
||||
to.minDistance = Mathf.Lerp(to.minDistance, from.minDistance, time);
|
||||
to.height = Mathf.Lerp(to.height, from.height, time);
|
||||
to.fixedAngle = Vector2.Lerp(to.fixedAngle, from.fixedAngle, time);
|
||||
to.smooth = Mathf.Lerp(to.smooth, from.smooth, time);
|
||||
to.xMouseSensitivity = Mathf.Lerp(to.xMouseSensitivity, from.xMouseSensitivity, time);
|
||||
to.yMouseSensitivity = Mathf.Lerp(to.yMouseSensitivity, from.yMouseSensitivity, time);
|
||||
to.yMinLimit = Mathf.Lerp(to.yMinLimit, from.yMinLimit, time);
|
||||
to.yMaxLimit = Mathf.Lerp(to.yMaxLimit, from.yMaxLimit, time);
|
||||
to.xMinLimit = Mathf.Lerp(to.xMinLimit, from.xMinLimit, time);
|
||||
to.xMaxLimit = Mathf.Lerp(to.xMaxLimit, from.xMaxLimit, time);
|
||||
to.rotationOffSet = Vector3.Lerp(to.rotationOffSet, from.rotationOffSet, time);
|
||||
to.cullingHeight = Mathf.Lerp(to.cullingHeight, from.cullingHeight, time);
|
||||
to.cullingMinDist = Mathf.Lerp(to.cullingMinDist, from.cullingMinDist, time);
|
||||
to.cameraMode = from.cameraMode;
|
||||
to.useZoom = from.useZoom;
|
||||
to.lookPoints = from.lookPoints;
|
||||
to.fov = Mathf.Lerp(to.fov, from.fov, time);
|
||||
|
||||
if (to.fov <= 0) to.fov = 1f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copy of CameraStates
|
||||
/// </summary>
|
||||
/// <param name="to"></param>
|
||||
/// <param name="from"></param>
|
||||
public static void CopyState(this vThirdPersonCameraState to, vThirdPersonCameraState from)
|
||||
{
|
||||
to.Name = from.Name;
|
||||
to.forward = from.forward;
|
||||
to.right = from.right;
|
||||
to.defaultDistance = from.defaultDistance;
|
||||
to.maxDistance = from.maxDistance;
|
||||
to.minDistance = from.minDistance;
|
||||
to.height = from.height;
|
||||
to.fixedAngle = from.fixedAngle;
|
||||
to.lookPoints = from.lookPoints;
|
||||
to.smooth = from.smooth;
|
||||
to.xMouseSensitivity = from.xMouseSensitivity;
|
||||
to.yMouseSensitivity = from.yMouseSensitivity;
|
||||
to.yMinLimit = from.yMinLimit;
|
||||
to.yMaxLimit = from.yMaxLimit;
|
||||
to.xMinLimit = from.xMinLimit;
|
||||
to.xMaxLimit = from.xMaxLimit;
|
||||
to.rotationOffSet = from.rotationOffSet;
|
||||
to.cullingHeight = from.cullingHeight;
|
||||
to.cullingMinDist = from.cullingMinDist;
|
||||
to.cameraMode = from.cameraMode;
|
||||
to.useZoom = from.useZoom;
|
||||
to.fov = from.fov;
|
||||
|
||||
if (to.fov <= 0) to.fov = 1f;
|
||||
}
|
||||
|
||||
public static ClipPlanePoints NearClipPlanePoints(this Camera camera, Vector3 pos, float clipPlaneMargin)
|
||||
{
|
||||
var clipPlanePoints = new ClipPlanePoints();
|
||||
|
||||
var transform = camera.transform;
|
||||
var halfFOV = (camera.fieldOfView / 2) * Mathf.Deg2Rad;
|
||||
var aspect = camera.aspect;
|
||||
var distance = camera.nearClipPlane;
|
||||
var height = distance * Mathf.Tan(halfFOV);
|
||||
var width = height * aspect;
|
||||
height *= 1 + clipPlaneMargin;
|
||||
width *= 1 + clipPlaneMargin;
|
||||
clipPlanePoints.LowerRight = pos + transform.right * width;
|
||||
clipPlanePoints.LowerRight -= transform.up * height;
|
||||
clipPlanePoints.LowerRight += transform.forward * distance;
|
||||
|
||||
clipPlanePoints.LowerLeft = pos - transform.right * width;
|
||||
clipPlanePoints.LowerLeft -= transform.up * height;
|
||||
clipPlanePoints.LowerLeft += transform.forward * distance;
|
||||
|
||||
clipPlanePoints.UpperRight = pos + transform.right * width;
|
||||
clipPlanePoints.UpperRight += transform.up * height;
|
||||
clipPlanePoints.UpperRight += transform.forward * distance;
|
||||
|
||||
clipPlanePoints.UpperLeft = pos - transform.right * width;
|
||||
clipPlanePoints.UpperLeft += transform.up * height;
|
||||
clipPlanePoints.UpperLeft += transform.forward * distance;
|
||||
|
||||
return clipPlanePoints;
|
||||
}
|
||||
}
|
||||
|
||||
public struct ClipPlanePoints
|
||||
{
|
||||
public Vector3 UpperLeft;
|
||||
public Vector3 UpperRight;
|
||||
public Vector3 LowerLeft;
|
||||
public Vector3 LowerRight;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 17c74b52b8d0ad04aa7481d6a1197d1b
|
||||
timeCreated: 1525990119
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
namespace Invector
|
||||
{
|
||||
[System.Serializable]
|
||||
public class vThirdPersonCameraListData : ScriptableObject
|
||||
{
|
||||
[SerializeField] public string Name;
|
||||
[SerializeField] public List<vThirdPersonCameraState> tpCameraStates;
|
||||
|
||||
public vThirdPersonCameraListData()
|
||||
{
|
||||
tpCameraStates = new List<vThirdPersonCameraState>();
|
||||
tpCameraStates.Add(new vThirdPersonCameraState("Default"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7592ac57a97621844bb7d05b6822c040
|
||||
timeCreated: 1426817105
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,76 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Invector
|
||||
{
|
||||
[System.Serializable]
|
||||
public class vThirdPersonCameraState
|
||||
{
|
||||
public string Name;
|
||||
public float forward;
|
||||
public float right;
|
||||
public float defaultDistance;
|
||||
public float maxDistance;
|
||||
public float minDistance;
|
||||
public float height;
|
||||
public float smooth = 10f;
|
||||
public float smoothDamp = 0f;
|
||||
public float xMouseSensitivity;
|
||||
public float yMouseSensitivity;
|
||||
public float yMinLimit;
|
||||
public float yMaxLimit;
|
||||
public float xMinLimit;
|
||||
public float xMaxLimit;
|
||||
|
||||
public Vector3 rotationOffSet;
|
||||
public float cullingHeight;
|
||||
public float cullingMinDist;
|
||||
public float fov;
|
||||
public bool useZoom;
|
||||
public Vector2 fixedAngle;
|
||||
public List<LookPoint> lookPoints;
|
||||
public TPCameraMode cameraMode;
|
||||
|
||||
public vThirdPersonCameraState(string name)
|
||||
{
|
||||
Name = name;
|
||||
forward = -1f;
|
||||
right = 0f;
|
||||
defaultDistance = 1.5f;
|
||||
maxDistance = 3f;
|
||||
minDistance = 0.5f;
|
||||
height = 0f;
|
||||
smooth = 10f;
|
||||
smoothDamp = 0f;
|
||||
xMouseSensitivity = 3f;
|
||||
yMouseSensitivity = 3f;
|
||||
yMinLimit = -40f;
|
||||
yMaxLimit = 80f;
|
||||
xMinLimit = -360f;
|
||||
xMaxLimit = 360f;
|
||||
cullingHeight = 0.2f;
|
||||
cullingMinDist = 0.1f;
|
||||
fov = 60f;
|
||||
useZoom = false;
|
||||
forward = 60;
|
||||
fixedAngle = Vector2.zero;
|
||||
cameraMode = TPCameraMode.FreeDirectional;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class LookPoint
|
||||
{
|
||||
public string pointName;
|
||||
public Vector3 positionPoint;
|
||||
public Vector3 eulerAngle;
|
||||
public bool freeRotation;
|
||||
}
|
||||
|
||||
public enum TPCameraMode
|
||||
{
|
||||
FreeDirectional,
|
||||
FixedAngle,
|
||||
FixedPoint
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 80e3a9051ec7b4740b46f7f880eeb2fb
|
||||
timeCreated: 1426817210
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 41524fcaa48073c47b6c6b1f47f7dce2
|
||||
folderAsset: yes
|
||||
timeCreated: 1435613876
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fee373f3ff5771d4cbca2e667f2ee24f
|
||||
folderAsset: yes
|
||||
timeCreated: 1494437044
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f0562eeefa7a963429a4ee595d37adb4
|
||||
folderAsset: yes
|
||||
timeCreated: 1494437079
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,510 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &137936
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 22474998}
|
||||
- component: {fileID: 22289816}
|
||||
- component: {fileID: 11430320}
|
||||
m_Layer: 5
|
||||
m_Name: Text
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &22474998
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 137936}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 22462718}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 75, y: 0}
|
||||
m_SizeDelta: {x: -150, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &22289816
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 137936}
|
||||
m_CullTransparentMesh: 0
|
||||
--- !u!114 &11430320
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 137936}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 2100000, guid: a33be1e1efa8ca14286b77d062313a4e, type: 2}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_FontData:
|
||||
m_Font: {fileID: 12800000, guid: a8f74dbf0f81e504bbbdf3f6063e1047, type: 3}
|
||||
m_FontSize: 100
|
||||
m_FontStyle: 0
|
||||
m_BestFit: 1
|
||||
m_MinSize: 50
|
||||
m_MaxSize: 100
|
||||
m_Alignment: 4
|
||||
m_AlignByGeometry: 0
|
||||
m_RichText: 1
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: 'action text
|
||||
|
||||
F'
|
||||
--- !u!1 &146674
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 22462718}
|
||||
- component: {fileID: 22244980}
|
||||
- component: {fileID: 11404324}
|
||||
- component: {fileID: 11492154}
|
||||
m_Layer: 5
|
||||
m_Name: bg
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &22462718
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 146674}
|
||||
m_LocalRotation: {x: 0, y: -1, z: 0, w: -0.00000010430813}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 22474998}
|
||||
- {fileID: 22493032}
|
||||
- {fileID: 22433174}
|
||||
m_Father: {fileID: 22447194}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &22244980
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 146674}
|
||||
m_CullTransparentMesh: 0
|
||||
--- !u!114 &11404324
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 146674}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 2100000, guid: a33be1e1efa8ca14286b77d062313a4e, type: 2}
|
||||
m_Color: {r: 0, g: 0, b: 0, a: 0.627451}
|
||||
m_RaycastTarget: 1
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 0}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!114 &11492154
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 146674}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 60254cc56f3d5d04896861196a404996, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
OnChangeToKeyboard:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 190832}
|
||||
m_MethodName: SetActive
|
||||
m_Mode: 6
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
- m_Target: {fileID: 154448}
|
||||
m_MethodName: SetActive
|
||||
m_Mode: 6
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 1
|
||||
m_CallState: 2
|
||||
OnChangeToMobile:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
OnChangeToJoystick:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 190832}
|
||||
m_MethodName: SetActive
|
||||
m_Mode: 6
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 1
|
||||
m_CallState: 2
|
||||
- m_Target: {fileID: 154448}
|
||||
m_MethodName: SetActive
|
||||
m_Mode: 6
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
--- !u!1 &154448
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 22493032}
|
||||
- component: {fileID: 22229584}
|
||||
- component: {fileID: 11453002}
|
||||
m_Layer: 5
|
||||
m_Name: icon_keyboard
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &22493032
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 154448}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 22462718}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0.5}
|
||||
m_AnchorMax: {x: 0, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0.00064086914, y: 0.0000141859055}
|
||||
m_SizeDelta: {x: 150, y: 150}
|
||||
m_Pivot: {x: 0, y: 0.5}
|
||||
--- !u!222 &22229584
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 154448}
|
||||
m_CullTransparentMesh: 0
|
||||
--- !u!114 &11453002
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 154448}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 2100000, guid: a33be1e1efa8ca14286b77d062313a4e, type: 2}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 21300000, guid: 9dc1b1e35a44b5a4da340dd179166361, type: 3}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 1
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!1 &190832
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 22433174}
|
||||
- component: {fileID: 22292520}
|
||||
- component: {fileID: 11468942}
|
||||
m_Layer: 5
|
||||
m_Name: icon_controller
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &22433174
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 190832}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 22462718}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0.5}
|
||||
m_AnchorMax: {x: 0, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 150, y: 150}
|
||||
m_Pivot: {x: 0, y: 0.5}
|
||||
--- !u!222 &22292520
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 190832}
|
||||
m_CullTransparentMesh: 0
|
||||
--- !u!114 &11468942
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 190832}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 2100000, guid: a33be1e1efa8ca14286b77d062313a4e, type: 2}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 21300000, guid: cfea15071ee3a4543ba205f132c5da33, type: 3}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 1
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!1 &196820
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 22447194}
|
||||
- component: {fileID: 22359920}
|
||||
- component: {fileID: 11429832}
|
||||
- component: {fileID: 11408192}
|
||||
- component: {fileID: 11402886}
|
||||
- component: {fileID: 11426842}
|
||||
m_Layer: 5
|
||||
m_Name: vActionText_ExampleA
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &22447194
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 196820}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 28.808083}
|
||||
m_LocalScale: {x: 0.0017500378, y: 0.0017500373, z: 0.0017500373}
|
||||
m_Children:
|
||||
- {fileID: 22462718}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 24.946892, y: 0.816}
|
||||
m_SizeDelta: {x: 700, y: 150}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!223 &22359920
|
||||
Canvas:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 196820}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_RenderMode: 2
|
||||
m_Camera: {fileID: 0}
|
||||
m_PlaneDistance: 100
|
||||
m_PixelPerfect: 0
|
||||
m_ReceivesEvents: 1
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_AdditionalShaderChannelsFlag: 25
|
||||
m_SortingLayerID: 0
|
||||
m_SortingOrder: 0
|
||||
m_TargetDisplay: 0
|
||||
--- !u!114 &11429832
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 196820}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_UiScaleMode: 0
|
||||
m_ReferencePixelsPerUnit: 100
|
||||
m_ScaleFactor: 1
|
||||
m_ReferenceResolution: {x: 800, y: 600}
|
||||
m_ScreenMatchMode: 0
|
||||
m_MatchWidthOrHeight: 0
|
||||
m_PhysicalUnit: 3
|
||||
m_FallbackScreenDPI: 96
|
||||
m_DefaultSpriteDPI: 96
|
||||
m_DynamicPixelsPerUnit: 1
|
||||
--- !u!114 &11408192
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 196820}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_IgnoreReversedGraphics: 1
|
||||
m_BlockingObjects: 0
|
||||
m_BlockingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
--- !u!114 &11402886
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 196820}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 19c789670a80b704eba4dfebed94a111, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
header: COMMENT
|
||||
comment: 'This is a ingame HUD example, it will render above all objects and follow
|
||||
the camera.
|
||||
|
||||
|
||||
Inside you can modify the Text or the Sprite buttons.'
|
||||
inEdit: 0
|
||||
--- !u!114 &11426842
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 196820}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: a5bfa2d224a49724b94dd6c24553be35, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
alignUp: 0
|
||||
height: 1
|
||||
detachOnStart: 0
|
||||
useSmothRotation: 1
|
||||
justY: 0
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c08c0d81378ff14e93e590e27e40c1d
|
||||
timeCreated: 1494437091
|
||||
licenseType: Store
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,493 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &137936
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 22474998}
|
||||
- component: {fileID: 22289816}
|
||||
- component: {fileID: 11430320}
|
||||
m_Layer: 5
|
||||
m_Name: Text
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &22474998
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 137936}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 22462718}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 75, y: 0}
|
||||
m_SizeDelta: {x: -150, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &22289816
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 137936}
|
||||
m_CullTransparentMesh: 0
|
||||
--- !u!114 &11430320
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 137936}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_FontData:
|
||||
m_Font: {fileID: 12800000, guid: a8f74dbf0f81e504bbbdf3f6063e1047, type: 3}
|
||||
m_FontSize: 100
|
||||
m_FontStyle: 0
|
||||
m_BestFit: 1
|
||||
m_MinSize: 50
|
||||
m_MaxSize: 100
|
||||
m_Alignment: 4
|
||||
m_AlignByGeometry: 0
|
||||
m_RichText: 1
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: 'action text
|
||||
|
||||
F'
|
||||
--- !u!1 &146674
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 22462718}
|
||||
- component: {fileID: 22244980}
|
||||
- component: {fileID: 11404324}
|
||||
- component: {fileID: 11492154}
|
||||
m_Layer: 5
|
||||
m_Name: bg
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &22462718
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 146674}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 22474998}
|
||||
- {fileID: 22493032}
|
||||
- {fileID: 22433174}
|
||||
m_Father: {fileID: 22447194}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &22244980
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 146674}
|
||||
m_CullTransparentMesh: 0
|
||||
--- !u!114 &11404324
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 146674}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 0, g: 0, b: 0, a: 0.627451}
|
||||
m_RaycastTarget: 1
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 0}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!114 &11492154
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 146674}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 60254cc56f3d5d04896861196a404996, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
OnChangeToKeyboard:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 190832}
|
||||
m_MethodName: SetActive
|
||||
m_Mode: 6
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
- m_Target: {fileID: 154448}
|
||||
m_MethodName: SetActive
|
||||
m_Mode: 6
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 1
|
||||
m_CallState: 2
|
||||
OnChangeToMobile:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
OnChangeToJoystick:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 190832}
|
||||
m_MethodName: SetActive
|
||||
m_Mode: 6
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 1
|
||||
m_CallState: 2
|
||||
- m_Target: {fileID: 154448}
|
||||
m_MethodName: SetActive
|
||||
m_Mode: 6
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
--- !u!1 &154448
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 22493032}
|
||||
- component: {fileID: 22229584}
|
||||
- component: {fileID: 11453002}
|
||||
m_Layer: 5
|
||||
m_Name: icon_keyboard
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &22493032
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 154448}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 22462718}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0.5}
|
||||
m_AnchorMax: {x: 0, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0.00064086914, y: 0.0000141859055}
|
||||
m_SizeDelta: {x: 150, y: 150}
|
||||
m_Pivot: {x: 0, y: 0.5}
|
||||
--- !u!222 &22229584
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 154448}
|
||||
m_CullTransparentMesh: 0
|
||||
--- !u!114 &11453002
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 154448}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 21300000, guid: 9dc1b1e35a44b5a4da340dd179166361, type: 3}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 1
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!1 &190832
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 22433174}
|
||||
- component: {fileID: 22292520}
|
||||
- component: {fileID: 11468942}
|
||||
m_Layer: 5
|
||||
m_Name: icon_controller
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &22433174
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 190832}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 22462718}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0.5}
|
||||
m_AnchorMax: {x: 0, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 150, y: 150}
|
||||
m_Pivot: {x: 0, y: 0.5}
|
||||
--- !u!222 &22292520
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 190832}
|
||||
m_CullTransparentMesh: 0
|
||||
--- !u!114 &11468942
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 190832}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 21300000, guid: cfea15071ee3a4543ba205f132c5da33, type: 3}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 1
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!1 &196820
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 22447194}
|
||||
- component: {fileID: 22359920}
|
||||
- component: {fileID: 11429832}
|
||||
- component: {fileID: 11408192}
|
||||
- component: {fileID: 11402886}
|
||||
m_Layer: 5
|
||||
m_Name: vActionText_ExampleB
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &22447194
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 196820}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 28.228796}
|
||||
m_LocalScale: {x: 0.0017500378, y: 0.0017500373, z: 0.0017500373}
|
||||
m_Children:
|
||||
- {fileID: 22462718}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 24.609264, y: 0.195}
|
||||
m_SizeDelta: {x: 700, y: 150}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!223 &22359920
|
||||
Canvas:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 196820}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_RenderMode: 2
|
||||
m_Camera: {fileID: 0}
|
||||
m_PlaneDistance: 100
|
||||
m_PixelPerfect: 0
|
||||
m_ReceivesEvents: 1
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_AdditionalShaderChannelsFlag: 25
|
||||
m_SortingLayerID: 0
|
||||
m_SortingOrder: 0
|
||||
m_TargetDisplay: 0
|
||||
--- !u!114 &11429832
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 196820}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_UiScaleMode: 0
|
||||
m_ReferencePixelsPerUnit: 100
|
||||
m_ScaleFactor: 1
|
||||
m_ReferenceResolution: {x: 800, y: 600}
|
||||
m_ScreenMatchMode: 0
|
||||
m_MatchWidthOrHeight: 0
|
||||
m_PhysicalUnit: 3
|
||||
m_FallbackScreenDPI: 96
|
||||
m_DefaultSpriteDPI: 96
|
||||
m_DynamicPixelsPerUnit: 1
|
||||
--- !u!114 &11408192
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 196820}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_IgnoreReversedGraphics: 1
|
||||
m_BlockingObjects: 0
|
||||
m_BlockingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
--- !u!114 &11402886
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 196820}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 19c789670a80b704eba4dfebed94a111, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
header: COMMENT
|
||||
comment: 'This is a ingame HUD example, you can use on world space and it will
|
||||
render just like a normal Object.
|
||||
|
||||
|
||||
Inside you can modify the Text or the
|
||||
Sprite buttons.'
|
||||
inEdit: 0
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 544aa551098166042af57ffecc053c48
|
||||
timeCreated: 1494449016
|
||||
licenseType: Store
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,111 @@
|
||||
using UnityEngine;
|
||||
namespace Invector.vCharacterController.vActions
|
||||
{
|
||||
/// <summary>
|
||||
/// Define all the Action Controllers.
|
||||
/// </summary>
|
||||
public interface IActionController
|
||||
{
|
||||
bool enabled { get; set; }
|
||||
GameObject gameObject { get; }
|
||||
Transform transform { get; }
|
||||
string name { get; }
|
||||
System.Type GetType();
|
||||
}
|
||||
/// <summary>
|
||||
/// Used to receive Event when do action.
|
||||
/// Ps. Need implementation
|
||||
/// </summary>
|
||||
public interface IActionReceiver : IActionController
|
||||
{
|
||||
void OnReceiveAction(vTriggerGenericAction actionInfo);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Used to register the event <see cref="vCharacter.onActionEnter"/> in the <see cref="vCharacter"/>. Ps.Need implementation
|
||||
/// </summary>
|
||||
public interface IActionEnterListener : IActionController
|
||||
{
|
||||
void OnActionEnter(Collider actionCollider);
|
||||
}
|
||||
/// <summary>
|
||||
/// Used to register the event <see cref="vCharacter.onActionExit"/> in the <see cref="vCharacter"/>. Ps.Need implementation
|
||||
/// </summary>
|
||||
public interface IActionExitListener : IActionController
|
||||
{
|
||||
void OnActionExit(Collider actionCollider);
|
||||
}
|
||||
/// <summary>
|
||||
/// Used to register the event <see cref="vCharacter.onActionStay"/> in the <see cref="vCharacter"/>. Ps. Need implementation
|
||||
/// </summary>
|
||||
public interface IActionStayListener : IActionController
|
||||
{
|
||||
void OnActionStay(Collider actionCollider);
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Used to register the events <see cref="vCharacter.onActionEnter"/>,<see cref="vCharacter.onActionStay"/> and <see cref="vCharacter.onActionExit"/> in the <see cref="vCharacter"/>. Depending of options enabled (<see cref="vActionListener.actionEnter"/>, <see cref="vActionListener.actionStay"/> and <see cref="vActionListener.actionExit"/>). Ps. Need implementation
|
||||
/// </summary>
|
||||
public interface IActionListener : IActionEnterListener, IActionExitListener, IActionStayListener
|
||||
{
|
||||
bool actionEnter { get; set; }
|
||||
bool actionExit { get; set; }
|
||||
bool actionStay { get; set; }
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Implementation of the <see cref="IActionListener"/>.
|
||||
/// Used to register the events <see cref="vCharacter.onActionEnter"/>,<see cref="vCharacter.onActionStay"/> and <see cref="vCharacter.onActionExit"/> in the <see cref="vCharacter"/>.
|
||||
/// Depending of options enabled (<see cref="actionEnter"/>, <see cref="actionStay"/> and <see cref="actionExit"/>). Override <seealso cref="SetUpListener"/> to change default options (all enabled)
|
||||
/// </summary>
|
||||
public abstract class vActionListener : vMonoBehaviour, IActionListener
|
||||
{
|
||||
public bool actionEnter { get; set; }
|
||||
public bool actionExit { get; set; }
|
||||
public bool actionStay { get; set; }
|
||||
protected virtual void Awake()
|
||||
{
|
||||
SetUpListener();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called On Awake
|
||||
/// </summary>
|
||||
protected virtual void SetUpListener()
|
||||
{
|
||||
///Set what kind of action need to use;
|
||||
actionEnter = true;///Use Trigger Enter
|
||||
actionExit = true; ///Use Trigger Exit
|
||||
actionStay = true; ///Use Trigger Stay
|
||||
}
|
||||
|
||||
protected virtual void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void OnActionEnter(Collider other)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void OnActionStay(Collider other)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void OnActionExit(Collider other)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class vOnActionHandle : UnityEngine.Events.UnityEvent<vTriggerGenericAction>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d19b14876bfb07747ab805e15e655f8f
|
||||
timeCreated: 1494029663
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,914 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Invector.vCharacterController.vActions
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using vCharacterController;
|
||||
|
||||
[vClassHeader("GENERIC ACTION", "Use the vTriggerGenericAction to trigger a simple animation.\n<b><size=12>You can use <color=red>vGenericActionReceiver</color> component to filter events by action name</size></b>", iconName = "triggerIcon")]
|
||||
public class vGenericAction : vActionListener
|
||||
{
|
||||
#region Variables
|
||||
|
||||
[vEditorToolbar("Settings")]
|
||||
[Tooltip("Tag of the object you want to access")]
|
||||
public string actionTag = "Action";
|
||||
[Tooltip("Use root motion of the animation")]
|
||||
public bool useRootMotion = true;
|
||||
|
||||
[vEditorToolbar("Debug")]
|
||||
[Header("--- Debug Only ---")]
|
||||
[Tooltip("Check this to enter the debug mode")]
|
||||
public bool debugMode;
|
||||
[vReadOnly] protected vTriggerGenericAction _triggerAction;
|
||||
public virtual vTriggerGenericAction triggerAction { get => _triggerAction; set => _triggerAction = value; }
|
||||
|
||||
[vReadOnly, SerializeField]
|
||||
protected bool _playingAnimation;
|
||||
[vReadOnly, SerializeField]
|
||||
protected bool actionStarted;
|
||||
[vReadOnly]
|
||||
public bool isLockTriggerEvents;
|
||||
[vReadOnly, SerializeField]
|
||||
protected List<Collider> colliders = new List<Collider>();
|
||||
|
||||
[vEditorToolbar("Events")]
|
||||
public vOnActionHandle OnDoAction = new vOnActionHandle();
|
||||
public vOnActionHandle OnEnterTriggerAction;
|
||||
public vOnActionHandle OnExitTriggerAction;
|
||||
public vOnActionHandle OnStartAction;
|
||||
public vOnActionHandle OnCancelAction;
|
||||
public vOnActionHandle OnEndAction;
|
||||
|
||||
public bool doingAction { get; set; }
|
||||
public virtual Camera mainCamera { get; set; }
|
||||
public virtual vThirdPersonInput tpInput { get; set; }
|
||||
protected virtual float _currentInputDelay { get; set; }
|
||||
protected virtual Vector3 _screenCenter { get; set; }
|
||||
protected virtual float timeInTrigger { get; set; }
|
||||
protected virtual float animationBehaviourDelay { get; set; }
|
||||
|
||||
protected bool finishRotationMatch;
|
||||
protected bool finishPositionXZMatch;
|
||||
protected bool finishPositionYMatch;
|
||||
protected virtual Vector3 screenCenter
|
||||
{
|
||||
get
|
||||
{
|
||||
var center = _screenCenter;
|
||||
center.x = Screen.width * 0.5f;
|
||||
center.y = Screen.height * 0.5f;
|
||||
center.z = 0;
|
||||
return _screenCenter = center;
|
||||
}
|
||||
}
|
||||
|
||||
internal Dictionary<Collider, ActionStorage> actions;
|
||||
|
||||
#endregion
|
||||
|
||||
internal class ActionStorage
|
||||
{
|
||||
internal vTriggerGenericAction action;
|
||||
internal bool isValid;
|
||||
internal ActionStorage()
|
||||
{
|
||||
|
||||
}
|
||||
internal ActionStorage(vTriggerGenericAction action)
|
||||
{
|
||||
this.action = action;
|
||||
action.OnValidate.AddListener((GameObject o) => { isValid = true; });
|
||||
action.OnInvalidate.AddListener((GameObject o) => { isValid = false; });
|
||||
}
|
||||
public static implicit operator vTriggerGenericAction(ActionStorage storage)
|
||||
{
|
||||
return storage.action;
|
||||
}
|
||||
public static implicit operator ActionStorage(vTriggerGenericAction action)
|
||||
{
|
||||
return new ActionStorage(action);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SetUpListener()
|
||||
{
|
||||
actionEnter = true;
|
||||
actionStay = true;
|
||||
actionExit = true;
|
||||
actions = new Dictionary<Collider, ActionStorage>();
|
||||
}
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
tpInput = GetComponent<vThirdPersonInput>();
|
||||
|
||||
var actionsReceivers = GetComponentsInChildren<IActionReceiver>();
|
||||
|
||||
for (int i = 0; i < actionsReceivers.Length; i++)
|
||||
{
|
||||
OnDoAction.AddListener(actionsReceivers[i].OnReceiveAction);
|
||||
}
|
||||
|
||||
|
||||
if (tpInput != null)
|
||||
{
|
||||
tpInput.onUpdate -= CheckForTriggerAction;
|
||||
tpInput.onUpdate += CheckForTriggerAction;
|
||||
|
||||
tpInput.onLateUpdate -= UpdateGenericAction;
|
||||
tpInput.onLateUpdate += UpdateGenericAction;
|
||||
}
|
||||
if (!mainCamera)
|
||||
{
|
||||
mainCamera = Camera.main;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void UpdateGenericAction()
|
||||
{
|
||||
if (!mainCamera)
|
||||
{
|
||||
mainCamera = Camera.main;
|
||||
}
|
||||
|
||||
if (!mainCamera)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AnimationBehaviour();
|
||||
HandleColliders();
|
||||
}
|
||||
|
||||
protected virtual void HandleColliders()
|
||||
{
|
||||
colliders.Clear();
|
||||
foreach (var key in actions.Keys)
|
||||
{
|
||||
colliders.Add(key);
|
||||
}
|
||||
if (!doingAction && triggerAction && !isLockTriggerEvents)
|
||||
{
|
||||
if (timeInTrigger <= 0)
|
||||
{
|
||||
actions.Clear();
|
||||
triggerAction = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
timeInTrigger -= Time.deltaTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual bool inActionAnimation
|
||||
{
|
||||
get
|
||||
{
|
||||
return !string.IsNullOrEmpty(triggerAction.playAnimation)
|
||||
&& tpInput.cc.animatorStateInfos.stateInfos[triggerAction.animatorLayer].shortPathHash.Equals(Animator.StringToHash(triggerAction.playAnimation));
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void CheckForTriggerAction()
|
||||
{
|
||||
if (actions.Count == 0 && !triggerAction || isLockTriggerEvents)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vTriggerGenericAction _triggerAction = GetNearAction();
|
||||
if (!doingAction && triggerAction != _triggerAction)
|
||||
{
|
||||
triggerAction = _triggerAction;
|
||||
if (triggerAction)
|
||||
{
|
||||
triggerAction.OnValidate.Invoke(gameObject);
|
||||
OnEnterTriggerAction.Invoke(triggerAction);
|
||||
}
|
||||
}
|
||||
|
||||
TriggerActionInput();
|
||||
}
|
||||
|
||||
protected virtual vTriggerGenericAction GetNearAction()
|
||||
{
|
||||
if (isLockTriggerEvents || doingAction || playingAnimation)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
float distance = Mathf.Infinity;
|
||||
vTriggerGenericAction _targetAction = null;
|
||||
|
||||
foreach (var key in actions.Keys)
|
||||
{
|
||||
if (key)
|
||||
{
|
||||
try
|
||||
{
|
||||
vTriggerGenericAction action = actions[key];
|
||||
var screenP = mainCamera ? mainCamera.WorldToScreenPoint(key.transform.position) : screenCenter;
|
||||
if (mainCamera)
|
||||
{
|
||||
|
||||
bool isValid = action.enabled && action.gameObject.activeInHierarchy && (!action.activeFromForward && (screenP - screenCenter).magnitude < distance || IsInForward(action.transform, action.forwardAngle) && (screenP - screenCenter).magnitude < distance);
|
||||
if (isValid)
|
||||
{
|
||||
distance = (screenP - screenCenter).magnitude;
|
||||
if (_targetAction && _targetAction != action)
|
||||
{
|
||||
if (actions[_targetAction._collider].isValid)
|
||||
{
|
||||
_targetAction.OnInvalidate.Invoke(gameObject);
|
||||
}
|
||||
|
||||
_targetAction = action;
|
||||
}
|
||||
else if (_targetAction == null)
|
||||
{
|
||||
_targetAction = action;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (actions[action._collider].isValid)
|
||||
{
|
||||
action.OnInvalidate.Invoke(gameObject);
|
||||
}
|
||||
|
||||
OnExitTriggerAction.Invoke(triggerAction);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!_targetAction)
|
||||
{
|
||||
_targetAction = action;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (actions[action._collider].isValid)
|
||||
{
|
||||
action.OnInvalidate.Invoke(gameObject);
|
||||
}
|
||||
OnExitTriggerAction.Invoke(triggerAction);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
actions.Remove(key);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return _targetAction;
|
||||
}
|
||||
|
||||
protected virtual bool IsInForward(Transform target, float angleToCompare)
|
||||
{
|
||||
var angle = Vector3.Angle(transform.forward, target.forward);
|
||||
return angle <= angleToCompare;
|
||||
}
|
||||
|
||||
protected virtual void AnimationBehaviour()
|
||||
{
|
||||
if (animationBehaviourDelay > 0 && !playingAnimation)
|
||||
{
|
||||
animationBehaviourDelay -= Time.deltaTime; return;
|
||||
}
|
||||
|
||||
if (playingAnimation)
|
||||
{
|
||||
if (triggerAction.matchTarget != null)
|
||||
{
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log($"<b>GenericAction: </b><color=blue>Match Target...</color> ");
|
||||
}
|
||||
|
||||
EvaluateToTargetPosition();
|
||||
}
|
||||
|
||||
if (triggerAction.useTriggerRotation)
|
||||
{
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log($"<b>GenericAction: </b><color=blue>Rotate to Target...</color> ");
|
||||
}
|
||||
|
||||
EvaluateToTargetRotation();
|
||||
}
|
||||
|
||||
if (actionStarted && !triggerAction.endActionManualy && (triggerAction.inputType != vTriggerGenericAction.InputType.GetButtonTimer || !triggerAction.playAnimationWhileHoldingButton) && tpInput.cc.animatorStateInfos.GetCurrentNormalizedTime(triggerAction.animatorLayer) >= triggerAction.endExitTimeAnimation)
|
||||
{
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log($"<b>GenericAction: </b>Finish Animation ");
|
||||
}
|
||||
// triggers the OnEndAnimation Event
|
||||
EndAction();
|
||||
}
|
||||
}
|
||||
else if (doingAction && actionStarted && (triggerAction == null || !triggerAction.endActionManualy))
|
||||
{
|
||||
//when using a GetButtonTimer the ResetTriggerSettings will be automatically called at the end of the timer or by releasing the input
|
||||
if (triggerAction != null && (triggerAction.inputType == vTriggerGenericAction.InputType.GetButtonTimer && triggerAction.playAnimationWhileHoldingButton))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log($"<b>GenericAction: </b>Force ResetTriggerSettings ");
|
||||
}
|
||||
// triggers the OnEndAnimation Event
|
||||
EndAction();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void EvaluateToTargetPosition()
|
||||
{
|
||||
var matchTargetPosition = triggerAction.matchTarget.position;
|
||||
switch (triggerAction.avatarTarget)
|
||||
{
|
||||
case AvatarTarget.LeftHand:
|
||||
matchTargetPosition = (triggerAction.matchTarget.position - transform.rotation * transform.InverseTransformPoint(tpInput.animator.GetBoneTransform(HumanBodyBones.LeftHand).position));
|
||||
break;
|
||||
case AvatarTarget.RightHand:
|
||||
matchTargetPosition = (triggerAction.matchTarget.position - transform.rotation * transform.InverseTransformPoint(tpInput.animator.GetBoneTransform(HumanBodyBones.RightHand).position));
|
||||
break;
|
||||
case AvatarTarget.LeftFoot:
|
||||
matchTargetPosition = (triggerAction.matchTarget.position - transform.rotation * transform.InverseTransformPoint(tpInput.animator.GetBoneTransform(HumanBodyBones.LeftFoot).position));
|
||||
break;
|
||||
case AvatarTarget.RightFoot:
|
||||
matchTargetPosition = (triggerAction.matchTarget.position - transform.rotation * transform.InverseTransformPoint(tpInput.animator.GetBoneTransform(HumanBodyBones.RightFoot).position));
|
||||
break;
|
||||
}
|
||||
AnimationCurve XZ = triggerAction.matchPositionXZCurve;
|
||||
AnimationCurve Y = triggerAction.matchPositionYCurve;
|
||||
float normalizedTime = Mathf.Clamp(tpInput.cc.animatorStateInfos.GetCurrentNormalizedTime(triggerAction.animatorLayer), 0, 1);
|
||||
|
||||
var localRelativeToTarget = triggerAction.matchTarget.InverseTransformPoint(matchTargetPosition);
|
||||
if (!triggerAction.useLocalX)
|
||||
{
|
||||
localRelativeToTarget.x = triggerAction.matchTarget.InverseTransformPoint(transform.position).x;
|
||||
}
|
||||
|
||||
if (!triggerAction.useLocalZ)
|
||||
{
|
||||
localRelativeToTarget.z = triggerAction.matchTarget.InverseTransformPoint(transform.position).z;
|
||||
}
|
||||
|
||||
matchTargetPosition = triggerAction.matchTarget.TransformPoint(localRelativeToTarget);
|
||||
|
||||
Vector3 rootPosition = tpInput.cc.animator.rootPosition;
|
||||
|
||||
float evaluatedXZ = XZ.Evaluate(normalizedTime);
|
||||
float evaluatedY = Y.Evaluate(normalizedTime);
|
||||
|
||||
if (evaluatedXZ < 1f)
|
||||
{
|
||||
rootPosition.x = Mathf.Lerp(rootPosition.x, matchTargetPosition.x, evaluatedXZ);
|
||||
rootPosition.z = Mathf.Lerp(rootPosition.z, matchTargetPosition.z, evaluatedXZ);
|
||||
finishPositionXZMatch = true;
|
||||
}
|
||||
else if (finishPositionXZMatch)
|
||||
{
|
||||
finishPositionXZMatch = false;
|
||||
rootPosition.x = matchTargetPosition.x;
|
||||
rootPosition.z = matchTargetPosition.z;
|
||||
}
|
||||
if (evaluatedY < 1f)
|
||||
{
|
||||
rootPosition.y = Mathf.Lerp(rootPosition.y, matchTargetPosition.y, evaluatedY);
|
||||
finishPositionYMatch = true;
|
||||
}
|
||||
else if (finishPositionYMatch)
|
||||
{
|
||||
finishPositionYMatch = false;
|
||||
rootPosition.y = matchTargetPosition.y;
|
||||
}
|
||||
|
||||
transform.position = rootPosition;
|
||||
}
|
||||
|
||||
protected virtual void EvaluateToTargetRotation()
|
||||
{
|
||||
var targetEuler = new Vector3(transform.eulerAngles.x, triggerAction.transform.eulerAngles.y, transform.eulerAngles.z);
|
||||
Quaternion targetRotation = Quaternion.Euler(targetEuler);
|
||||
Quaternion rootRotation = tpInput.cc.animator.rootRotation;
|
||||
AnimationCurve rotationCurve = triggerAction.matchRotationCurve;
|
||||
float normalizedTime = tpInput.cc.animatorStateInfos.GetCurrentNormalizedTime(triggerAction.animatorLayer);
|
||||
float evaluatedCurve = rotationCurve.Evaluate(normalizedTime);
|
||||
if (evaluatedCurve < 1)
|
||||
{
|
||||
rootRotation = Quaternion.Lerp(rootRotation, targetRotation, evaluatedCurve);
|
||||
finishRotationMatch = true;
|
||||
}
|
||||
else if (finishRotationMatch)
|
||||
{
|
||||
finishRotationMatch = false;
|
||||
rootRotation = targetRotation;
|
||||
}
|
||||
transform.rotation = rootRotation;
|
||||
}
|
||||
|
||||
protected virtual void EndAction()
|
||||
{
|
||||
OnEndAction.Invoke(triggerAction);
|
||||
|
||||
var trigger = triggerAction;
|
||||
// triggers the OnEndAnimation Event
|
||||
trigger.OnEndAnimation.Invoke();
|
||||
// Exit the trigger
|
||||
OnExitTriggerAction.Invoke(triggerAction);
|
||||
// reset GenericAction variables so you can use it again
|
||||
ResetTriggerSettings();
|
||||
|
||||
// Destroy trigger after reset all settings
|
||||
if (trigger.destroyAfter)
|
||||
{
|
||||
StartCoroutine(DestroyActionDelay(trigger));
|
||||
}
|
||||
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log($"<b>GenericAction: </b>End Action ");
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool playingAnimation
|
||||
{
|
||||
get
|
||||
{
|
||||
if (triggerAction == null || !doingAction)
|
||||
{
|
||||
return _playingAnimation = false;
|
||||
}
|
||||
|
||||
if (!_playingAnimation && inActionAnimation)
|
||||
{
|
||||
_playingAnimation = true;
|
||||
triggerAction.OnStartAnimation.Invoke();
|
||||
DisablePlayerGravityAndCollision();
|
||||
}
|
||||
else if (_playingAnimation && !inActionAnimation)
|
||||
{
|
||||
_playingAnimation = false;
|
||||
}
|
||||
return _playingAnimation;
|
||||
}
|
||||
protected set
|
||||
{
|
||||
_playingAnimation = true;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool actionConditions
|
||||
{
|
||||
get
|
||||
{
|
||||
return (!doingAction && !playingAnimation && !tpInput.cc.isJumping && !tpInput.cc.customAction /*&& !tpInput.cc.animator.IsInTransition(triggerAction.animatorLayer)*/);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnActionEnter(Collider other)
|
||||
{
|
||||
if (isLockTriggerEvents)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (other != null && other.gameObject.CompareTag(actionTag))
|
||||
{
|
||||
if (!actions.ContainsKey(other))
|
||||
{
|
||||
vTriggerGenericAction[] _triggerActions = other.GetComponents<vTriggerGenericAction>();
|
||||
for (int i = 0; i < _triggerActions.Length; i++)
|
||||
{
|
||||
var _triggerAction = _triggerActions[i];
|
||||
if (_triggerAction && _triggerAction.enabled)
|
||||
{
|
||||
actions.Add(other, _triggerAction);
|
||||
_triggerAction.OnPlayerEnter.Invoke(gameObject);
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log("<color=green>Enter in Trigger </color>" + other.gameObject, other.gameObject);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnActionExit(Collider other)
|
||||
{
|
||||
if (isLockTriggerEvents)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (other.gameObject.CompareTag(actionTag) && actions.ContainsKey(other) && (!doingAction || other != triggerAction._collider))
|
||||
{
|
||||
vTriggerGenericAction action = actions[other];
|
||||
actions.Remove(other);
|
||||
action.OnPlayerExit.Invoke(gameObject);
|
||||
action.OnInvalidate.Invoke(gameObject);
|
||||
OnExitTriggerAction.Invoke(action);
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log("<color=red>Exit of Trigger </color> " + other.gameObject, other.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnActionStay(Collider other)
|
||||
{
|
||||
if (isLockTriggerEvents)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (other != null && actions.ContainsKey(other))
|
||||
{
|
||||
|
||||
actions[other].action.OnPlayerStay.Invoke(gameObject);
|
||||
timeInTrigger = .5f;
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log("<color=yellow>Stay in Trigger </color>" + other.gameObject, other.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// End Action Manualy if <see cref="vTriggerGenericAction.endActionManualy"/> equals true
|
||||
/// </summary>
|
||||
public virtual void FinishAction()
|
||||
{
|
||||
if (triggerAction && actionStarted && triggerAction.endActionManualy)
|
||||
{
|
||||
EndAction();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void CancelAction()
|
||||
{
|
||||
if (triggerAction && actionStarted)
|
||||
{
|
||||
var trigger = triggerAction;
|
||||
// triggers the OnEndAnimation Event
|
||||
trigger.OnCancelAction.Invoke();
|
||||
// Exit the trigger
|
||||
OnExitTriggerAction.Invoke(triggerAction);
|
||||
// reset GenericAction variables so you can use it again
|
||||
ResetTriggerSettings();
|
||||
// Destroy trigger after reset all settings
|
||||
if (trigger.destroyAfter)
|
||||
{
|
||||
StartCoroutine(DestroyActionDelay(trigger));
|
||||
}
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log($"<b>GenericAction: </b>Cancel Action ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void TriggerActionInput()
|
||||
{
|
||||
if (triggerAction == null || !triggerAction.gameObject.activeInHierarchy || (triggerAction.CanDoAction == false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// AutoAction
|
||||
if (triggerAction.inputType == vTriggerGenericAction.InputType.AutoAction && actionConditions)
|
||||
{
|
||||
TriggerActionEvents();
|
||||
TriggerAnimation();
|
||||
}
|
||||
// GetButtonDown
|
||||
else if (triggerAction.inputType == vTriggerGenericAction.InputType.GetButtonDown && actionConditions)
|
||||
{
|
||||
if (triggerAction.actionInput.GetButtonDown())
|
||||
{
|
||||
TriggerActionEvents();
|
||||
TriggerAnimation();
|
||||
}
|
||||
}
|
||||
// GetDoubleButton
|
||||
else if (triggerAction.inputType == vTriggerGenericAction.InputType.GetDoubleButton && actionConditions)
|
||||
{
|
||||
if (triggerAction.actionInput.GetDoubleButtonDown(triggerAction.doubleButtomTime))
|
||||
{
|
||||
TriggerActionEvents();
|
||||
TriggerAnimation();
|
||||
}
|
||||
}
|
||||
// GetButtonTimer (Hold Button)
|
||||
else if (triggerAction.inputType == vTriggerGenericAction.InputType.GetButtonTimer)
|
||||
{
|
||||
if (_currentInputDelay <= 0)
|
||||
{
|
||||
var up = false;
|
||||
var t = 0f;
|
||||
|
||||
// this mode will play the animation while you're holding the button
|
||||
if (triggerAction.playAnimationWhileHoldingButton)
|
||||
{
|
||||
TriggerActionEventsInput();
|
||||
|
||||
// call the OnFinishActionInput after the buttomTimer is concluded and reset player settings
|
||||
if (triggerAction.actionInput.GetButtonTimer(ref t, ref up, triggerAction.buttonTimer))
|
||||
{
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log($"<b>GenericAction: </b>Finish Action Input ");
|
||||
}
|
||||
|
||||
triggerAction.UpdateButtonTimer(0);
|
||||
triggerAction.OnFinishActionInput.Invoke();
|
||||
|
||||
ResetActionState();
|
||||
EndAction();
|
||||
//ResetTriggerSettings();
|
||||
}
|
||||
|
||||
// trigger the Animation and the ActionEvents while your hold the button
|
||||
if (triggerAction && triggerAction.actionInput.inButtomTimer)
|
||||
{
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log($"<b>GenericAction: </b><color=blue>Holding Input</color> ");
|
||||
}
|
||||
|
||||
triggerAction.UpdateButtonTimer(t);
|
||||
TriggerAnimation();
|
||||
}
|
||||
|
||||
// call OnCancelActionInput if the button is released before ending the buttonTimer
|
||||
if (up && triggerAction)
|
||||
{
|
||||
CancelButtonTimer();
|
||||
}
|
||||
}
|
||||
// this mode will play the animation after you finish holding the button
|
||||
else /*if (!doingAction)*/
|
||||
{
|
||||
TriggerActionEventsInput();
|
||||
|
||||
// call the OnFinishActionInput after the buttomTimer is concluded and reset player settings
|
||||
if (triggerAction.actionInput.GetButtonTimer(ref t, ref up, triggerAction.buttonTimer))
|
||||
{
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log($"<b>GenericAction: </b>Finish Action Input ");
|
||||
}
|
||||
|
||||
triggerAction.UpdateButtonTimer(0);
|
||||
triggerAction.OnFinishActionInput.Invoke();
|
||||
// destroy the triggerAction if checked with destroyAfter
|
||||
TriggerAnimation();
|
||||
}
|
||||
|
||||
// trigger the ActionEvents while your hold the button
|
||||
if (triggerAction && triggerAction.actionInput.inButtomTimer)
|
||||
{
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log($"<b>GenericAction: </b><color=blue>Holding Input</color>");
|
||||
}
|
||||
|
||||
triggerAction.UpdateButtonTimer(t);
|
||||
}
|
||||
|
||||
// call OnCancelActionInput if the button is released before ending the buttonTimer
|
||||
if (up && triggerAction)
|
||||
{
|
||||
CancelButtonTimer();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentInputDelay -= Time.deltaTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void CancelButtonTimer()
|
||||
{
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log($"<b>GenericAction: </b>Cancel Action ");
|
||||
}
|
||||
|
||||
triggerAction.OnCancelActionInput.Invoke();
|
||||
_currentInputDelay = triggerAction.inputDelay;
|
||||
triggerAction.UpdateButtonTimer(0);
|
||||
OnCancelAction.Invoke(triggerAction);
|
||||
ResetActionState();
|
||||
ResetTriggerSettings(false);
|
||||
}
|
||||
|
||||
protected virtual void TriggerActionEventsInput()
|
||||
{
|
||||
// trigger the ActionEvents while your hold the button
|
||||
if (triggerAction && triggerAction.actionInput.GetButtonDown())
|
||||
{
|
||||
TriggerActionEvents();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void TriggerActionEvents()
|
||||
{
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log($"<b>GenericAction: </b>TriggerAction Events ", gameObject);
|
||||
}
|
||||
|
||||
doingAction = true;
|
||||
// Call OnStartAction from the Controller's GenericAction inspector
|
||||
OnStartAction.Invoke(triggerAction);
|
||||
|
||||
// Call OnDoAction from the Controller's GenericAction
|
||||
OnDoAction.Invoke(triggerAction);
|
||||
|
||||
// trigger OnDoAction Event, you can add a delay in the inspector
|
||||
StartCoroutine(triggerAction.OnPressActionDelay(gameObject));
|
||||
}
|
||||
|
||||
public virtual void TriggerAnimation()
|
||||
{
|
||||
if (playingAnimation || actionStarted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log($"<b>GenericAction: </b>TriggerAnimation ", gameObject);
|
||||
}
|
||||
|
||||
if (triggerAction.animatorActionState != 0)
|
||||
{
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log($"<b>GenericAction: </b>Applied ActionState: " + triggerAction.animatorActionState + " ", gameObject);
|
||||
}
|
||||
|
||||
tpInput.cc.SetActionState(triggerAction.animatorActionState);
|
||||
}
|
||||
|
||||
// trigger the animation behaviour & match target
|
||||
if (!string.IsNullOrEmpty(triggerAction.playAnimation))
|
||||
{
|
||||
if (!actionStarted)
|
||||
{
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log($"<b>GenericAction: </b>PlayAnimation: " + triggerAction.playAnimation + " ", gameObject);
|
||||
}
|
||||
|
||||
actionStarted = true;
|
||||
playingAnimation = true;
|
||||
tpInput.cc.animator.CrossFadeInFixedTime(triggerAction.playAnimation, triggerAction.crossFadeTransition, triggerAction.animatorLayer); // trigger the action animation clip
|
||||
if (!string.IsNullOrEmpty(triggerAction.customCameraState))
|
||||
{
|
||||
tpInput.ChangeCameraState(triggerAction.customCameraState, true); // change current camera state to a custom
|
||||
}
|
||||
}
|
||||
animationBehaviourDelay = triggerAction.crossFadeTransition + 0.1f;
|
||||
}
|
||||
else
|
||||
{
|
||||
actionStarted = true;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void ResetActionState()
|
||||
{
|
||||
if (triggerAction && triggerAction.resetAnimatorActionState)
|
||||
{
|
||||
tpInput.cc.SetActionState(0);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void ResetTriggerSettings(bool removeTrigger = true)
|
||||
{
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log($"<b>GenericAction: </b>Reset Trigger Settings ");
|
||||
}
|
||||
|
||||
// reset player gravity and collision
|
||||
EnablePlayerGravityAndCollision();
|
||||
// reset the Animator parameter ActionState back to 0
|
||||
ResetActionState();
|
||||
// reset the CameraState to the Default state
|
||||
if (triggerAction != null && !string.IsNullOrEmpty(triggerAction.customCameraState))
|
||||
{
|
||||
tpInput.ResetCameraState();
|
||||
}
|
||||
// remove the collider from the actions list
|
||||
if (triggerAction != null && actions.ContainsKey(triggerAction._collider) && removeTrigger)
|
||||
{
|
||||
actions.Remove(triggerAction._collider);
|
||||
}
|
||||
triggerAction = null;
|
||||
doingAction = false;
|
||||
actionStarted = false;
|
||||
}
|
||||
|
||||
public virtual void DisablePlayerGravityAndCollision()
|
||||
{
|
||||
if (triggerAction && triggerAction.disableGravity)
|
||||
{
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log($"<b>GenericAction: </b><color=red>Disable Player's Gravity</color> ");
|
||||
}
|
||||
|
||||
tpInput.cc._rigidbody.useGravity = false;
|
||||
if (!tpInput.cc._rigidbody.isKinematic)
|
||||
tpInput.cc._rigidbody.linearVelocity = Vector3.zero;
|
||||
tpInput.cc._rigidbody.isKinematic = true;
|
||||
}
|
||||
if (triggerAction && triggerAction.disableCollision)
|
||||
{
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log($"<b>GenericAction: </b><color=red>Disable Player's Collision</color> ");
|
||||
}
|
||||
|
||||
tpInput.cc._capsuleCollider.isTrigger = true;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void EnablePlayerGravityAndCollision()
|
||||
{
|
||||
if (triggerAction && triggerAction.disableGravity)
|
||||
{
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log($"<b>GenericAction: </b><color=red>Enable Player's Gravity</color> ");
|
||||
}
|
||||
|
||||
tpInput.cc._rigidbody.useGravity = true;
|
||||
tpInput.cc._rigidbody.isKinematic = false;
|
||||
}
|
||||
if (triggerAction && triggerAction.disableCollision)
|
||||
{
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log($"<b>GenericAction: </b><color=red>Enable Player's Collision</color> ");
|
||||
}
|
||||
|
||||
tpInput.cc._capsuleCollider.isTrigger = false;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual IEnumerator DestroyActionDelay(vTriggerGenericAction triggerAction)
|
||||
{
|
||||
var _triggerAction = triggerAction;
|
||||
yield return new WaitForSeconds(_triggerAction.destroyDelay);
|
||||
if (_triggerAction != null && _triggerAction.gameObject != null)
|
||||
{
|
||||
OnExitTriggerAction.Invoke(triggerAction);
|
||||
Destroy(_triggerAction.gameObject);
|
||||
}
|
||||
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log($"<b>GenericAction: </b>Destroy Trigger ");
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void SetLockTriggerEvents(bool value)
|
||||
{
|
||||
foreach (var key in actions.Keys)
|
||||
{
|
||||
if (key)
|
||||
{
|
||||
actions[key].action.OnPlayerExit.Invoke(gameObject);
|
||||
actions[key].action.OnInvalidate.Invoke(gameObject);
|
||||
}
|
||||
}
|
||||
actions.Clear();
|
||||
isLockTriggerEvents = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f1660eeab87ecf543be4a3ca42e6e836
|
||||
timeCreated: 1493315378
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,106 @@
|
||||
using System.Collections.Generic;
|
||||
namespace Invector.vCharacterController.vActions
|
||||
{
|
||||
/// <summary>
|
||||
/// Generic Action receiver for <seealso cref="vGenericAction"/> events.
|
||||
/// Use this component inside character with <see cref="vGenericAction"/> component.
|
||||
/// This is usefull for trigger events based in the <seealso cref="vTriggerGenericAction.actionName"/>.
|
||||
/// </summary>
|
||||
[vClassHeader("Action Receiver")]
|
||||
public class vGenericActionReceiver : vMonoBehaviour
|
||||
{
|
||||
public List<string> supportedActionNames = new List<string>() { "Action" };
|
||||
public UnityEngine.Events.UnityEvent onEnterTriggerAction;
|
||||
public UnityEngine.Events.UnityEvent onExitTriggerAction;
|
||||
public UnityEngine.Events.UnityEvent onStartAction;
|
||||
public UnityEngine.Events.UnityEvent onCancelAction;
|
||||
public UnityEngine.Events.UnityEvent onEndAction;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
vGenericAction genericAction = gameObject.GetComponentInParent<vGenericAction>();
|
||||
if (genericAction)
|
||||
{
|
||||
genericAction.OnEnterTriggerAction.AddListener(OnEnterTriggerAction);
|
||||
genericAction.OnExitTriggerAction.AddListener(OnExitTriggerAction);
|
||||
genericAction.OnStartAction.AddListener(OnStartAction);
|
||||
genericAction.OnCancelAction.AddListener(OnCancelAction);
|
||||
genericAction.OnEndAction.AddListener(OnEndAction);
|
||||
}
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
vGenericAction genericAction = GetComponentInParent<vGenericAction>();
|
||||
if (genericAction)
|
||||
{
|
||||
genericAction.OnEnterTriggerAction.RemoveListener(OnEnterTriggerAction);
|
||||
genericAction.OnExitTriggerAction.RemoveListener(OnExitTriggerAction);
|
||||
genericAction.OnStartAction.RemoveListener(OnStartAction);
|
||||
genericAction.OnCancelAction.RemoveListener(OnCancelAction);
|
||||
genericAction.OnEndAction.RemoveListener(OnEndAction);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual bool IsValidAction(vTriggerGenericAction actionInfo)
|
||||
{
|
||||
bool isValid = this.enabled && this.gameObject.activeInHierarchy && actionInfo != null && supportedActionNames.Contains(actionInfo.actionName);
|
||||
return isValid;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event called when Enter in trigger
|
||||
/// </summary>
|
||||
/// <param name="actionInfo"></param>
|
||||
public virtual void OnEnterTriggerAction(vTriggerGenericAction actionInfo)
|
||||
{
|
||||
if (IsValidAction(actionInfo))
|
||||
{
|
||||
onEnterTriggerAction.Invoke();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Event Called when exit Trigger
|
||||
/// </summary>
|
||||
/// <param name="actionInfo"></param>
|
||||
public virtual void OnExitTriggerAction(vTriggerGenericAction actionInfo)
|
||||
{
|
||||
if (IsValidAction(actionInfo))
|
||||
{
|
||||
onExitTriggerAction.Invoke();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Event called when action is started
|
||||
/// </summary>
|
||||
/// <param name="actionInfo"></param>
|
||||
public virtual void OnStartAction(vTriggerGenericAction actionInfo)
|
||||
{
|
||||
if (IsValidAction(actionInfo))
|
||||
{
|
||||
onStartAction.Invoke();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Event called when action is canceled
|
||||
/// </summary>
|
||||
/// <param name="actionInfo"></param>
|
||||
public virtual void OnCancelAction(vTriggerGenericAction actionInfo)
|
||||
{
|
||||
if (IsValidAction(actionInfo))
|
||||
{
|
||||
onCancelAction.Invoke();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Event called when action is finished or canceled
|
||||
/// </summary>
|
||||
/// <param name="actionInfo"></param>
|
||||
public virtual void OnEndAction(vTriggerGenericAction actionInfo)
|
||||
{
|
||||
if (IsValidAction(actionInfo))
|
||||
{
|
||||
onEndAction.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4dc232b8e1716b046831c15cc4cda895
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,76 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace Invector.vCharacterController.vActions
|
||||
{
|
||||
[vClassHeader("Generic Animation", "Use this script to trigger a simple animation.")]
|
||||
public class vGenericAnimation : vMonoBehaviour
|
||||
{
|
||||
#region Variables
|
||||
|
||||
[Tooltip("Input to trigger the custom animation")]
|
||||
public GenericInput actionInput = new GenericInput("L", "A", "A");
|
||||
[Tooltip("Name of the animation clip")]
|
||||
public string animationClip;
|
||||
[Tooltip("Where in the end of the animation will trigger the event OnEndAnimation")]
|
||||
public float animationEnd = 0.8f;
|
||||
|
||||
public UnityEvent OnPlayAnimation;
|
||||
public UnityEvent OnEndAnimation;
|
||||
|
||||
protected bool isPlaying;
|
||||
protected bool triggerOnce;
|
||||
protected vThirdPersonInput tpInput;
|
||||
|
||||
#endregion
|
||||
|
||||
protected virtual void Start()
|
||||
{
|
||||
tpInput = GetComponent<vThirdPersonInput>();
|
||||
}
|
||||
|
||||
protected virtual void LateUpdate()
|
||||
{
|
||||
TriggerAnimation();
|
||||
AnimationBehaviour();
|
||||
}
|
||||
|
||||
protected virtual void TriggerAnimation()
|
||||
{
|
||||
// condition to trigger the animation
|
||||
bool playConditions = !isPlaying && !tpInput.cc.customAction && !string.IsNullOrEmpty(animationClip);
|
||||
|
||||
if (actionInput.GetButtonDown() && playConditions)
|
||||
PlayAnimation();
|
||||
}
|
||||
|
||||
public virtual void PlayAnimation()
|
||||
{
|
||||
// we use a bool to trigger the event just once at the end of the animation
|
||||
triggerOnce = true;
|
||||
// trigger the OnPlay Event
|
||||
OnPlayAnimation.Invoke();
|
||||
// trigger the animationClip
|
||||
tpInput.cc.animator.CrossFadeInFixedTime(animationClip, 0.1f);
|
||||
}
|
||||
|
||||
protected virtual void AnimationBehaviour()
|
||||
{
|
||||
// know if the animation is playing or not
|
||||
isPlaying = tpInput.cc.baseLayerInfo.IsName(animationClip);
|
||||
|
||||
if (isPlaying)
|
||||
{
|
||||
// detected the end of the animation clip to trigger the OnEndAnimation Event
|
||||
if (tpInput.cc.animator.GetCurrentAnimatorStateInfo(0).normalizedTime >= animationEnd)
|
||||
{
|
||||
if (triggerOnce)
|
||||
{
|
||||
triggerOnce = false; // reset the bool so we can call the event again
|
||||
OnEndAnimation.Invoke(); // call the OnEnd Event at the end of the animation
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab01fc92c35bcd64681457359b1685c0
|
||||
timeCreated: 1495501541
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,614 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
namespace Invector.vCharacterController.vActions
|
||||
{
|
||||
[vClassHeader("Ladder Action", iconName = "ladderIcon")]
|
||||
public class vLadderAction : vActionListener
|
||||
{
|
||||
#region public variables
|
||||
|
||||
[vEditorToolbar("Settings", overrideChildOrder: true, order = 0)]
|
||||
[Tooltip("Tag of the object you want to access")]
|
||||
public string actionTag = "LadderTrigger";
|
||||
[Tooltip("Speed multiplier for the climb ladder animations")]
|
||||
public float climbSpeed = 1.5f;
|
||||
[Tooltip("Speed multiplier for the climb ladder animations when the fastClimbInput is pressed")]
|
||||
public float fastClimbSpeed = 3f;
|
||||
[Tooltip("How much Stamina will be consumed when climbing faster")]
|
||||
public float fastClimbStamina = 30f;
|
||||
[Tooltip("Input to use the ladder going up or down")]
|
||||
public GenericInput verticalInput = new GenericInput("Vertical", "LeftAnalogVertical", "Vertical");
|
||||
[Tooltip("Input to enter the ladder")]
|
||||
public GenericInput enterInput = new GenericInput("E", "A", "A");
|
||||
[Tooltip("Input to exit the ladder")]
|
||||
public GenericInput exitInput = new GenericInput("Space", "B", "B");
|
||||
[Tooltip("Input to climb faster")]
|
||||
public GenericInput fastClimbInput = new GenericInput("LeftShift", "LeftStickClick", "LeftStickClick");
|
||||
[Tooltip("Input to climb faster")]
|
||||
public GenericInput slideDownInput = new GenericInput("Q", "X", "X");
|
||||
|
||||
|
||||
[vEditorToolbar("Events")]
|
||||
public UnityEvent OnEnterLadder;
|
||||
public UnityEvent OnExitLadder;
|
||||
public UnityEvent OnEnterTriggerLadder;
|
||||
public UnityEvent OnExitTriggerLadder;
|
||||
|
||||
|
||||
[vEditorToolbar("Debug")]
|
||||
public bool debugMode;
|
||||
[vReadOnly(false)]
|
||||
[SerializeField]
|
||||
protected vTriggerLadderAction targetLadderAction;
|
||||
[vReadOnly(false)]
|
||||
[SerializeField]
|
||||
protected vTriggerLadderAction currentLadderAction;
|
||||
//[vReadOnly(false)]
|
||||
//[SerializeField]
|
||||
protected List<vTriggerLadderAction> actionTriggers = new List<vTriggerLadderAction>();
|
||||
[vReadOnly(false)]
|
||||
[SerializeField]
|
||||
protected float _speed;
|
||||
protected virtual float speed { get { return _speed; } set { _speed = value; } }
|
||||
[vReadOnly(false)]
|
||||
[SerializeField]
|
||||
protected float currentClimbSpeed;
|
||||
[vReadOnly(false)]
|
||||
[SerializeField]
|
||||
protected bool _isUsingLadder;
|
||||
public virtual bool isUsingLadder { get { return _isUsingLadder; } set { _isUsingLadder = value; } }
|
||||
[vReadOnly(false)]
|
||||
[SerializeField]
|
||||
protected bool enterLadderStarted;
|
||||
[vReadOnly(false)]
|
||||
[SerializeField]
|
||||
protected bool inEnterLadderAnimation;
|
||||
[vReadOnly(false)]
|
||||
[SerializeField]
|
||||
protected bool inExitingLadderAnimation;
|
||||
[vReadOnly(false)]
|
||||
[SerializeField]
|
||||
protected bool triggerEnterOnce;
|
||||
[vReadOnly(false)]
|
||||
[SerializeField]
|
||||
protected bool triggerExitOnce;
|
||||
|
||||
#endregion
|
||||
|
||||
protected vThirdPersonInput tpInput;
|
||||
protected bool isAligningMidAir;
|
||||
|
||||
protected override void SetUpListener()
|
||||
{
|
||||
actionEnter = false;
|
||||
actionStay = true;
|
||||
actionExit = true;
|
||||
}
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
tpInput = GetComponent<vThirdPersonInput>();
|
||||
if (tpInput)
|
||||
{
|
||||
tpInput.onUpdate -= UpdateLadderBehavior;
|
||||
tpInput.onUpdate += UpdateLadderBehavior;
|
||||
|
||||
tpInput.onAnimatorMove -= UsingLadder;
|
||||
tpInput.onAnimatorMove += UsingLadder;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void UpdateLadderBehavior()
|
||||
{
|
||||
AutoEnterLadder();
|
||||
EnterLadderInput();
|
||||
ExitLadderInput();
|
||||
}
|
||||
|
||||
protected virtual void EnterLadderInput()
|
||||
{
|
||||
if (targetLadderAction == null || tpInput.cc.customAction || tpInput.cc.isJumping || !tpInput.cc.isGrounded || tpInput.cc.isRolling)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (enterInput.GetButtonDown() && !enterLadderStarted && !isUsingLadder && !targetLadderAction.autoAction)
|
||||
{
|
||||
TriggerEnterLadder();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void ExitLadderInput()
|
||||
{
|
||||
if (!isUsingLadder)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (tpInput.cc.baseLayerInfo.IsName("EnterLadderTop") || tpInput.cc.baseLayerInfo.IsName("EnterLadderBottom"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetLadderAction == null)
|
||||
{
|
||||
if (tpInput.cc.IsAnimatorTag("ClimbLadder"))
|
||||
{
|
||||
if (slideDownInput.GetButtonDown() && !inExitingLadderAnimation)
|
||||
{
|
||||
tpInput.cc.animator.CrossFadeInFixedTime("Ladder_SlideDown", 0.2f);
|
||||
}
|
||||
|
||||
// exit ladder at any moment by pressing the cancelInput
|
||||
if (exitInput.GetButtonDown())
|
||||
{
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log("Quick Exit..." + currentLadderAction.name + "_" + currentLadderAction.transform.parent.gameObject.name);
|
||||
}
|
||||
tpInput.cc.animator.speed = 1;
|
||||
tpInput.cc.animator.CrossFadeInFixedTime("QuickExitLadder", 0.1f);
|
||||
Invoke("ResetPlayerSettings", .5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
currentLadderAction = targetLadderAction;
|
||||
var animationClip = targetLadderAction.exitAnimation;
|
||||
if (animationClip == "ExitLadderBottom")
|
||||
{
|
||||
// exit ladder when reach the bottom by pressing the cancelInput or pressing down at
|
||||
if (exitInput.GetButtonDown() && !triggerExitOnce || (speed <= -0.05f && !triggerExitOnce) || (tpInput.cc.IsAnimatorTag("LadderSlideDown") && targetLadderAction != null && !triggerExitOnce))
|
||||
{
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log("Exit Bottom..." + currentLadderAction.name + "_" + currentLadderAction.transform.parent.gameObject.name);
|
||||
}
|
||||
triggerExitOnce = true;
|
||||
tpInput.cc.animator.CrossFadeInFixedTime(targetLadderAction.exitAnimation, 0.1f); // trigger the animation clip
|
||||
}
|
||||
}
|
||||
else if (animationClip == "ExitLadderTop" && tpInput.cc.IsAnimatorTag("ClimbLadder")) // exit the ladder from the top
|
||||
{
|
||||
if ((speed >= 0.05f) && !triggerExitOnce && !tpInput.cc.animator.IsInTransition(0)) // trigger the exit animation by pressing up
|
||||
{
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log("Exit Top..." + currentLadderAction.name + "_" + currentLadderAction.transform.parent.gameObject.name);
|
||||
}
|
||||
triggerExitOnce = true;
|
||||
tpInput.cc.animator.CrossFadeInFixedTime(targetLadderAction.exitAnimation, 0.1f); // trigger the animation clip
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void AutoEnterLadder()
|
||||
{
|
||||
if (targetLadderAction == null || !targetLadderAction.autoAction)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (tpInput.cc.customAction || isUsingLadder || tpInput.cc.animator.IsInTransition(0) || tpInput.cc.isRolling)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// enter the ladder automatically if checked with autoAction
|
||||
if (targetLadderAction.autoAction && tpInput.cc.input != Vector3.zero && !tpInput.cc.customAction)
|
||||
{
|
||||
var inputDir = Camera.main.transform.TransformDirection(new Vector3(tpInput.cc.input.x, 0f, tpInput.cc.input.z));
|
||||
inputDir.y = 0f;
|
||||
var dist = Vector3.Distance(inputDir.normalized, targetLadderAction.transform.forward);
|
||||
if (dist < 0.8f)
|
||||
{
|
||||
TriggerEnterLadder();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void TriggerMidAirEnterLadder(vTriggerLadderMiddle ladderMiddle)
|
||||
{
|
||||
if (tpInput.cc.isGrounded || isAligningMidAir) return;
|
||||
|
||||
isAligningMidAir = true;
|
||||
|
||||
Vector3 pos = ladderMiddle.refTarget.position;
|
||||
bool pointFounded = false;
|
||||
float distance = Vector3.Distance(pos, transform.position);
|
||||
int steps = (int)(ladderMiddle._collider.size.y / ladderMiddle.stepHeight);
|
||||
|
||||
for (int i = 0; i < steps; i++)
|
||||
{
|
||||
pos = ladderMiddle.refTarget.position + ladderMiddle.transform.up * ladderMiddle.stepHeight * i;
|
||||
var _distance = Vector3.Distance(pos, transform.position);
|
||||
|
||||
if (_distance <= distance)
|
||||
{
|
||||
distance = _distance;
|
||||
pointFounded = true;
|
||||
}
|
||||
else if (pointFounded)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
tpInput.cc.DisableGravityAndCollision();
|
||||
tpInput.cc.isCrouching = false;
|
||||
tpInput.cc.ControlCapsuleHeight();
|
||||
tpInput.UpdateCameraStates();
|
||||
tpInput.cc.UpdateAnimator();
|
||||
|
||||
triggerEnterOnce = true;
|
||||
enterLadderStarted = true;
|
||||
tpInput.cc.animator.SetInteger(vAnimatorParameters.ActionState, 1); // set actionState 1 to avoid falling transitions
|
||||
|
||||
tpInput.cc.StopCharacter();
|
||||
tpInput.SetLockAllInput(true);
|
||||
tpInput.cc.ResetInputAnimatorParameters();
|
||||
|
||||
var localPos = ladderMiddle.transform.InverseTransformPoint(transform.position);
|
||||
if (localPos.x >= 0f)
|
||||
tpInput.cc.animator.CrossFadeInFixedTime("IdleLadder_Left", 0.25f); // trigger the action animation clip
|
||||
else
|
||||
tpInput.cc.animator.CrossFadeInFixedTime("IdleLadder_Right", 0.25f); // trigger the action animation clip
|
||||
|
||||
tpInput.cc.disableAnimations = true;
|
||||
|
||||
StartCoroutine(AlignToMiddleLadder(pos, ladderMiddle.refTarget.rotation));
|
||||
}
|
||||
|
||||
IEnumerator AlignToMiddleLadder(Vector3 pos, Quaternion rot)
|
||||
{
|
||||
float time = 0f;
|
||||
Vector3 position = transform.position;
|
||||
Quaternion rotation = transform.rotation;
|
||||
|
||||
while (time <= 1f)
|
||||
{
|
||||
transform.position = Vector3.Lerp(position, pos, time);
|
||||
transform.rotation = Quaternion.Lerp(rotation, rot, time);
|
||||
|
||||
time += Time.fixedDeltaTime * 8f;
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
transform.position = pos;
|
||||
transform.rotation = rot;
|
||||
yield return null;
|
||||
}
|
||||
while (tpInput.cc.animator.IsInTransition(0));
|
||||
yield return new WaitForEndOfFrame();
|
||||
isUsingLadder = true;
|
||||
isAligningMidAir = false;
|
||||
}
|
||||
|
||||
protected virtual void TriggerEnterLadder()
|
||||
{
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log("Enter Ladder");
|
||||
}
|
||||
|
||||
OnExitTriggerLadder.Invoke();
|
||||
|
||||
if (targetLadderAction.targetCharacterParent)
|
||||
{
|
||||
transform.parent = targetLadderAction.targetCharacterParent;
|
||||
}
|
||||
|
||||
tpInput.cc.isCrouching = false;
|
||||
tpInput.cc.ControlCapsuleHeight();
|
||||
tpInput.UpdateCameraStates();
|
||||
tpInput.cc.UpdateAnimator();
|
||||
OnEnterLadder.Invoke();
|
||||
triggerEnterOnce = true;
|
||||
enterLadderStarted = true;
|
||||
tpInput.cc.animator.SetInteger(vAnimatorParameters.ActionState, 1); // set actionState 1 to avoid falling transitions
|
||||
tpInput.SetLockAllInput(true);
|
||||
tpInput.cc.ResetInputAnimatorParameters();
|
||||
targetLadderAction.OnDoAction.Invoke();
|
||||
currentLadderAction = targetLadderAction;
|
||||
//tpInput.cc.animator.updateMode = AnimatorUpdateMode.Normal;
|
||||
if (!string.IsNullOrEmpty(currentLadderAction.playAnimation))
|
||||
{
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log("TriggerAnimation " + currentLadderAction.name + "_" + currentLadderAction.transform.parent.gameObject.name);
|
||||
}
|
||||
|
||||
tpInput.cc.animator.CrossFadeInFixedTime(currentLadderAction.playAnimation, 0.25f); // trigger the action animation clip
|
||||
isUsingLadder = true;
|
||||
tpInput.cc.disableAnimations = true;
|
||||
tpInput.cc.StopCharacter();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void UsingLadder()
|
||||
{
|
||||
if (!isUsingLadder)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// update the base layer to know what animations are being played
|
||||
tpInput.cc.AnimatorLayerControl();
|
||||
tpInput.cc.ActionsControl();
|
||||
// update camera movement
|
||||
tpInput.CameraInput();
|
||||
|
||||
// go up or down
|
||||
speed = verticalInput.GetAxis();
|
||||
tpInput.cc.animator.SetFloat(vAnimatorParameters.InputVertical, speed, 0.1f, Time.deltaTime);
|
||||
if (speed >= 0.05f || speed <= -0.05f)
|
||||
{
|
||||
tpInput.cc.animator.speed = Mathf.Lerp(tpInput.cc.animator.speed, currentClimbSpeed, 2f * Time.deltaTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
tpInput.cc.animator.speed = Mathf.Lerp(tpInput.cc.animator.speed, 1f, 2f * Time.deltaTime);
|
||||
}
|
||||
|
||||
// increase speed by input and consume stamina
|
||||
if (fastClimbInput.GetButton() && tpInput.cc.currentStamina > 0)
|
||||
{
|
||||
currentClimbSpeed = fastClimbSpeed;
|
||||
StaminaConsumption();
|
||||
}
|
||||
else
|
||||
{
|
||||
currentClimbSpeed = climbSpeed;
|
||||
}
|
||||
|
||||
// enter ladder behaviour
|
||||
var _inEnterLadderAnimation = tpInput.cc.baseLayerInfo.IsName("EnterLadderTop") || tpInput.cc.baseLayerInfo.IsName("EnterLadderBottom") && !tpInput.cc.animator.IsInTransition(0);
|
||||
|
||||
if (_inEnterLadderAnimation)
|
||||
{
|
||||
this.inEnterLadderAnimation = true;
|
||||
|
||||
tpInput.cc.DisableGravityAndCollision(); // disable gravity & turn collision trigger
|
||||
// disable ingame hud
|
||||
if (currentLadderAction != null)
|
||||
{
|
||||
currentLadderAction.OnPlayerExit.Invoke();
|
||||
}
|
||||
|
||||
if (currentLadderAction.useTriggerRotation)
|
||||
{
|
||||
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log("Rotating to target..." + currentLadderAction.name + "_" + currentLadderAction.transform.parent.gameObject.name);
|
||||
}
|
||||
EvaluateToRotation(currentLadderAction.enterRotationCurve, currentLadderAction.matchTarget.transform.rotation, tpInput.cc.baseLayerInfo.normalizedTime);
|
||||
}
|
||||
|
||||
if (currentLadderAction.matchTarget != null)
|
||||
{
|
||||
if (transform.parent != currentLadderAction.targetCharacterParent)
|
||||
{
|
||||
transform.parent = currentLadderAction.targetCharacterParent;
|
||||
}
|
||||
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log("Match Target to Enter..." + currentLadderAction.name + "_" + currentLadderAction.transform.parent.gameObject.name);
|
||||
}
|
||||
|
||||
EvaluateToPosition(currentLadderAction.enterPositionXZCurve, currentLadderAction.enterPositionYCurve, currentLadderAction.matchTarget.position, tpInput.cc.baseLayerInfo.normalizedTime);
|
||||
}
|
||||
}
|
||||
|
||||
if (!_inEnterLadderAnimation && inEnterLadderAnimation)
|
||||
{
|
||||
enterLadderStarted = false;
|
||||
inEnterLadderAnimation = false;
|
||||
}
|
||||
TriggerExitLadder();
|
||||
}
|
||||
|
||||
protected virtual void TriggerExitLadder()
|
||||
{
|
||||
// exit ladder behaviour
|
||||
inExitingLadderAnimation = tpInput.cc.baseLayerInfo.IsName("ExitLadderTop") || tpInput.cc.baseLayerInfo.IsName("ExitLadderBottom") || tpInput.cc.baseLayerInfo.IsName("QuickExitLadder");
|
||||
|
||||
if (inExitingLadderAnimation)
|
||||
{
|
||||
tpInput.cc.animator.speed = 1;
|
||||
|
||||
if (currentLadderAction.exitMatchTarget != null && !tpInput.cc.baseLayerInfo.IsName("QuickExitLadder"))
|
||||
{
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log("Match Target to exit..." + currentLadderAction.name + "_" + currentLadderAction.transform.parent.gameObject.name);
|
||||
}
|
||||
|
||||
EvaluateToPosition(currentLadderAction.exitPositionXZCurve, currentLadderAction.exitPositionYCurve, currentLadderAction.exitMatchTarget.position, tpInput.cc.baseLayerInfo.normalizedTime);
|
||||
}
|
||||
var newRot = new Vector3(0, tpInput.animator.rootRotation.eulerAngles.y, 0);
|
||||
EvaluateToRotation(currentLadderAction.exitRotationCurve, Quaternion.Euler(newRot), tpInput.cc.baseLayerInfo.normalizedTime);
|
||||
|
||||
if (tpInput.cc.baseLayerInfo.normalizedTime >= 0.8f)
|
||||
{
|
||||
// after playing the animation we reset some values
|
||||
ResetPlayerSettings();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void EvaluateToPosition(AnimationCurve XZ, AnimationCurve Y, Vector3 targetPosition, float normalizedTime)
|
||||
{
|
||||
Vector3 rootPosition = tpInput.cc.animator.rootPosition;
|
||||
|
||||
float evaluatedXZ = XZ.Evaluate(normalizedTime);
|
||||
float evaluatedY = Y.Evaluate(normalizedTime);
|
||||
|
||||
if (evaluatedXZ < 1f)
|
||||
{
|
||||
rootPosition.x = Mathf.Lerp(rootPosition.x, targetPosition.x, evaluatedXZ);
|
||||
rootPosition.z = Mathf.Lerp(rootPosition.z, targetPosition.z, evaluatedXZ);
|
||||
}
|
||||
|
||||
if (evaluatedY < 1f)
|
||||
{
|
||||
rootPosition.y = Mathf.Lerp(rootPosition.y, targetPosition.y, evaluatedY);
|
||||
}
|
||||
|
||||
transform.position = rootPosition;
|
||||
}
|
||||
|
||||
protected virtual void EvaluateToRotation(AnimationCurve curve, Quaternion targetRotation, float normalizedTime)
|
||||
{
|
||||
Quaternion rootRotation = tpInput.cc.animator.rootRotation;
|
||||
float evaluatedCurve = curve.Evaluate(normalizedTime);
|
||||
if (evaluatedCurve < 1)
|
||||
{
|
||||
rootRotation = Quaternion.Lerp(rootRotation, targetRotation, evaluatedCurve);
|
||||
}
|
||||
transform.rotation = rootRotation;
|
||||
}
|
||||
|
||||
protected virtual void StaminaConsumption()
|
||||
{
|
||||
if (tpInput.cc.currentStamina <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
tpInput.cc.ReduceStamina(fastClimbStamina, true); // call the ReduceStamina method from the player
|
||||
tpInput.cc.currentStaminaRecoveryDelay = 0.25f; // delay to start recovery stamina
|
||||
}
|
||||
|
||||
protected virtual void AddLadderTrigger(vTriggerLadderAction _ladderAction)
|
||||
{
|
||||
if (targetLadderAction != _ladderAction)
|
||||
{
|
||||
targetLadderAction = _ladderAction;
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log("TriggerStay " + targetLadderAction.name + "_" + targetLadderAction.transform.parent.gameObject.name);
|
||||
}
|
||||
}
|
||||
|
||||
if (!actionTriggers.Contains(targetLadderAction))
|
||||
{
|
||||
actionTriggers.Add(targetLadderAction);
|
||||
targetLadderAction.OnPlayerEnter.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void RemoveLadderTrigger(vTriggerLadderAction _ladderAction)
|
||||
{
|
||||
if (_ladderAction == targetLadderAction)
|
||||
{
|
||||
targetLadderAction = null;
|
||||
}
|
||||
|
||||
if (actionTriggers.Contains(_ladderAction))
|
||||
{
|
||||
actionTriggers.Remove(_ladderAction);
|
||||
_ladderAction.OnPlayerExit.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void CheckForTriggerAction(Collider other)
|
||||
{
|
||||
// assign the component - it will be null when he exit the trigger area
|
||||
var _ladderAction = other.GetComponent<vTriggerLadderAction>();
|
||||
if (!_ladderAction)
|
||||
{
|
||||
AddLadderTrigger(_ladderAction);
|
||||
return;
|
||||
}
|
||||
// check the maxAngle too see if the character can do the action
|
||||
var dist = Vector3.Distance(transform.forward, _ladderAction.transform.forward);
|
||||
|
||||
if (isUsingLadder && _ladderAction != null)
|
||||
{
|
||||
if (targetLadderAction != _ladderAction)
|
||||
{
|
||||
targetLadderAction = _ladderAction;
|
||||
if (!actionTriggers.Contains(targetLadderAction))
|
||||
{
|
||||
actionTriggers.Add(targetLadderAction);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((_ladderAction.activeFromForward == false || dist <= 0.8f) && !isUsingLadder)
|
||||
{
|
||||
AddLadderTrigger(_ladderAction);
|
||||
OnEnterTriggerLadder.Invoke();
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoveLadderTrigger(_ladderAction);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void ResetPlayerSettings()
|
||||
{
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log("Reset Player Settings");
|
||||
}
|
||||
|
||||
speed = 0f;
|
||||
targetLadderAction = null;
|
||||
isUsingLadder = false;
|
||||
OnExitLadder.Invoke();
|
||||
triggerExitOnce = false;
|
||||
triggerEnterOnce = false;
|
||||
inEnterLadderAnimation = false;
|
||||
enterLadderStarted = false;
|
||||
tpInput.cc.animator.SetInteger(vAnimatorParameters.ActionState, 0);
|
||||
tpInput.cc.EnableGravityAndCollision();
|
||||
tpInput.SetLockAllInput(false);
|
||||
tpInput.cc.StopCharacter();
|
||||
tpInput.cc.disableAnimations = false;
|
||||
//tpInput.cc.animator.updateMode = AnimatorUpdateMode.AnimatePhysics;
|
||||
if (transform.parent != null)
|
||||
{
|
||||
transform.parent = null;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnActionStay(Collider other)
|
||||
{
|
||||
if (other.gameObject.CompareTag(actionTag))
|
||||
{
|
||||
CheckForTriggerAction(other);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnActionExit(Collider other)
|
||||
{
|
||||
if (other.gameObject.CompareTag(actionTag))
|
||||
{
|
||||
var _ladderAction = other.GetComponent<vTriggerLadderAction>();
|
||||
if (!_ladderAction)
|
||||
{
|
||||
return;
|
||||
}
|
||||
RemoveLadderTrigger(_ladderAction);
|
||||
if (debugMode)
|
||||
{
|
||||
Debug.Log("TriggerExit " + other.name + "_" + other.transform.parent.gameObject.name);
|
||||
}
|
||||
|
||||
OnExitTriggerLadder.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7d2c95dd758dfa4469068df6a1432f05
|
||||
timeCreated: 1493405773
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
using Invector;
|
||||
using Invector.vCharacterController.vActions;
|
||||
using System.Collections.Generic;
|
||||
|
||||
[vClassHeader("Trigger Action Event", helpBoxText = "Use this to filter a specific TriggerAction so you can use Events with the Controller or components attached to the Controller", useHelpBox = true)]
|
||||
public class vTriggerActionEvent : vMonoBehaviour
|
||||
{
|
||||
public List<ActionEvent> actionFinders;
|
||||
|
||||
public void TriggerEvent(vTriggerGenericAction action)
|
||||
{
|
||||
var _action = actionFinders.Find(a => a.actionName.Equals(action.gameObject.name));
|
||||
|
||||
if (_action != null)
|
||||
{
|
||||
_action.onTriggerEvent.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class ActionEvent
|
||||
{
|
||||
public string actionName;
|
||||
public UnityEngine.Events.UnityEvent onTriggerEvent;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48a88010f5c98cd4cbe92201839efbfc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,172 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Invector.vCharacterController.vActions
|
||||
{
|
||||
[vClassHeader("Trigger Generic Action", openClose = true, iconName = "triggerIcon")]
|
||||
public class vTriggerGenericAction : vMonoBehaviour
|
||||
{
|
||||
[vEditorToolbar("Input", order = 1)]
|
||||
|
||||
public InputType inputType = InputType.GetButtonDown;
|
||||
|
||||
[Tooltip("Input to make the action")]
|
||||
public GenericInput actionInput = new GenericInput("E", "A", "A");
|
||||
|
||||
public enum InputType
|
||||
{
|
||||
GetButtonDown,
|
||||
GetDoubleButton,
|
||||
GetButtonTimer,
|
||||
AutoAction
|
||||
};
|
||||
|
||||
[vHelpBox("Time you have to hold the button *Only for GetButtonTimer*")]
|
||||
public float buttonTimer = 3f;
|
||||
[vHelpBox("Add delay to start the input count *Only for GetButtonTimer*")]
|
||||
public float inputDelay = 0.1f;
|
||||
[vHelpBox("*Only for GetButtonTimer* \n\n<b>TRUE: </b> Play the animation while you're holding the button \n" +
|
||||
"<b>FALSE: </b>Play the animation after you finish holding the button")]
|
||||
public bool playAnimationWhileHoldingButton = true;
|
||||
|
||||
[vHelpBox("Time to press the button twice *Only for GetDoubleButton*")]
|
||||
public float doubleButtomTime = 0.25f;
|
||||
|
||||
[vEditorToolbar("Trigger", order = 2)]
|
||||
[SerializeField] protected bool canDoAction = true;
|
||||
|
||||
public string actionName = "Action";
|
||||
public string actionTag = "Action";
|
||||
[vHelpBox("Disable this trigger OnStart")]
|
||||
public bool disableOnStart = false;
|
||||
[vHelpBox("Disable the Player's Capsule Collider Collision, useful for animations with closer interactions")]
|
||||
public bool disableCollision;
|
||||
[vHelpBox("Disable the Player's Rigidbody Gravity, useful for on air animations")]
|
||||
public bool disableGravity;
|
||||
[vHelpBox("It will only use the trigger if the forward of the character is close to the forward of this transform")]
|
||||
public bool activeFromForward;
|
||||
[vHelpBox("Max angle between character forward and trigger forward to active trigger"), Range(5, 180)]
|
||||
public float forwardAngle = 55;
|
||||
[vHelpBox("Rotate Character to the Forward Rotation of this Trigger")]
|
||||
public bool useTriggerRotation;
|
||||
[vHelpBox("Destroy this Trigger after pressing the Input or AutoAction or finishing the Action")]
|
||||
public bool destroyAfter = false;
|
||||
[vHideInInspector("destroyAfter")]
|
||||
public float destroyDelay = 0f;
|
||||
[vHelpBox("Change your CameraState to a Custom State while playing the animation")]
|
||||
public string customCameraState;
|
||||
|
||||
[vEditorToolbar("Animation", order = 2)]
|
||||
|
||||
[vHelpBox("Trigger a Animation - Use the exactly same name of the AnimationState you want to trigger, " +
|
||||
"don't forget to add a vAnimatorTag to your State")]
|
||||
public string playAnimation;
|
||||
|
||||
public float crossFadeTransition = 0.25f;
|
||||
|
||||
public int animatorLayer = 0;
|
||||
|
||||
[vHelpBox("Check the Exit Time of your animation (if it doesn't loop) and insert here. \n\n" +
|
||||
"For example if your Exit Time is 0.82 you need to insert 0.82" +
|
||||
"\n\nAlways check with the Debug of the GenericAction if your animation is finishing correctly, " +
|
||||
"otherwise the controller won't reset to the default physics and collision.", vHelpBoxAttribute.MessageType.Warning)]
|
||||
[Tooltip("You can use this to make a persistent action, and finish the action calling FinishAction method of the vGenericAction component in your character")]
|
||||
public bool endActionManualy = false;
|
||||
[vHideInInspector("endActionManualy", invertValue = true)]
|
||||
public float endExitTimeAnimation = 0.8f;
|
||||
[vHelpBox("Use a ActionState value to apply special conditions for your AnimatorController transitions")]
|
||||
public int animatorActionState = 0;
|
||||
[vHelpBox("Reset the ActionState parameter to 0 after playing the animation")]
|
||||
public bool resetAnimatorActionState = true;
|
||||
[vHelpBox("Use a empty transform as reference for the MatchTarget")]
|
||||
public Transform matchTarget;
|
||||
[vHelpBox("Select the bone you want to use as reference to the Match Target")]
|
||||
public AvatarTarget avatarTarget;
|
||||
[Header("Curve Match target system")]
|
||||
public bool useLocalX = false;
|
||||
public bool useLocalZ = true;
|
||||
public AnimationCurve matchPositionXZCurve = new AnimationCurve(new Keyframe(0, 0), new Keyframe(.5f, 1), new Keyframe(1, 1));
|
||||
public AnimationCurve matchPositionYCurve = new AnimationCurve(new Keyframe(0, 0), new Keyframe(.5f, 1), new Keyframe(1, 1));
|
||||
public AnimationCurve matchRotationCurve = new AnimationCurve(new Keyframe(0, 0), new Keyframe(.5f, 1), new Keyframe(1, 1));
|
||||
|
||||
[vEditorToolbar("Events", order = 3)]
|
||||
|
||||
[Tooltip("Delay to run the OnDoAction Event")]
|
||||
[FormerlySerializedAs("onDoActionDelay")]
|
||||
public float onPressActionDelay;
|
||||
|
||||
[Header("--- INPUT EVENTS ---")]
|
||||
[FormerlySerializedAs("OnDoAction")]
|
||||
public UnityEvent OnPressActionInput;
|
||||
public OnDoActionWithTarget onPressActionInputWithTarget;
|
||||
|
||||
[Header("--- ONLY FOR GET BUTTON TIMER ---")]
|
||||
public UnityEvent OnCancelActionInput;
|
||||
public UnityEvent OnFinishActionInput;
|
||||
public OnUpdateValue OnUpdateButtonTimer;
|
||||
|
||||
[Header("--- ANIMATION EVENTS ---")]
|
||||
public UnityEvent OnStartAnimation;
|
||||
public UnityEvent OnEndAnimation;
|
||||
|
||||
[Header("--- PLAYER AND TRIGGER DETECTION ---")]
|
||||
public OnDoActionWithTarget OnPlayerEnter;
|
||||
public OnDoActionWithTarget OnPlayerStay;
|
||||
public OnDoActionWithTarget OnPlayerExit;
|
||||
|
||||
[Header("--- ACTION VALIDATION ---")]
|
||||
public OnDoActionWithTarget OnValidate;
|
||||
public OnDoActionWithTarget OnInvalidate;
|
||||
public UnityEvent OnCancelAction;
|
||||
|
||||
private float currentButtonTimer;
|
||||
internal Collider _collider;
|
||||
|
||||
public bool CanDoAction
|
||||
{
|
||||
get => canDoAction;
|
||||
set => canDoAction = value;
|
||||
}
|
||||
protected virtual void Start()
|
||||
{
|
||||
this.gameObject.tag = actionTag;
|
||||
this.gameObject.layer = LayerMask.NameToLayer("Triggers");
|
||||
_collider = GetComponent<Collider>();
|
||||
_collider.isTrigger = true;
|
||||
if (disableOnStart)
|
||||
this.enabled = false;
|
||||
}
|
||||
|
||||
public virtual IEnumerator OnPressActionDelay(GameObject obj)
|
||||
{
|
||||
yield return new WaitForSeconds(onPressActionDelay);
|
||||
OnPressActionInput.Invoke();
|
||||
if (obj)
|
||||
onPressActionInputWithTarget.Invoke(obj);
|
||||
}
|
||||
|
||||
public void UpdateButtonTimer(float value)
|
||||
{
|
||||
if (value != currentButtonTimer)
|
||||
{
|
||||
currentButtonTimer = value;
|
||||
OnUpdateButtonTimer.Invoke(value);
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class OnUpdateValue : UnityEvent<float>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class OnDoActionWithTarget : UnityEvent<GameObject>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 53a2f2cffbeaacb49b92a9a282dd4c19
|
||||
timeCreated: 1548187028
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 65f0ab239a5cfe64897f8b4b02466643, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,45 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
namespace Invector.vCharacterController.vActions
|
||||
{
|
||||
[vClassHeader("Trigger Ladder Action", false)]
|
||||
public class vTriggerLadderAction : vMonoBehaviour
|
||||
{
|
||||
[vEditorToolbar("Settings")]
|
||||
[Header("Trigger Action Options")]
|
||||
[Tooltip("Automatically execute the action without the need to press a Button")]
|
||||
public bool autoAction;
|
||||
|
||||
[Header("Enter")]
|
||||
[Tooltip("Trigger an Animation - Use the exactly same name of the AnimationState you want to trigger")]
|
||||
public string playAnimation;
|
||||
|
||||
[Header("Exit")]
|
||||
[Tooltip("Trigger an Animation - Use the exactly same name of the AnimationState you want to trigger")]
|
||||
public string exitAnimation;
|
||||
|
||||
[Tooltip("Use this to limit the trigger to active if forward of character is close to this forward")]
|
||||
public bool activeFromForward;
|
||||
[Tooltip("Rotate Character for this rotation when active")]
|
||||
public bool useTriggerRotation;
|
||||
|
||||
|
||||
[Tooltip("Target Character parent, used to movable ladders to set character child of target, keep empty if ladder is static")]
|
||||
public Transform targetCharacterParent;
|
||||
[vEditorToolbar("MatchTarget")]
|
||||
[Tooltip("Use a transform to help the character climb any height, take a look at the Example Scene ClimbUp, StepUp, JumpOver objects.")]
|
||||
public Transform matchTarget;
|
||||
[Tooltip("Use a empty gameObject as a reference for the character to exit")]
|
||||
public Transform exitMatchTarget;
|
||||
public AnimationCurve enterPositionXZCurve = new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 1));
|
||||
public AnimationCurve enterPositionYCurve = new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 1));
|
||||
public AnimationCurve exitPositionXZCurve = new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 1));
|
||||
public AnimationCurve exitPositionYCurve = new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 1));
|
||||
public AnimationCurve enterRotationCurve = new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 1));
|
||||
public AnimationCurve exitRotationCurve = new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 1));
|
||||
public UnityEvent OnDoAction;
|
||||
public UnityEvent OnPlayerEnter;
|
||||
public UnityEvent OnPlayerStay;
|
||||
public UnityEvent OnPlayerExit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: acb414223d4e72240a4c12d2d6a14be1
|
||||
timeCreated: 1469459577
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,48 @@
|
||||
using Invector.vCharacterController.vActions;
|
||||
using UnityEngine;
|
||||
|
||||
public class vTriggerLadderMiddle : MonoBehaviour
|
||||
{
|
||||
public Transform refTarget;
|
||||
public float stepHeight = 0.5f;
|
||||
public float entryAngleFwd = 45f;
|
||||
public bool debugMode = true;
|
||||
|
||||
vLadderAction ladderAction;
|
||||
internal BoxCollider _collider;
|
||||
|
||||
void Start()
|
||||
{
|
||||
_collider = GetComponent<BoxCollider>();
|
||||
}
|
||||
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
if (!debugMode) return;
|
||||
|
||||
if (!_collider)
|
||||
_collider = GetComponent<BoxCollider>();
|
||||
else
|
||||
{
|
||||
int steps = (int)(_collider.size.y / stepHeight);
|
||||
|
||||
for (int i = 0; i < steps; i++)
|
||||
{
|
||||
Gizmos.DrawSphere(refTarget.position + refTarget.up * i * stepHeight, 0.1f);
|
||||
Gizmos.DrawLine(refTarget.position + refTarget.up * i * stepHeight, refTarget.position + refTarget.up * i * stepHeight + refTarget.forward * 0.5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerStay(Collider other)
|
||||
{
|
||||
if (other.gameObject.CompareTag("Player"))
|
||||
{
|
||||
if (Vector3.Angle(other.transform.forward, refTarget.transform.forward) > entryAngleFwd) return;
|
||||
|
||||
ladderAction = other.GetComponent<vLadderAction>();
|
||||
if (ladderAction.isUsingLadder) return;
|
||||
ladderAction.TriggerMidAirEnterLadder(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3c5bae65728a16d4cb1052b692ce6e6e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: de05c90f6cd26a9478bee31eb029d848
|
||||
folderAsset: yes
|
||||
timeCreated: 1435613877
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f76efe6e52c0254bb6c56ad6a01f7ed
|
||||
folderAsset: yes
|
||||
timeCreated: 1495164888
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,15 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 2f22f37f63bcec14080b11ce5e381ce6, type: 3}
|
||||
m_Name: vEditorStartupPrefs
|
||||
m_EditorClassIdentifier:
|
||||
displayWelcomeScreen: 1
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1c9f2caa0db14374aaaabef8a5c88ce5
|
||||
timeCreated: 1570641149
|
||||
licenseType: Store
|
||||
NativeFormatImporter:
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Invector.vCharacterController
|
||||
{
|
||||
[Serializable]
|
||||
public class vEditorStartupPrefs : ScriptableObject
|
||||
{
|
||||
private static vEditorStartupPrefs instance;
|
||||
public static vEditorStartupPrefs Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = Resources.Load<vEditorStartupPrefs>("vEditorStartupPrefs");
|
||||
if (instance == null)
|
||||
{
|
||||
instance = CreateInstance<vEditorStartupPrefs>();
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField] private bool displayWelcomeScreen = true;
|
||||
|
||||
public static bool DisplayWelcomeScreen
|
||||
{
|
||||
get { return Instance.displayWelcomeScreen; }
|
||||
set
|
||||
{
|
||||
if (value != Instance.displayWelcomeScreen)
|
||||
{
|
||||
Instance.displayWelcomeScreen = value;
|
||||
SaveStartupPrefs();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void SaveStartupPrefs()
|
||||
{
|
||||
if (!AssetDatabase.Contains(Instance))
|
||||
{
|
||||
var copy = CreateInstance<vEditorStartupPrefs>();
|
||||
EditorUtility.CopySerialized(Instance, copy);
|
||||
instance = Resources.Load<vEditorStartupPrefs>("vEditorStartupPrefs");
|
||||
if (instance == null)
|
||||
{
|
||||
AssetDatabase.CreateAsset(copy, "Assets/Invector-3rdPersonController/Basic Locomotion/Resources/vEditorStartupPrefs.asset");
|
||||
AssetDatabase.Refresh();
|
||||
instance = copy;
|
||||
|
||||
return;
|
||||
}
|
||||
EditorUtility.CopySerialized(copy, instance);
|
||||
}
|
||||
EditorUtility.SetDirty(Instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2f22f37f63bcec14080b11ce5e381ce6
|
||||
timeCreated: 1570638069
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f7f845cfdfb83b4597aae966022b206
|
||||
timeCreated: 1437763044
|
||||
licenseType: Store
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3bf719ecb264d6242b5836d7f03f3b71
|
||||
timeCreated: 1570561745
|
||||
licenseType: Store
|
||||
NativeFormatImporter:
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,153 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Invector.vCharacterController
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(GenericInput))]
|
||||
public class vGenericInputDrawer : PropertyDrawer
|
||||
{
|
||||
public static GUISkin skin;
|
||||
public static GUIContent axisContent;
|
||||
public static GUIContent invertAxisContent;
|
||||
public static GUIContent unityInputContent;
|
||||
public static float heightOpen => ((EditorGUIUtility.singleLineHeight) * 7) + 10;
|
||||
|
||||
const string axisButtonTootip = "IsTriggerAxis?\nConvert Input Axis to Trigger Axis \nThis is usefull if you want to use a axis input like a trigger button.\n \n***Ps. This work only if input is used for GetButton or GetButton(down,up), not if is used for GetAxis";
|
||||
const string invertAxisButtonTootip = "InvertTriggerAxis?\nIf the Input is an TriggerAxis button you can invert the valid input.\nIf enable the valid axis input is -1 else valid axis input is 1";
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
Color color = new Color(1f, 0.549f, 0f );
|
||||
GUI.color = property.isExpanded ? color : Color.white;
|
||||
if (axisContent == null)
|
||||
{
|
||||
axisContent = new GUIContent(EditorGUIUtility.IconContent("d_MoveTool On@2x"));
|
||||
axisContent.tooltip = axisButtonTootip;
|
||||
|
||||
}
|
||||
if (invertAxisContent == null)
|
||||
{
|
||||
invertAxisContent = new GUIContent(EditorGUIUtility.IconContent("Mirror"));
|
||||
invertAxisContent.tooltip = invertAxisButtonTootip;
|
||||
}
|
||||
if (unityInputContent == null)
|
||||
{
|
||||
unityInputContent = new GUIContent();
|
||||
}
|
||||
|
||||
var rect1 = new Rect(position.x, position.y, EditorGUIUtility.singleLineHeight * 2f, EditorGUIUtility.singleLineHeight);
|
||||
var rect2 = new Rect(position.x + rect1.width, position.y, position.width - rect1.width, EditorGUIUtility.singleLineHeight);
|
||||
|
||||
var useInput = property.FindPropertyRelative("useInput");
|
||||
|
||||
if (property.isExpanded)
|
||||
{
|
||||
var bgRect = position;
|
||||
bgRect.height = heightOpen;
|
||||
|
||||
GUI.Box(bgRect, "", EditorStyles.helpBox);
|
||||
}
|
||||
|
||||
if (useInput != null)
|
||||
{
|
||||
useInput.boolValue = GUI.Toggle(rect1, useInput.boolValue, "USE", EditorStyles.miniButtonMid);
|
||||
if (useInput.boolValue == false)
|
||||
{
|
||||
property.isExpanded = false;
|
||||
}
|
||||
|
||||
GUI.enabled = useInput.boolValue;
|
||||
}
|
||||
|
||||
property.isExpanded = GUI.Toggle(rect2, property.isExpanded, property.displayName, EditorStyles.miniButtonMid);
|
||||
GUI.color = Color.white;
|
||||
if (property.isExpanded)
|
||||
{
|
||||
|
||||
var keyboard = property.FindPropertyRelative("keyboard");
|
||||
var joystick = property.FindPropertyRelative("joystick");
|
||||
var mobile = property.FindPropertyRelative("mobile");
|
||||
|
||||
var keyboardAxis = property.FindPropertyRelative("keyboardAxis");
|
||||
var joystickAxis = property.FindPropertyRelative("joystickAxis");
|
||||
var mobileAxis = property.FindPropertyRelative("mobileAxis");
|
||||
|
||||
var joystickAxisInvert = property.FindPropertyRelative("joystickAxisInvert");
|
||||
var keyboardAxisInvert = property.FindPropertyRelative("keyboardAxisInvert");
|
||||
var mobileAxisInvert = property.FindPropertyRelative("mobileAxisInvert");
|
||||
|
||||
var isUnityInput = property.FindPropertyRelative("isUnityInput");
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
var totalRect = position;
|
||||
|
||||
totalRect.height = EditorGUIUtility.singleLineHeight;
|
||||
|
||||
totalRect.width -= 10;
|
||||
totalRect.x += 5;
|
||||
DrawInput(ref totalRect, "Mouse Keyboard Input", keyboard, keyboardAxis, keyboardAxisInvert, isUnityInput, true);
|
||||
DrawInput(ref totalRect, "Joystick Input", joystick, joystickAxis, joystickAxisInvert, null, false);
|
||||
DrawInput(ref totalRect,"Mobile Input", mobile, mobileAxis, mobileAxisInvert, null, false);
|
||||
|
||||
}
|
||||
GUI.enabled = true;
|
||||
|
||||
}
|
||||
void DrawInput(ref Rect totalRect,string tooltip, SerializedProperty input, SerializedProperty axis, SerializedProperty invert, SerializedProperty isUnityInput = null, bool withKeys = false)
|
||||
{
|
||||
totalRect.y += EditorGUIUtility.singleLineHeight ;
|
||||
GUI.Label(totalRect, tooltip,EditorStyles.miniLabel);
|
||||
totalRect.y += EditorGUIUtility.singleLineHeight;
|
||||
var width1 = EditorGUIUtility.singleLineHeight * 1.5f;
|
||||
var width2 = totalRect.width - (width1 * 3);
|
||||
var rectA = new Rect(totalRect.x, totalRect.y, width1, totalRect.height);
|
||||
var rectB = new Rect(totalRect.x + width1, totalRect.y, width2, totalRect.height);
|
||||
var rectC = new Rect(totalRect.x + width1 + width2, totalRect.y, width1, totalRect.height);
|
||||
var rectD = new Rect(totalRect.x + (width1) * 2 + width2, totalRect.y, width1, totalRect.height);
|
||||
|
||||
var content = unityInputContent;
|
||||
content.tooltip = (isUnityInput == null || isUnityInput.boolValue) ? "Input is a UnityInput" : "Input is a KeyCode";
|
||||
content.image = (isUnityInput == null || isUnityInput.boolValue) ? EditorGUIUtility.IconContent("UnityLogo").image : EditorGUIUtility.IconContent("Font Icon").image;
|
||||
|
||||
GUI.Box(rectA, content, EditorStyles.miniButton);
|
||||
DrawInputEnum(input, isUnityInput, rectB, withKeys);
|
||||
|
||||
GUI.color = axis.boolValue ? Color.grey : Color.white;
|
||||
axis.boolValue = GUI.Toggle(rectC, axis.boolValue, axisContent, EditorStyles.miniButton);
|
||||
GUI.color = invert.boolValue ? Color.grey : Color.white;
|
||||
GUI.enabled = axis.boolValue;
|
||||
|
||||
invert.boolValue = GUI.Toggle(rectD, invert.boolValue, invertAxisContent, EditorStyles.miniButton) && axis.boolValue;
|
||||
GUI.enabled = true;
|
||||
GUI.color = Color.white;
|
||||
}
|
||||
|
||||
void DrawInputEnum(SerializedProperty input, SerializedProperty isUnityInput, Rect rect, bool withKeys = false)
|
||||
{
|
||||
|
||||
if (GUI.Button(rect, new GUIContent(input.stringValue), EditorStyles.miniPullDown))
|
||||
{
|
||||
PopupWindow.Show(rect, new vGenericInputSelector
|
||||
("Input for " + input.displayName, input.stringValue, withKeys, isUnityInput == null || isUnityInput.boolValue, (string newInput, bool isKey) =>
|
||||
{
|
||||
input.stringValue = newInput;
|
||||
if (isUnityInput != null)
|
||||
{
|
||||
isUnityInput.boolValue = !isKey;
|
||||
}
|
||||
|
||||
input.serializedObject.ApplyModifiedProperties();
|
||||
input.serializedObject.Update();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
return !property.isExpanded ? EditorGUIUtility.singleLineHeight : heightOpen;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 100554bba32332448baa745ce3875587
|
||||
timeCreated: 1475778971
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,140 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
|
||||
public class vGenericInputSelector : PopupWindowContent
|
||||
{
|
||||
public vGenericInputSelector (string label,string lastInput, bool drawKeys,bool isUnityInput, UnityEngine.Events.UnityAction<string, bool> onSelectInput)
|
||||
{
|
||||
this.label = label;
|
||||
this.drawKeys = drawKeys;
|
||||
this.onSelectInput = onSelectInput;
|
||||
this.isUnityInput = isUnityInput;
|
||||
this.lastInput = lastInput;
|
||||
if(drawKeys)
|
||||
{
|
||||
toolBar = new GUIContent[] { new GUIContent("Unity Inputs", unityInputToolip), new GUIContent("KeyCodes", keyCodeTooltip) };
|
||||
selectedToolBar = isUnityInput?0:1;
|
||||
}
|
||||
else toolBar = new GUIContent[] { new GUIContent("Unity Inputs", unityInputToolip)};
|
||||
|
||||
|
||||
}
|
||||
const string keyCodeTooltip = "KeyCode use a Enum (GetKey, GetKeyDown,GetKeyUp)";
|
||||
const string unityInputToolip = "Unity input use input names created in InputManager (GetButton, GetButtonDown, GetButtonUp";
|
||||
public static UnityEngine.Object inputManager;
|
||||
public static string[] _unityInputs = new string[0];
|
||||
public static string[] _unityKeys = new string[0];
|
||||
public static float minHeight = EditorGUIUtility.singleLineHeight*10;
|
||||
public static float maxHeight = EditorGUIUtility.singleLineHeight * 50;
|
||||
public static float height= EditorGUIUtility.singleLineHeight;
|
||||
public string label;
|
||||
public string search;
|
||||
|
||||
protected Vector2 scrollView;
|
||||
protected Vector2 scrollView2;
|
||||
protected int selectedToolBar = 0;
|
||||
protected bool drawKeys =true;
|
||||
protected bool isUnityInput;
|
||||
protected string lastInput;
|
||||
protected GUIContent[] toolBar;
|
||||
/// <summary>
|
||||
/// Event to return the select input and if the input is an keycode
|
||||
/// </summary>
|
||||
public UnityEngine.Events.UnityAction<string, bool> onSelectInput;
|
||||
|
||||
public override Vector2 GetWindowSize()
|
||||
{
|
||||
return new Vector2(300, Mathf.Clamp((height * UnityInputs.Length),minHeight,maxHeight));
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect rect)
|
||||
{
|
||||
GUILayout.BeginArea(rect,"","box");
|
||||
GUILayout.Box(label,GUILayout.ExpandWidth(true));
|
||||
DrawFilter();
|
||||
|
||||
selectedToolBar = GUILayout.Toolbar(selectedToolBar, toolBar);
|
||||
if(selectedToolBar==0) DrawInput( UnityInputs, false, ref scrollView,isUnityInput );
|
||||
else if (selectedToolBar ==1) DrawInput( UnityKeys, true, ref scrollView2,!isUnityInput);
|
||||
GUILayout.EndArea();
|
||||
// if(GUI.GetNameOfFocusedControl()!= "Search Field") EditorGUI.FocusTextInControl("Search Field");
|
||||
|
||||
}
|
||||
void DrawInput( string[] inputs,bool isKey,ref Vector2 scrollView,bool hightlightName = false)
|
||||
{
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.Space(10);
|
||||
scrollView = GUILayout.BeginScrollView(scrollView);
|
||||
for (int i=0;i< inputs.Length;i++)
|
||||
{
|
||||
var input = inputs[i];
|
||||
if (string.IsNullOrEmpty(search) || input.Trim().StartsWith(search) || input.Trim().ToLower().StartsWith(search.ToLower()))
|
||||
{
|
||||
if (hightlightName && input.Equals(lastInput)) GUI.color = Color.green;
|
||||
if (GUILayout.Button(input, EditorStyles.toolbarButton))
|
||||
{
|
||||
onSelectInput?.Invoke(input, isKey);
|
||||
editorWindow.Close();
|
||||
}
|
||||
}
|
||||
GUI.color = Color.white;
|
||||
}
|
||||
GUILayout.EndScrollView();
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
void DrawFilter()
|
||||
{
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
GUI.SetNextControlName("Search Field");
|
||||
search = GUILayout.TextField(search, EditorStyles.toolbarSearchField);
|
||||
if(string.IsNullOrEmpty(search))
|
||||
{
|
||||
var fieldRect = GUILayoutUtility.GetLastRect();
|
||||
GUI.Label(fieldRect, " ....Search for input",EditorStyles.centeredGreyMiniLabel);
|
||||
}
|
||||
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
static string[] UnityKeys
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_unityKeys != null && _unityKeys.Length > 0) return _unityKeys;
|
||||
_unityKeys = Enum.GetNames(typeof(KeyCode));
|
||||
return _unityKeys;
|
||||
}
|
||||
}
|
||||
|
||||
static string[] UnityInputs
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_unityInputs != null && _unityInputs.Length > 0) return _unityInputs;
|
||||
|
||||
if (!inputManager)
|
||||
inputManager = AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/InputManager.asset")[0];
|
||||
|
||||
SerializedObject obj = new SerializedObject(inputManager);
|
||||
SerializedProperty axisArray = obj.FindProperty("m_Axes");
|
||||
|
||||
if (_unityInputs.Length != axisArray.arraySize)
|
||||
_unityInputs = new string[axisArray.arraySize];
|
||||
for (int i = 0; i < axisArray.arraySize; ++i)
|
||||
{
|
||||
var axis = axisArray.GetArrayElementAtIndex(i);
|
||||
var name = axis.FindPropertyRelative("m_Name").stringValue;
|
||||
_unityInputs[i] = name;
|
||||
}
|
||||
|
||||
return _unityInputs;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84f66b9391c9b2d49ae30e0ef8ece31d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,30 @@
|
||||
using UnityEditor;
|
||||
|
||||
namespace Invector.vCharacterController
|
||||
{
|
||||
[InitializeOnLoad]
|
||||
public class vInvectorStartup
|
||||
{
|
||||
static vInvectorStartup()
|
||||
{
|
||||
EditorApplication.update -= TriggerWelcomeScreen;
|
||||
EditorApplication.update += TriggerWelcomeScreen;
|
||||
}
|
||||
|
||||
private static void TriggerWelcomeScreen()
|
||||
{
|
||||
var showAtStartup = vEditorStartupPrefs.DisplayWelcomeScreen && EditorApplication.timeSinceStartup < 30f;
|
||||
|
||||
if (showAtStartup)
|
||||
{
|
||||
vInvectorWelcomeWindow.Open();
|
||||
}
|
||||
EditorApplication.update -= TriggerWelcomeScreen;
|
||||
}
|
||||
|
||||
private static void PlayModeChanged()
|
||||
{
|
||||
EditorApplication.update -= TriggerWelcomeScreen;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 41708f07abf46044399f2e556a162802
|
||||
timeCreated: 1570643086
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,358 @@
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Invector.vCharacterController
|
||||
{
|
||||
[InitializeOnLoad]
|
||||
public class vInvectorWelcomeWindow : EditorWindow
|
||||
{
|
||||
#region ToolBar Drawers
|
||||
/// <summary>
|
||||
/// ToolBar Class
|
||||
/// </summary>
|
||||
public class ToolBar
|
||||
{
|
||||
public string title;
|
||||
public UnityEngine.Events.UnityAction Draw;
|
||||
/// <summary>
|
||||
/// Create New Toolbar
|
||||
/// </summary>
|
||||
/// <param name="title">Title</param>
|
||||
/// <param name="onDraw">Method to draw when toolbar is selected</param>
|
||||
public ToolBar(string title, UnityEngine.Events.UnityAction onDraw)
|
||||
{
|
||||
this.title = title;
|
||||
this.Draw = onDraw;
|
||||
}
|
||||
public static implicit operator string(ToolBar tool)
|
||||
{
|
||||
return tool.title;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Index of selected <seealso cref="toolBars"/>
|
||||
/// </summary>
|
||||
public int toolBarIndex = 0;
|
||||
|
||||
/// <summary>
|
||||
/// List of Toolbars
|
||||
/// </summary>
|
||||
public ToolBar[] toolBars = new ToolBar[]
|
||||
{
|
||||
new ToolBar("First Run",FirstRunPageContent),
|
||||
new ToolBar("Getting Started",GettingStartedPageContent),
|
||||
#if INVECTOR_BASIC
|
||||
new ToolBar("Add-ons",AddonsPageContent),
|
||||
#endif
|
||||
new ToolBar("Forum | Discord",Forum)
|
||||
};
|
||||
#endregion
|
||||
|
||||
public const string _thirdPersonVersion = "2.6.4";
|
||||
public const string _fsmAIVersion = "1.2.0";
|
||||
|
||||
public const string _projectSettingsPath = "Assets/Invector-3rdPersonController/Basic Locomotion/Editor/Resources/vProjectSettings.unitypackage";
|
||||
public const string _mobilePackagePath = "Assets/Invector-3rdPersonController/Basic Locomotion/Editor/Resources/vMobileAddon.unitypackage";
|
||||
public const string _topDownPackagePath = "Assets/Invector-3rdPersonController/Basic Locomotion/Editor/Resources/vTopDownAddon.unitypackage";
|
||||
public const string _pointAndClickPackagePath = "Assets/Invector-3rdPersonController/Basic Locomotion/Editor/Resources/vPointClickAddon.unitypackage";
|
||||
public const string _platformPackagePath = "Assets/Invector-3rdPersonController/Basic Locomotion/Editor/Resources/v2DPlatformAddon.unitypackage";
|
||||
public const string _vMansionPath = "Assets/Invector-3rdPersonController/Basic Locomotion/Editor/Resources/vMansionAddon.unitypackage";
|
||||
|
||||
public static Texture2D invectorBanner = null;
|
||||
public static Texture2D mobileIcon = null;
|
||||
public static Texture2D topdownIcon = null;
|
||||
public static Texture2D pointAndClickIcon = null;
|
||||
public static Texture2D platformIcon = null;
|
||||
public static Texture2D vMansionIcon = null;
|
||||
public static Texture2D assetStoreIcon = null;
|
||||
public static Texture2D climbAddon = null;
|
||||
public static Texture2D swimmingAddon = null;
|
||||
public static Texture2D stealthKillAddon = null;
|
||||
public static Texture2D builderAddon = null;
|
||||
public static Texture2D ziplineAddon = null;
|
||||
public static Texture2D craftingAddon = null;
|
||||
public static Texture2D pushAddon = null;
|
||||
public static Texture2D coverAddon = null;
|
||||
|
||||
public static Vector2 scrollPosition;
|
||||
|
||||
GUISkin skin;
|
||||
private const int windowWidth = 600;
|
||||
private const int windowHeight = 500;
|
||||
|
||||
[MenuItem("Invector/Welcome Window", false, windowWidth)]
|
||||
public static void Open()
|
||||
{
|
||||
GetWindow<vInvectorWelcomeWindow>(true);
|
||||
}
|
||||
|
||||
#if INVECTOR_BASIC
|
||||
|
||||
[MenuItem("Invector/Add-Ons", false, windowWidth, priority = 2)]
|
||||
static void AddonsMenu()
|
||||
{
|
||||
GetWindow<vInvectorWelcomeWindow>(true).toolBarIndex = 2;
|
||||
}
|
||||
#endif
|
||||
public void OnEnable()
|
||||
{
|
||||
titleContent = new GUIContent("Welcome To Invector");
|
||||
maxSize = new Vector2(windowWidth, windowHeight);
|
||||
minSize = maxSize;
|
||||
InitStyle();
|
||||
}
|
||||
|
||||
void InitStyle()
|
||||
{
|
||||
if (!skin)
|
||||
{
|
||||
skin = Resources.Load("welcomeWindowSkin") as GUISkin;
|
||||
}
|
||||
|
||||
invectorBanner = (Texture2D)Resources.Load("invectorBanner", typeof(Texture2D));
|
||||
mobileIcon = (Texture2D)Resources.Load("mobileIcon", typeof(Texture2D));
|
||||
topdownIcon = (Texture2D)Resources.Load("topdownIcon", typeof(Texture2D));
|
||||
pointAndClickIcon = (Texture2D)Resources.Load("clickToMoveIcon", typeof(Texture2D));
|
||||
platformIcon = (Texture2D)Resources.Load("platformIcon", typeof(Texture2D));
|
||||
vMansionIcon = (Texture2D)Resources.Load("vMansionIcon", typeof(Texture2D));
|
||||
assetStoreIcon = (Texture2D)Resources.Load("Unity-Asset-Store", typeof(Texture2D));
|
||||
climbAddon = (Texture2D)Resources.Load("climbAddon", typeof(Texture2D));
|
||||
swimmingAddon = (Texture2D)Resources.Load("swimmingAddon", typeof(Texture2D));
|
||||
stealthKillAddon = (Texture2D)Resources.Load("stealthKillAddon", typeof(Texture2D));
|
||||
builderAddon = (Texture2D)Resources.Load("builderAddon", typeof(Texture2D));
|
||||
ziplineAddon = (Texture2D)Resources.Load("ziplineAddon", typeof(Texture2D));
|
||||
craftingAddon = (Texture2D)Resources.Load("craftingAddon", typeof(Texture2D));
|
||||
pushAddon = (Texture2D)Resources.Load("pushAddon", typeof(Texture2D));
|
||||
coverAddon = (Texture2D)Resources.Load("coverAddon", typeof(Texture2D));
|
||||
}
|
||||
|
||||
public void OnGUI()
|
||||
{
|
||||
GUI.skin = skin;
|
||||
|
||||
DrawHeader();
|
||||
DrawMenuButtons();
|
||||
DrawPageContent();
|
||||
DrawBottom();
|
||||
}
|
||||
|
||||
private void DrawHeader()
|
||||
{
|
||||
GUILayout.Label(invectorBanner, GUILayout.Height(110));
|
||||
}
|
||||
|
||||
private void DrawMenuButtons()
|
||||
{
|
||||
GUILayout.Space(-10);
|
||||
toolBarIndex = GUILayout.Toolbar(toolBarIndex, ToolbarNames());
|
||||
}
|
||||
|
||||
private string[] ToolbarNames()
|
||||
{
|
||||
string[] names = new string[toolBars.Length];
|
||||
for (int i = 0; i < toolBars.Length; i++)
|
||||
{
|
||||
names[i] = toolBars[i];
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
private void DrawPageContent()
|
||||
{
|
||||
GUILayout.BeginArea(new Rect(4, 140, 592, 340));
|
||||
toolBars[toolBarIndex].Draw();
|
||||
GUILayout.EndArea();
|
||||
GUILayout.FlexibleSpace();
|
||||
}
|
||||
|
||||
private void DrawBottom()
|
||||
{
|
||||
GUILayout.BeginHorizontal("box");
|
||||
|
||||
vEditorStartupPrefs.DisplayWelcomeScreen = GUILayout.Toggle(vEditorStartupPrefs.DisplayWelcomeScreen, "Display this window at startup");
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
private static void ImportPackage(string package)
|
||||
{
|
||||
try
|
||||
{
|
||||
AssetDatabase.ImportPackage(package, true);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Debug.LogError("Failed to import package: " + package);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#region Static ToolBars
|
||||
|
||||
public static void FirstRunPageContent()
|
||||
{
|
||||
GUILayout.BeginVertical("window");
|
||||
|
||||
EditorGUILayout.HelpBox("This Template requires a custom ProjectSettings which includes: InputManager, Layers, Tags and a PhysicsManager." +
|
||||
" It's recommended to import the Template into a New Empty Project, using it as a base to build your game. \n\n * You can UNCHECK the InputManager when using only the FSM AI", MessageType.Warning, true);
|
||||
|
||||
if (GUILayout.Button(">>> Import Project Settings <<<"))
|
||||
{
|
||||
AssetDatabase.ImportPackage(_projectSettingsPath, true);
|
||||
}
|
||||
|
||||
GUILayout.Space(10);
|
||||
|
||||
#if INVECTOR_BASIC
|
||||
EditorGUILayout.HelpBox("Third Person Installed Version: " + _thirdPersonVersion, MessageType.Info);
|
||||
#endif
|
||||
#if INVECTOR_BASIC
|
||||
if (GUILayout.Button("Third Person Documentation"))
|
||||
{
|
||||
Application.OpenURL("https://www.invector.xyz/thirdpersondocumentation");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if INVECTOR_AI_TEMPLATE
|
||||
EditorGUILayout.HelpBox("FSM AI Installed Version: " + _fsmAIVersion, MessageType.Info);
|
||||
#endif
|
||||
|
||||
#if INVECTOR_AI_TEMPLATE
|
||||
if (GUILayout.Button("FSM AI Documentation"))
|
||||
{
|
||||
Application.OpenURL("https://www.invector.xyz/aidocumentation");
|
||||
}
|
||||
#endif
|
||||
|
||||
GUILayout.Space(10);
|
||||
if (GUILayout.Button("Youtube Tutorials"))
|
||||
{
|
||||
Application.OpenURL("https://www.youtube.com/channel/UCSEoY03WFn7D0m1uMi6DxZQ/videos");
|
||||
}
|
||||
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
public static void AddonsPageContent()
|
||||
{
|
||||
GUILayout.BeginVertical("window");
|
||||
scrollPosition = GUILayout.BeginScrollView(
|
||||
scrollPosition, GUILayout.Width(570), GUILayout.Height(316));
|
||||
|
||||
DrawNewAddon(mobileIcon, "Mobile Examples", "Simple mobile example, basic, melee and shooter scenes included", "Import Package", _mobilePackagePath, false);
|
||||
DrawNewAddon(topdownIcon, "Topdown Examples", "Topdown controller basic, melee and shooter scenes included", "Import Package", _topDownPackagePath, false);
|
||||
DrawNewAddon(pointAndClickIcon, "Point&Click Examples", "Similar to Diablo gameplay, basic and melee scenes included", "Import Package", _pointAndClickPackagePath, false);
|
||||
DrawNewAddon(platformIcon, "2.5D Examples", "2.5D with corner transition, basic, melee and shooter scenes included", "Import Package", _platformPackagePath, false);
|
||||
DrawNewAddon(vMansionIcon, "Mansion CameraMode Examples", "Cool example of how to use the CameraMode to create a CCTV or oldschool gameplay style", "Import Package", _vMansionPath, false);
|
||||
|
||||
DrawNewAddon(coverAddon, "Shooter Cover Add-on", "Advanced Cover mechanics to bring more Shooter action or Stealth approach for your game", "Go to AssetStore", "https://assetstore.unity.com/packages/tools/game-toolkits/invector-shooter-cover-add-on-204918", true);
|
||||
DrawNewAddon(pushAddon, "Push & Pull Add-on", "Push and Pull objects to create puzzles", "Go to AssetStore", "https://assetstore.unity.com/packages/tools/game-toolkits/invector-push-add-on-188670", true);
|
||||
DrawNewAddon(craftingAddon, "Crafting Add-on", "Expand Invector's Inventory System to create new items by combining two or more items into a new one.", "Go to AssetStore", "https://assetstore.unity.com/packages/templates/systems/invector-crafting-add-on-168799", true);
|
||||
DrawNewAddon(climbAddon, "FreeClimb Add-on", "Climb on any surface such as walls or cliffs.", "Go to AssetStore", "https://assetstore.unity.com/packages/tools/utilities/third-person-freeclimb-add-on-105187", true);
|
||||
DrawNewAddon(swimmingAddon, "Swimming Add-on", "Swim on the surface or dive into the water", "Go to AssetStore", "https://assetstore.unity.com/packages/tools/utilities/third-person-swimming-add-on-97418", true);
|
||||
DrawNewAddon(ziplineAddon, "Zipline Add-on", "Zipline through pre located ropes", "Go to AssetStore", "https://assetstore.unity.com/packages/tools/utilities/third-person-zipline-add-on-97410", true);
|
||||
DrawNewAddon(stealthKillAddon, "Stealth Kill Add-on (Free!)", "Example using the GenericAction feature, animations included.", "Go to AssetStore", "https://assetstore.unity.com/packages/templates/systems/invector-stealth-kill-add-on-135495", true);
|
||||
DrawNewAddon(builderAddon, "Builder Add-on", "Collect Items and Build them anywhere in your scene to create traps or interactables!", "Go to AssetStore", "https://assetstore.unity.com/packages/tools/utilities/third-person-builder-add-on-152689", true);
|
||||
|
||||
|
||||
GUILayout.EndScrollView();
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
private static void DrawNewAddon(Texture2D icon, string title, string description, string button, string path, bool useUrl)
|
||||
{
|
||||
GUILayout.BeginHorizontal("box");
|
||||
|
||||
GUILayout.Label(icon, GUI.skin.GetStyle("Icon"), GUILayout.Height(90), GUILayout.Width(90));
|
||||
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.Label(title, GUI.skin.GetStyle("Title"), GUILayout.Width(300));
|
||||
GUILayout.Label(description, GUILayout.Width(300));
|
||||
GUILayout.EndVertical();
|
||||
|
||||
if (GUILayout.Button(button))
|
||||
{
|
||||
if (useUrl)
|
||||
{
|
||||
Application.OpenURL(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
AssetDatabase.ImportPackage(path, true);
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
public static void GettingStartedPageContent()
|
||||
{
|
||||
GUILayout.BeginVertical("window");
|
||||
|
||||
|
||||
GUILayout.BeginHorizontal("box");
|
||||
GUILayout.Label("<b>1</b>- First you need to Import our <b>ProjectSettings</b>, otherwise you will get errors about missing Inputs and Layers. Then create a new folder for your Project and put your files there, don't use the Invector Folder to avoid losing files when updating to a new version.");
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.Space(6);
|
||||
|
||||
GUILayout.BeginHorizontal("box");
|
||||
GUILayout.Label("<b>2</b>- Never modify a default resource file (Animator, Prefabs, etc...) that comes with the template, instead" +
|
||||
" create a copy of the original file and place it inside your project folder.");
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.Space(6);
|
||||
|
||||
GUILayout.BeginHorizontal("box");
|
||||
GUILayout.Label("<b>3</b>- When modifying the Invector scripts, make sure to comment the original source and create a #region for ex: 'MyCustomModification' " +
|
||||
"so it's easier to find and implement again once you update the template to a newer version.");
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.Space(6);
|
||||
|
||||
if (GUILayout.Button("Guideline to Import/Update"))
|
||||
{
|
||||
Application.OpenURL("https://invector.proboards.com/thread/2896/guideline-import-update-invector-assets");
|
||||
}
|
||||
|
||||
|
||||
EditorGUILayout.HelpBox("- ALWAYS BACKUP your project before updating!", MessageType.Warning, true);
|
||||
EditorGUILayout.HelpBox("- To update your template you need to Delete the Invector folder, this way you won't get any conflicts between old files and newer files.", MessageType.Info, true);
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
public static void Forum()
|
||||
{
|
||||
GUILayout.BeginVertical("window");
|
||||
|
||||
GUILayout.BeginVertical("box");
|
||||
EditorGUILayout.HelpBox("The Official Invector Forum is getting bigger every day, join the vCommunity too!\n\n- Get help from users \n- Community Add-ons created by users\n- Get feedback to your Project \n- Showcase your Game \n- Check the latests Integrations", MessageType.Info);
|
||||
if (GUILayout.Button("Open Forum"))
|
||||
{
|
||||
Application.OpenURL("http://invector.proboards.com/");
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
|
||||
GUILayout.Space(5);
|
||||
|
||||
GUILayout.BeginVertical("box");
|
||||
EditorGUILayout.HelpBox("Join the Official Invector Discord Channel to get help, talk with developers, share experiencies and more...", MessageType.Info);
|
||||
if (GUILayout.Button("Join Discord"))
|
||||
{
|
||||
Application.OpenURL("https://discord.gg/arWD8UPbgN");
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5fc5f628a186dcc448c8511ddf750be4
|
||||
timeCreated: 1554144232
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,96 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
namespace Invector.vCharacterController
|
||||
{
|
||||
[CustomEditor(typeof(vThirdPersonController), true)]
|
||||
public class vThirdPersonControllerEditor : vEditorBase
|
||||
{
|
||||
public vThirdPersonController tp;
|
||||
public CapsuleCollider _capsuleCollider;
|
||||
public GUIStyle fontLabelStyle = new GUIStyle();
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
tp = (vThirdPersonController)target;
|
||||
_capsuleCollider = tp.GetComponent<CapsuleCollider>();
|
||||
}
|
||||
|
||||
protected virtual void OnSceneGUI()
|
||||
{
|
||||
if (tp && tp.debugWindow)
|
||||
{
|
||||
if (!_capsuleCollider) return;
|
||||
|
||||
DrawGroundDetection();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void DrawGroundDetection()
|
||||
{
|
||||
// TO DO NEW GROUND DETECTION DEBUG
|
||||
|
||||
|
||||
//var checkGroundCenter = tp.transform.position + Vector3.up * (_capsuleCollider.radius);
|
||||
//var pMin = checkGroundCenter + Vector3.down * (tp.groundMinDistance + _capsuleCollider.radius);
|
||||
//var pMax = checkGroundCenter + Vector3.down * (tp.groundMaxDistance + _capsuleCollider.radius);
|
||||
|
||||
//var pValid = pMin;
|
||||
//var colorMin = Color.yellow;
|
||||
//var colorMax = Color.yellow;
|
||||
|
||||
//if (tp.isGrounded)
|
||||
//{
|
||||
// pValid = pMax;
|
||||
// colorMax = Color.green;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// pValid = pMin;
|
||||
// colorMin = Color.green;
|
||||
//}
|
||||
//Handles.color = colorMin;
|
||||
//Handles.DrawSolidDisc(pMin, tp.transform.up, _capsuleCollider.radius * .25f);
|
||||
//Handles.DrawWireDisc(pMin + Vector3.up * _capsuleCollider.radius, tp.transform.up, _capsuleCollider.radius * 1f);
|
||||
//Handles.color = colorMax;
|
||||
//if (tp.isGrounded)
|
||||
//{
|
||||
// Handles.DrawWireDisc(pMax + Vector3.up * _capsuleCollider.radius, tp.transform.up, _capsuleCollider.radius * 1f);
|
||||
//}
|
||||
//Handles.DrawSolidDisc(pMax, tp.transform.up, _capsuleCollider.radius * .25f);
|
||||
//Handles.color = Color.green;
|
||||
//Handles.DrawWireArc(pValid + Vector3.up * _capsuleCollider.radius, tp.transform.right, tp.transform.forward, 180, _capsuleCollider.radius * 1f);
|
||||
//Handles.DrawWireArc(pValid + Vector3.up * _capsuleCollider.radius, tp.transform.forward, tp.transform.right, -180, _capsuleCollider.radius * 1f);
|
||||
//Handles.color = Color.red * 0.5f;
|
||||
//if (Application.isPlaying)
|
||||
//{
|
||||
// if (tp.groundHit.collider)
|
||||
// {
|
||||
// Vector3 p = tp.transform.position;
|
||||
// p.y = tp.groundHit.point.y;
|
||||
// Handles.DrawSolidDisc(p, tp.groundHit.normal, _capsuleCollider.radius * 1f);
|
||||
// DrawLabel(p, "GroundHit");
|
||||
// }
|
||||
// else Handles.DrawSolidDisc(checkGroundCenter + Vector3.down * (tp.groundMaxDistance + _capsuleCollider.radius), tp.transform.up, _capsuleCollider.radius * 1f);
|
||||
//}
|
||||
|
||||
//Handles.color = Color.white;
|
||||
//DrawLabel(pMin, "GroundMin");
|
||||
//DrawLabel(pMax, "GroundMax");
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected virtual void DrawLabel(Vector3 position, string label, int size = 25)
|
||||
{
|
||||
float zoom = Vector3.Distance(position, SceneView.currentDrawingSceneView.camera.transform.position);
|
||||
int fontSize = size;
|
||||
fontLabelStyle.fontSize = Mathf.FloorToInt(fontSize / zoom);
|
||||
fontLabelStyle.normal.textColor = Color.black;
|
||||
fontLabelStyle.alignment = TextAnchor.MiddleLeft;
|
||||
Handles.Label(position, label, fontLabelStyle);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 98c54e356287a1f4b8aa83f49ada1532
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,89 @@
|
||||
using UnityEngine;
|
||||
namespace Invector
|
||||
{
|
||||
/// <summary>
|
||||
/// This class is useful when you don't make sure if parameter of the Animator exist
|
||||
/// </summary>
|
||||
public class vAnimatorParameter
|
||||
{
|
||||
readonly AnimatorControllerParameter _parameter;
|
||||
|
||||
public static implicit operator int(vAnimatorParameter a)
|
||||
{
|
||||
if (a.isValid) return a._parameter.nameHash;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
public readonly bool isValid;
|
||||
|
||||
public vAnimatorParameter(Animator animator, string parameter)
|
||||
{
|
||||
if (animator && animator.ContainsParameter(parameter))
|
||||
{
|
||||
_parameter = animator.GetValidParameter(parameter);
|
||||
this.isValid = true;
|
||||
}
|
||||
|
||||
else this.isValid = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Extencion class for Animator Paramentes
|
||||
/// </summary>
|
||||
public static class vAnimatorParameterHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Get Animator paramenter
|
||||
/// </summary>
|
||||
/// <param name="animator">Target animator</param>
|
||||
/// <param name="paramenterName">Target animator paramenter</param>
|
||||
/// <returns></returns>
|
||||
public static AnimatorControllerParameter GetValidParameter(this Animator animator, string paramenterName)
|
||||
{
|
||||
if (null == animator)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return System.Array.Find(animator.parameters, p => p.name.Equals(paramenterName));
|
||||
}
|
||||
public static bool GetValidParameter(this Animator animator,string paramenterName, out AnimatorControllerParameter parameter)
|
||||
{
|
||||
parameter = animator.GetValidParameter(paramenterName);
|
||||
return parameter != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if Animator has specific paramenter
|
||||
/// </summary>
|
||||
/// <param name="animator">Target animator</param>
|
||||
/// <param name="paramenterName">Target animator paramenter</param>
|
||||
/// <returns></returns>
|
||||
public static bool ContainsParameter(this Animator animator, string paramenterName)
|
||||
{
|
||||
if (null == animator)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return System.Array.Exists(animator.parameters,p=>p.name.Equals(paramenterName));
|
||||
}
|
||||
/// <summary>
|
||||
/// Check if Animator has specific paramenter
|
||||
/// </summary>
|
||||
/// <param name="animator">Target animator</param>
|
||||
/// <param name="parameterName">Target animator paramenter</param>
|
||||
/// <param name="parameterType">Target animator paramenter type</param>
|
||||
/// <returns></returns>
|
||||
public static bool ContainsParameter(this Animator animator, string parameterName, AnimatorControllerParameterType parameterType)
|
||||
{
|
||||
if (null == animator)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return System.Array.Exists(animator.parameters, p => p.name.Equals(parameterName) && p.type.Equals(parameterType)); ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48b231e902e10a744816dacd4a653437
|
||||
timeCreated: 1529627592
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,256 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Invector.vEventSystems
|
||||
{
|
||||
public interface vIAnimatorStateInfoController
|
||||
{
|
||||
vAnimatorStateInfos animatorStateInfos { get; }
|
||||
}
|
||||
public static class vIAnimatorStateInfoHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Register all listener to <see cref="vAnimatorTagBase"/> listener
|
||||
/// </summary>
|
||||
/// <param name="animatorStateInfos"></param>
|
||||
public static void Register(this vIAnimatorStateInfoController animatorStateInfos)
|
||||
{
|
||||
if (animatorStateInfos.isValid())
|
||||
{
|
||||
animatorStateInfos.animatorStateInfos.RegisterListener();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Remove all listener from <see cref="vAnimatorTagBase"/>
|
||||
/// </summary>
|
||||
/// <param name="animatorStateInfos"></param>
|
||||
public static void UnRegister(this vIAnimatorStateInfoController animatorStateInfos)
|
||||
{
|
||||
if (animatorStateInfos.isValid())
|
||||
{
|
||||
animatorStateInfos.animatorStateInfos.RemoveListener();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Check if is valid
|
||||
/// </summary>
|
||||
/// <param name="animatorStateInfos"></param>
|
||||
/// <returns></returns>
|
||||
public static bool isValid(this vIAnimatorStateInfoController animatorStateInfos)
|
||||
{
|
||||
return animatorStateInfos != null && animatorStateInfos.animatorStateInfos != null && animatorStateInfos.animatorStateInfos.animator != null;
|
||||
}
|
||||
|
||||
}
|
||||
[System.Serializable]
|
||||
public class vAnimatorStateInfos
|
||||
{
|
||||
public bool debug;
|
||||
public Animator animator;
|
||||
public vAnimatorStateInfos(Animator animator)
|
||||
{
|
||||
this.animator = animator;
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
if (animator)
|
||||
{
|
||||
stateInfos = new vStateInfo[animator.layerCount];
|
||||
for (int i = 0; i < stateInfos.Length; i++)
|
||||
{
|
||||
stateInfos[i] = new vStateInfo(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RegisterListener()
|
||||
{
|
||||
if (animator == null) return;
|
||||
for (int i = 0; i < stateInfos.Length; i++)
|
||||
{
|
||||
var stateInfo = stateInfos[i];
|
||||
if (stateInfo != null)
|
||||
{
|
||||
stateInfo.tags.Clear();
|
||||
stateInfo.normalizedTime = 0;
|
||||
stateInfo.layer = i;
|
||||
stateInfo.shortPathHash = 0;
|
||||
}
|
||||
else stateInfos[i] = new vStateInfo(i);
|
||||
}
|
||||
var bhv = animator.GetBehaviours<vAnimatorTagBase>();
|
||||
for (int i = 0; i < bhv.Length; i++)
|
||||
{
|
||||
bhv[i].RemoveStateInfoListener(this);
|
||||
bhv[i].AddStateInfoListener(this);
|
||||
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Debug.Log($"Listeners Registered", animator);
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveListener()
|
||||
{
|
||||
if (animator)
|
||||
{
|
||||
var bhv = animator.GetBehaviours<vAnimatorTagBase>();
|
||||
for (int i = 0; i < bhv.Length; i++)
|
||||
{
|
||||
bhv[i].RemoveStateInfoListener(this);
|
||||
}
|
||||
if (debug)
|
||||
{
|
||||
Debug.Log($"Listeners Removed", animator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public vStateInfo[] stateInfos = new vStateInfo[0];
|
||||
[System.Serializable]
|
||||
public class vStateInfo
|
||||
{
|
||||
public int layer;
|
||||
public int shortPathHash;
|
||||
public float normalizedTime;
|
||||
public List<string> tags = new List<string>();
|
||||
public vStateInfo(int layer)
|
||||
{
|
||||
this.layer = layer;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Add tag to the layer
|
||||
/// </summary>
|
||||
/// <param name="tag">Tag</param>
|
||||
/// <param name="layer">Animator layer</param>
|
||||
public void AddStateInfo(string tag, int layer)
|
||||
{
|
||||
if (stateInfos.Length > 0 && layer < stateInfos.Length)
|
||||
{
|
||||
vStateInfo info = stateInfos[layer];
|
||||
info.tags.Add(tag);
|
||||
info.shortPathHash = 0;
|
||||
info.normalizedTime = 0;
|
||||
}
|
||||
if (debug)
|
||||
{
|
||||
Debug.Log($"<color=green>Add tag : <b><i>{tag}</i></b></color>,in the animator layer :{layer}", animator);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Uptade State info
|
||||
/// </summary>
|
||||
/// <param name="layer">state layer</param>
|
||||
/// <param name="normalizedTime">state normalizedTime</param>
|
||||
/// <param name="fullPathHash">state fullPathHash</param>
|
||||
public void UpdateStateInfo(int layer, float normalizedTime, int fullPathHash)
|
||||
{
|
||||
if (stateInfos.Length > 0 && layer < stateInfos.Length)
|
||||
{
|
||||
vStateInfo info = stateInfos[layer];
|
||||
info.normalizedTime = normalizedTime;
|
||||
info.shortPathHash = fullPathHash;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Remove Tag of the layer
|
||||
/// </summary>
|
||||
/// <param name="tag">Tag</param>
|
||||
/// <param name="layer">Animator layer</param>
|
||||
public void RemoveStateInfo(string tag, int layer)
|
||||
{
|
||||
if (stateInfos.Length > 0 && layer < stateInfos.Length)
|
||||
{
|
||||
vStateInfo info = stateInfos[layer];
|
||||
if (info.tags.Contains(tag))
|
||||
{
|
||||
info.tags.Remove(tag);
|
||||
if (info.tags.Count == 0)
|
||||
{
|
||||
info.shortPathHash = 0;
|
||||
info.normalizedTime = 0;
|
||||
}
|
||||
if (debug)
|
||||
{
|
||||
Debug.Log($"<color=red>Remove tag : <b><i>{tag}</i></b></color>, in the animator layer :{layer}", animator);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Check If StateInfo list contains tag
|
||||
/// </summary>
|
||||
/// <param name="tag">tag to check</param>
|
||||
/// <returns></returns>
|
||||
public bool HasTag(string tag)
|
||||
{
|
||||
for (int i = 0; i < stateInfos.Length; i++)
|
||||
{
|
||||
if (stateInfos[i].tags.Contains(tag)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// Check if All tags in in StateInfo List
|
||||
/// </summary>
|
||||
/// <param name="tags">tags to check</param>
|
||||
/// <returns></returns>
|
||||
public bool HasAllTags(params string[] tags)
|
||||
{
|
||||
var has = tags.Length > 0 ? true : false;
|
||||
for (int i = 0; i < tags.Length; i++)
|
||||
{
|
||||
if (!HasTag(tags[i]))
|
||||
{
|
||||
has = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return has;
|
||||
}
|
||||
/// <summary>
|
||||
/// Check if StateInfo List Contains any tag
|
||||
/// </summary>
|
||||
/// <param name="tags">tags to check</param>
|
||||
/// <returns></returns>
|
||||
public bool HasAnyTag(params string[] tags)
|
||||
{
|
||||
var has = false;
|
||||
for (int i = 0; i < tags.Length; i++)
|
||||
{
|
||||
if (HasTag(tags[i]))
|
||||
{
|
||||
has = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return has;
|
||||
}
|
||||
/// <summary>
|
||||
/// Get current animator state info using tag
|
||||
/// </summary>
|
||||
/// <param name="tag">tag</param>
|
||||
/// <returns>if tag exit return AnimatorStateInfo? else return null</returns>
|
||||
public vStateInfo GetStateInfoUsingTag(string tag)
|
||||
{
|
||||
return System.Array.Find(stateInfos, info => info.tags.Contains(tag));
|
||||
}
|
||||
|
||||
public float GetCurrentNormalizedTime(int layer)
|
||||
{
|
||||
if (stateInfos.Length > 0 && layer < stateInfos.Length)
|
||||
{
|
||||
vStateInfo info = stateInfos[layer];
|
||||
return info.normalizedTime;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a9853b4f1e758c04d91a5db8f1b9a453
|
||||
timeCreated: 1529517732
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,166 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace Invector.vCharacterController
|
||||
{
|
||||
[System.Serializable]
|
||||
public class OnActionHandle : UnityEvent<Collider> { }
|
||||
[System.Serializable]
|
||||
|
||||
[vClassHeader("vCharacter")]
|
||||
public class vCharacter : vHealthController, vICharacter
|
||||
{
|
||||
#region Character Variables
|
||||
|
||||
public enum DeathBy
|
||||
{
|
||||
Animation,
|
||||
AnimationWithRagdoll,
|
||||
Ragdoll
|
||||
}
|
||||
|
||||
[vEditorToolbar("Health")]
|
||||
public DeathBy deathBy = DeathBy.Animation;
|
||||
public bool removeComponentsAfterDie;
|
||||
|
||||
[vEditorToolbar("Debug", order = 9)]
|
||||
[HideInInspector]
|
||||
public bool debugActionListener;
|
||||
public Animator animator { get; protected set; }
|
||||
public bool _ragdolled = false;
|
||||
public virtual bool ragdolled { get { return _ragdolled; } set { _ragdolled = value; } }
|
||||
|
||||
[vEditorToolbar("Events")]
|
||||
|
||||
public UnityEvent OnCrouch;
|
||||
public UnityEvent OnStandUp;
|
||||
|
||||
[SerializeField] protected OnActiveRagdoll _onActiveRagdoll = new OnActiveRagdoll();
|
||||
public OnActiveRagdoll onActiveRagdoll { get { return _onActiveRagdoll; } protected set { _onActiveRagdoll = value; } }
|
||||
public UnityEvent onDisableRagdoll;
|
||||
[Header("Check if Character is in Trigger with tag Action")]
|
||||
[HideInInspector]
|
||||
public OnActionHandle onActionEnter = new OnActionHandle();
|
||||
[HideInInspector]
|
||||
public OnActionHandle onActionStay = new OnActionHandle();
|
||||
[HideInInspector]
|
||||
public OnActionHandle onActionExit = new OnActionHandle();
|
||||
|
||||
protected vAnimatorParameter hitDirectionHash;
|
||||
protected vAnimatorParameter reactionIDHash;
|
||||
protected vAnimatorParameter triggerReactionHash;
|
||||
protected vAnimatorParameter triggerResetStateHash;
|
||||
protected vAnimatorParameter recoilIDHash;
|
||||
protected vAnimatorParameter triggerRecoilHash;
|
||||
|
||||
protected bool isInit;
|
||||
|
||||
public virtual bool isCrouching
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isCrouching;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != _isCrouching)
|
||||
{
|
||||
if (value)
|
||||
OnCrouch.Invoke();
|
||||
else
|
||||
OnStandUp.Invoke();
|
||||
}
|
||||
_isCrouching = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected bool _isCrouching;
|
||||
|
||||
#endregion
|
||||
|
||||
public virtual void Init()
|
||||
{
|
||||
animator = GetComponent<Animator>();
|
||||
if (animator)
|
||||
{
|
||||
hitDirectionHash = new vAnimatorParameter(animator, "HitDirection");
|
||||
reactionIDHash = new vAnimatorParameter(animator, "ReactionID");
|
||||
triggerReactionHash = new vAnimatorParameter(animator, "TriggerReaction");
|
||||
triggerResetStateHash = new vAnimatorParameter(animator, "ResetState");
|
||||
recoilIDHash = new vAnimatorParameter(animator, "RecoilID");
|
||||
triggerRecoilHash = new vAnimatorParameter(animator, "TriggerRecoil");
|
||||
}
|
||||
|
||||
this.LoadActionControllers(debugActionListener);
|
||||
}
|
||||
|
||||
public virtual void ResetRagdoll()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void EnableRagdoll()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected virtual void OnTriggerEnter(Collider other)
|
||||
{
|
||||
onActionEnter.Invoke(other);
|
||||
}
|
||||
|
||||
protected virtual void OnTriggerStay(Collider other)
|
||||
{
|
||||
onActionStay.Invoke(other);
|
||||
}
|
||||
|
||||
protected virtual void OnTriggerExit(Collider other)
|
||||
{
|
||||
onActionExit.Invoke(other);
|
||||
}
|
||||
|
||||
public override void TakeDamage(vDamage damage)
|
||||
{
|
||||
base.TakeDamage(damage);
|
||||
TriggerDamageReaction(damage);
|
||||
}
|
||||
|
||||
protected virtual void TriggerDamageReaction(vDamage damage)
|
||||
{
|
||||
if (animator != null && animator.enabled && !damage.activeRagdoll && currentHealth > 0)
|
||||
{
|
||||
if (hitDirectionHash.isValid && damage.sender) animator.SetInteger(hitDirectionHash, (int)transform.HitAngle(damage.sender.position));
|
||||
|
||||
// trigger hitReaction animation
|
||||
if (damage.hitReaction)
|
||||
{
|
||||
// set the ID of the reaction based on the attack animation state of the attacker - Check the MeleeAttackBehavior script
|
||||
if (reactionIDHash.isValid) animator.SetInteger(reactionIDHash, damage.reaction_id);
|
||||
if (triggerReactionHash.isValid) SetAnimatorTrigger(triggerReactionHash);
|
||||
if (triggerResetStateHash.isValid) SetAnimatorTrigger(triggerResetStateHash);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (recoilIDHash.isValid) animator.SetInteger(recoilIDHash, damage.recoil_id);
|
||||
if (triggerRecoilHash.isValid) SetAnimatorTrigger(triggerRecoilHash);
|
||||
if (triggerResetStateHash.isValid) SetAnimatorTrigger(triggerResetStateHash);
|
||||
}
|
||||
}
|
||||
if (damage.activeRagdoll)
|
||||
onActiveRagdoll.Invoke(damage);
|
||||
}
|
||||
|
||||
private IEnumerator SetTriggerRoutine(int trigger)
|
||||
{
|
||||
animator.SetTrigger(trigger);
|
||||
yield return new WaitForSeconds(0.1f);
|
||||
animator.ResetTrigger(trigger);
|
||||
}
|
||||
|
||||
public virtual void SetAnimatorTrigger(int trigger)
|
||||
{
|
||||
StartCoroutine(SetTriggerRoutine(trigger));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e60001fd9dfe58f44a9649eb520cacae
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
@@ -0,0 +1,343 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace Invector
|
||||
{
|
||||
using UnityEngine.Events;
|
||||
using vCharacterController;
|
||||
[vClassHeader("Simple GameController Example", openClose = false)]
|
||||
public class vGameController : vMonoBehaviour
|
||||
{
|
||||
[System.Serializable]
|
||||
public class OnRealoadGame : UnityEngine.Events.UnityEvent { }
|
||||
[vHelpBox("Assign your Character Prefab to be instantiate at the SpawnPoint, leave it unassigned to Restart the Scene instead")]
|
||||
public GameObject playerPrefab;
|
||||
[vHelpBox("Assign a empty transform to spawn the Player to a specific location")]
|
||||
public Transform spawnPoint;
|
||||
[vHelpBox("Time to wait until the scene restart or the player will be spawned again")]
|
||||
public float respawnTimer = 4f;
|
||||
[vHelpBox("Check this if you want to destroy the dead body after the respawn")]
|
||||
public bool destroyBodyAfterDead;
|
||||
[vHelpBox("Display a message using the FadeText UI")]
|
||||
public bool displayInfoInFadeText = true;
|
||||
|
||||
[HideInInspector]
|
||||
public OnRealoadGame OnReloadGame = new OnRealoadGame();
|
||||
[HideInInspector]
|
||||
public GameObject currentPlayer;
|
||||
private vThirdPersonController currentController;
|
||||
public static vGameController instance;
|
||||
private GameObject oldPlayer;
|
||||
|
||||
public UnityEvent onSpawn;
|
||||
public bool dontDestroyOnLoad = true;
|
||||
|
||||
protected virtual void Start()
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = this;
|
||||
if (dontDestroyOnLoad)
|
||||
{
|
||||
DontDestroyOnLoad(this.gameObject);
|
||||
}
|
||||
|
||||
this.gameObject.name = gameObject.name + " Instance";
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy(this.gameObject);
|
||||
return;
|
||||
}
|
||||
|
||||
SceneManager.sceneLoaded += OnLevelFinishedLoading;
|
||||
if (displayInfoInFadeText && vHUDController.instance)
|
||||
{
|
||||
vHUDController.instance.ShowText("Init Scene");
|
||||
}
|
||||
|
||||
FindPlayer();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show/Hide Cursor
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public virtual void ShowCursor(bool value)
|
||||
{
|
||||
Cursor.visible = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lock/Unlock the cursor to the center of screen
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public virtual void LockCursor(bool value)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
}
|
||||
else
|
||||
{
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnCharacterDead(GameObject _gameObject)
|
||||
{
|
||||
oldPlayer = _gameObject;
|
||||
|
||||
if (playerPrefab != null)
|
||||
{
|
||||
StartCoroutine(RespawnRoutine());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (displayInfoInFadeText && vHUDController.instance)
|
||||
{
|
||||
vHUDController.instance.ShowText("Restarting Scene...");
|
||||
}
|
||||
|
||||
Invoke("ResetScene", respawnTimer);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual IEnumerator RespawnRoutine()
|
||||
{
|
||||
yield return new WaitForSeconds(respawnTimer);
|
||||
|
||||
if (playerPrefab != null && spawnPoint != null)
|
||||
{
|
||||
if (oldPlayer != null && destroyBodyAfterDead)
|
||||
{
|
||||
if (displayInfoInFadeText && vHUDController.instance)
|
||||
{
|
||||
vHUDController.instance.ShowText("Player destroyed: " + oldPlayer.name.Replace("(Clone)", "").Replace("Instance", ""));
|
||||
}
|
||||
|
||||
Destroy(oldPlayer);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (displayInfoInFadeText && vHUDController.instance)
|
||||
{
|
||||
vHUDController.instance.ShowText("Remove Player Components: " + oldPlayer.name.Replace("(Clone)", "").Replace("Instance", ""));
|
||||
}
|
||||
|
||||
DestroyPlayerComponents(oldPlayer);
|
||||
}
|
||||
|
||||
yield return new WaitForEndOfFrame();
|
||||
|
||||
currentPlayer = Instantiate(playerPrefab, spawnPoint.position, spawnPoint.rotation);
|
||||
currentController = currentPlayer.GetComponent<vThirdPersonController>();
|
||||
currentController.onDead.AddListener(OnCharacterDead);
|
||||
|
||||
if (displayInfoInFadeText && vHUDController.instance)
|
||||
{
|
||||
vHUDController.instance.ShowText("Respawn player: " + currentPlayer.name.Replace("(Clone)", ""));
|
||||
}
|
||||
|
||||
OnReloadGame.Invoke();
|
||||
onSpawn.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnLevelFinishedLoading(Scene scene, LoadSceneMode mode)
|
||||
{
|
||||
FindPlayer();
|
||||
if (currentController == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentController.currentHealth > 0)
|
||||
{
|
||||
if (displayInfoInFadeText && vHUDController.instance)
|
||||
{
|
||||
vHUDController.instance.ShowText("Load Scene: " + scene.name);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
if (displayInfoInFadeText && vHUDController.instance)
|
||||
{
|
||||
vHUDController.instance.ShowText("Reload Scene");
|
||||
}
|
||||
|
||||
OnReloadGame.Invoke();
|
||||
}
|
||||
|
||||
protected virtual void FindPlayer()
|
||||
{
|
||||
var player = GameObject.FindObjectOfType<vThirdPersonController>();
|
||||
|
||||
if (player)
|
||||
{
|
||||
currentPlayer = player.gameObject;
|
||||
currentController = player;
|
||||
player.onDead.AddListener(OnCharacterDead);
|
||||
if (displayInfoInFadeText && vHUDController.instance)
|
||||
{
|
||||
vHUDController.instance.ShowText("Found player: " + currentPlayer.name.Replace("(Clone)", "").Replace("Instance", ""));
|
||||
}
|
||||
}
|
||||
else if (currentPlayer == null && playerPrefab != null && spawnPoint != null)
|
||||
{
|
||||
SpawnAtPoint(spawnPoint);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void DestroyPlayerComponents(GameObject target)
|
||||
{
|
||||
if (!target)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var comps = target.GetComponentsInChildren<MonoBehaviour>();
|
||||
for (int i = 0; i < comps.Length; i++)
|
||||
{
|
||||
Destroy(comps[i]);
|
||||
}
|
||||
var coll = target.GetComponent<Collider>();
|
||||
if (coll != null)
|
||||
{
|
||||
Destroy(coll);
|
||||
}
|
||||
|
||||
var rigidbody = target.GetComponent<Rigidbody>();
|
||||
if (rigidbody != null)
|
||||
{
|
||||
Destroy(rigidbody);
|
||||
}
|
||||
|
||||
var animator = target.GetComponent<Animator>();
|
||||
if (animator != null)
|
||||
{
|
||||
Destroy(animator);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set a custom spawn point (or use it as checkpoint to your level)
|
||||
/// </summary>
|
||||
/// <param name="newSpawnPoint"> new point to spawn</param>
|
||||
public virtual void SetSpawnPoint(Transform newSpawnPoint)
|
||||
{
|
||||
spawnPoint = newSpawnPoint;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the default player prefab
|
||||
/// </summary>
|
||||
/// <param name="prefab"></param>
|
||||
public void SetPlayerPrefab(GameObject prefab)
|
||||
{
|
||||
playerPrefab = prefab;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Spawn New Player at a specific point
|
||||
/// </summary>
|
||||
/// <param name="targetPoint"> Point to spawn player</param>
|
||||
public virtual void SpawnAtPoint(Transform targetPoint)
|
||||
{
|
||||
if (playerPrefab != null)
|
||||
{
|
||||
if (oldPlayer != null && destroyBodyAfterDead)
|
||||
{
|
||||
if (displayInfoInFadeText && vHUDController.instance)
|
||||
{
|
||||
vHUDController.instance.ShowText("Player destroyed: " + oldPlayer.name.Replace("(Clone)", "").Replace("Instance", ""));
|
||||
}
|
||||
|
||||
Destroy(oldPlayer);
|
||||
}
|
||||
|
||||
else if (oldPlayer != null)
|
||||
{
|
||||
if (displayInfoInFadeText && vHUDController.instance)
|
||||
{
|
||||
vHUDController.instance.ShowText("Remove Player Components: " + oldPlayer.name.Replace("(Clone)", "").Replace("Instance", ""));
|
||||
}
|
||||
|
||||
DestroyPlayerComponents(oldPlayer);
|
||||
}
|
||||
|
||||
currentPlayer = Instantiate(playerPrefab, targetPoint.position, targetPoint.rotation);
|
||||
currentController = currentPlayer.GetComponent<vThirdPersonController>();
|
||||
currentController.onDead.AddListener(OnCharacterDead);
|
||||
OnReloadGame.Invoke();
|
||||
|
||||
if (displayInfoInFadeText && vHUDController.instance)
|
||||
{
|
||||
vHUDController.instance.ShowText("Spawn player: " + currentPlayer.name.Replace("(Clone)", ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Spawn player
|
||||
/// </summary>
|
||||
/// <param name="prefab"></param>
|
||||
public virtual void SpawnPlayer(GameObject prefab)
|
||||
{
|
||||
if (prefab != null && spawnPoint != null)
|
||||
{
|
||||
var targetPoint = spawnPoint;
|
||||
if (oldPlayer != null && destroyBodyAfterDead)
|
||||
{
|
||||
if (displayInfoInFadeText && vHUDController.instance)
|
||||
{
|
||||
vHUDController.instance.ShowText("Player destroyed: " + oldPlayer.name.Replace("(Clone)", "").Replace("Instance", ""));
|
||||
}
|
||||
|
||||
Destroy(oldPlayer);
|
||||
}
|
||||
|
||||
else if (oldPlayer != null)
|
||||
{
|
||||
if (displayInfoInFadeText && vHUDController.instance)
|
||||
{
|
||||
vHUDController.instance.ShowText("Remove Player Components: " + oldPlayer.name.Replace("(Clone)", "").Replace("Instance", ""));
|
||||
}
|
||||
|
||||
DestroyPlayerComponents(oldPlayer);
|
||||
}
|
||||
|
||||
currentPlayer = Instantiate(prefab, targetPoint.position, targetPoint.rotation);
|
||||
currentController = currentPlayer.GetComponent<vThirdPersonController>();
|
||||
currentController.onDead.AddListener(OnCharacterDead);
|
||||
OnReloadGame.Invoke();
|
||||
|
||||
if (displayInfoInFadeText && vHUDController.instance)
|
||||
{
|
||||
vHUDController.instance.ShowText("Spawn player: " + currentPlayer.name.Replace("(Clone)", ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reload current Scene and current Player
|
||||
/// </summary>
|
||||
public virtual void ResetScene()
|
||||
{
|
||||
if (oldPlayer)
|
||||
{
|
||||
DestroyPlayerComponents(oldPlayer);
|
||||
}
|
||||
|
||||
var scene = SceneManager.GetActiveScene();
|
||||
SceneManager.LoadScene(scene.name);
|
||||
|
||||
if (oldPlayer && destroyBodyAfterDead)
|
||||
{
|
||||
Destroy(oldPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f8a5c95eb7ab7db4f9f2151bae646701
|
||||
timeCreated: 1451348693
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,269 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Invector.vCharacterController
|
||||
{
|
||||
public class vHUDController : MonoBehaviour
|
||||
{
|
||||
#region General Variables
|
||||
|
||||
#region Health/Stamina Variables
|
||||
[Header("Health/Stamina")]
|
||||
public Slider healthSlider;
|
||||
public float healthSliderMaxValueSmooth = 10f;
|
||||
public float healthSliderValueSmooth = 10;
|
||||
public Slider staminaSlider;
|
||||
public float staminaSliderMaxValueSmooth = 10f;
|
||||
public float staminaSliderValueSmooth = 100;
|
||||
[Header("DamageHUD")]
|
||||
public Image damageImage;
|
||||
public float flashSpeed = 5f;
|
||||
public Color flashColour = new Color(1f, 0f, 0f, 0.1f);
|
||||
[HideInInspector] public bool damaged;
|
||||
#endregion
|
||||
|
||||
#region Display Controls Variables
|
||||
[Header("Controls Display")]
|
||||
[HideInInspector]
|
||||
public bool controllerInput;
|
||||
public Image displayControls;
|
||||
public Sprite joystickControls;
|
||||
public Sprite keyboardControls;
|
||||
#endregion
|
||||
|
||||
#region Debug Info Variables
|
||||
[Header("Debug Window")]
|
||||
public GameObject debugPanel;
|
||||
[HideInInspector]
|
||||
public Text debugText;
|
||||
#endregion
|
||||
|
||||
#region Change Input Text Variables
|
||||
[Header("Text with FadeIn/Out")]
|
||||
public Text fadeText;
|
||||
private float textDuration, fadeDuration, durationTimer, timer;
|
||||
private Color startColor, endColor;
|
||||
private bool fade;
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
private static vHUDController _instance;
|
||||
public static vHUDController instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = GameObject.FindObjectOfType<vHUDController>();
|
||||
//Tell unity not to destroy this object when loading a new scene
|
||||
//DontDestroyOnLoad(_instance.gameObject);
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
InitFadeText();
|
||||
if (debugPanel != null)
|
||||
debugText = debugPanel.GetComponentInChildren<Text>();
|
||||
}
|
||||
|
||||
public void Init(vThirdPersonController cc)
|
||||
{
|
||||
cc.onDead.AddListener(OnDead);
|
||||
cc.onReceiveDamage.AddListener(EnableDamageSprite);
|
||||
damageImage.color = new Color(0f, 0f, 0f, 0f);
|
||||
if (healthSlider)
|
||||
{
|
||||
if (cc.maxHealth != healthSlider.maxValue)
|
||||
{
|
||||
healthSlider.maxValue = cc.maxHealth;
|
||||
healthSlider.onValueChanged.Invoke(healthSlider.value);
|
||||
}
|
||||
healthSlider.value = cc.currentHealth;
|
||||
}
|
||||
if (staminaSlider)
|
||||
{
|
||||
if (cc.maxStamina != staminaSlider.maxValue)
|
||||
{
|
||||
staminaSlider.maxValue = cc.maxStamina;
|
||||
staminaSlider.onValueChanged.Invoke(staminaSlider.value);
|
||||
}
|
||||
staminaSlider.value = cc.currentStamina;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDead(GameObject arg0)
|
||||
{
|
||||
ShowText("You are Dead!");
|
||||
}
|
||||
|
||||
public virtual void UpdateHUD(vThirdPersonController cc)
|
||||
{
|
||||
UpdateDebugWindow(cc);
|
||||
UpdateSliders(cc);
|
||||
ChangeInputDisplay();
|
||||
ShowDamageSprite();
|
||||
FadeEffect();
|
||||
}
|
||||
|
||||
public void ShowText(string message, float textTime = 2f, float fadeTime = 0.5f)
|
||||
{
|
||||
if (fadeText != null && !fade)
|
||||
{
|
||||
fadeText.text = message;
|
||||
textDuration = textTime;
|
||||
fadeDuration = fadeTime;
|
||||
durationTimer = 0f;
|
||||
timer = 0f;
|
||||
fade = true;
|
||||
}
|
||||
else if (fadeText != null)
|
||||
{
|
||||
fadeText.text += "\n" + message;
|
||||
textDuration = textTime;
|
||||
fadeDuration = fadeTime;
|
||||
durationTimer = 0f;
|
||||
timer = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowText(string message)
|
||||
{
|
||||
if (fadeText != null && !fade)
|
||||
{
|
||||
fadeText.text = message;
|
||||
textDuration = 2f;
|
||||
fadeDuration = 0.5f;
|
||||
durationTimer = 0f;
|
||||
timer = 0f;
|
||||
fade = true;
|
||||
}
|
||||
else if (fadeText != null)
|
||||
{
|
||||
fadeText.text += "\n" + message;
|
||||
textDuration = 2f;
|
||||
fadeDuration = 0.5f;
|
||||
durationTimer = 0f;
|
||||
timer = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateSliders(vThirdPersonController cc)
|
||||
{
|
||||
if (healthSlider != null)
|
||||
{
|
||||
if (cc.maxHealth != healthSlider.maxValue)
|
||||
{
|
||||
healthSlider.maxValue = Mathf.Lerp(healthSlider.maxValue, cc.maxHealth, healthSliderMaxValueSmooth * Time.fixedDeltaTime);
|
||||
healthSlider.onValueChanged.Invoke(healthSlider.value);
|
||||
}
|
||||
healthSlider.value = Mathf.Lerp(healthSlider.value, cc.currentHealth, healthSliderValueSmooth * Time.fixedDeltaTime);
|
||||
}
|
||||
if (staminaSlider)
|
||||
{
|
||||
if (cc.maxStamina != staminaSlider.maxValue)
|
||||
{
|
||||
staminaSlider.maxValue = Mathf.Lerp(staminaSlider.maxValue, cc.maxStamina, staminaSliderMaxValueSmooth * Time.fixedDeltaTime);
|
||||
staminaSlider.onValueChanged.Invoke(staminaSlider.value);
|
||||
}
|
||||
staminaSlider.value = Mathf.Lerp(staminaSlider.value, cc.currentStamina, staminaSliderValueSmooth * Time.fixedDeltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowDamageSprite()
|
||||
{
|
||||
if (damaged)
|
||||
{
|
||||
damaged = false;
|
||||
if (damageImage != null)
|
||||
damageImage.color = flashColour;
|
||||
}
|
||||
else if (damageImage != null)
|
||||
damageImage.color = Color.Lerp(damageImage.color, Color.clear, flashSpeed * Time.deltaTime);
|
||||
}
|
||||
|
||||
public void EnableDamageSprite(vDamage damage)
|
||||
{
|
||||
if (damageImage != null)
|
||||
damageImage.enabled = true;
|
||||
damaged = true;
|
||||
}
|
||||
|
||||
void UpdateDebugWindow(vThirdPersonController cc)
|
||||
{
|
||||
if (cc.debugWindow)
|
||||
{
|
||||
if (debugPanel != null && !debugPanel.activeSelf)
|
||||
debugPanel.SetActive(true);
|
||||
if (debugText)
|
||||
debugText.text = cc.DebugInfo();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (debugPanel != null && debugPanel.activeSelf)
|
||||
debugPanel.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
void ChangeInputDisplay()
|
||||
{
|
||||
if (displayControls == null) return;
|
||||
#if MOBILE_INPUT
|
||||
displayControls.enabled = false;
|
||||
#else
|
||||
if (controllerInput && vInput.instance.inputDevice == InputDevice.Joystick)
|
||||
displayControls.sprite = joystickControls;
|
||||
else
|
||||
displayControls.sprite = keyboardControls;
|
||||
#endif
|
||||
}
|
||||
|
||||
void InitFadeText()
|
||||
{
|
||||
if (fadeText != null)
|
||||
{
|
||||
fadeText.verticalOverflow = VerticalWrapMode.Overflow;
|
||||
startColor = fadeText.color;
|
||||
endColor.a = 0f;
|
||||
fadeText.color = endColor;
|
||||
}
|
||||
else
|
||||
Debug.Log("Please assign a Text object on the field Fade Text");
|
||||
}
|
||||
|
||||
void FadeEffect()
|
||||
{
|
||||
if (fadeText != null)
|
||||
{
|
||||
if (fade)
|
||||
{
|
||||
fadeText.color = Color.Lerp(endColor, startColor, timer);
|
||||
|
||||
if (timer < 1)
|
||||
timer += Time.deltaTime / fadeDuration;
|
||||
|
||||
if (fadeText.color.a >= 1)
|
||||
{
|
||||
fade = false;
|
||||
timer = 0f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fadeText.color.a >= 1)
|
||||
durationTimer += Time.deltaTime;
|
||||
|
||||
if (durationTimer >= textDuration)
|
||||
{
|
||||
fadeText.color = Color.Lerp(startColor, endColor, timer);
|
||||
if (timer < 1)
|
||||
timer += Time.deltaTime / fadeDuration;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2f66a52c3c67ac0438fa54788c311abf
|
||||
timeCreated: 1431398482
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Invector.vCharacterController
|
||||
{
|
||||
[System.Serializable]
|
||||
public class OnActiveRagdoll : UnityEngine.Events.UnityEvent<vDamage> { }
|
||||
public interface vICharacter : vIHealthController
|
||||
{
|
||||
OnActiveRagdoll onActiveRagdoll { get; }
|
||||
Animator animator { get; }
|
||||
bool isCrouching { get; }
|
||||
bool ragdolled { get; set; }
|
||||
void EnableRagdoll();
|
||||
void ResetRagdoll();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 27f3148d37abd6248842df7b12d08509
|
||||
timeCreated: 1529517453
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,834 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
#if MOBILE_INPUT
|
||||
using UnityStandardAssets.CrossPlatformInput;
|
||||
#endif
|
||||
|
||||
namespace Invector.vCharacterController
|
||||
{
|
||||
public class vInput : MonoBehaviour
|
||||
{
|
||||
public delegate void OnChangeInputType(InputDevice type);
|
||||
public event OnChangeInputType onChangeInputType;
|
||||
private static vInput _instance;
|
||||
public static vInput instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = GameObject.FindObjectOfType<vInput>();
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = new GameObject("vInputType").AddComponent<vInput>();
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
public vHUDController hud;
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (hud == null) hud = vHUDController.instance;
|
||||
|
||||
}
|
||||
|
||||
private InputDevice _inputType = InputDevice.MouseKeyboard;
|
||||
[HideInInspector]
|
||||
public InputDevice inputDevice
|
||||
{
|
||||
get { return _inputType; }
|
||||
set
|
||||
{
|
||||
_inputType = value;
|
||||
OnChangeInput();
|
||||
}
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
switch (inputDevice)
|
||||
{
|
||||
case InputDevice.MouseKeyboard:
|
||||
if (isJoystickInput())
|
||||
{
|
||||
inputDevice = InputDevice.Joystick;
|
||||
|
||||
if (hud != null)
|
||||
{
|
||||
hud.controllerInput = true;
|
||||
hud.ShowText("Control scheme changed to Controller", 2f, 0.5f);
|
||||
}
|
||||
}
|
||||
else if (isMobileInput())
|
||||
{
|
||||
inputDevice = InputDevice.Mobile;
|
||||
if (hud != null)
|
||||
{
|
||||
hud.controllerInput = true;
|
||||
hud.ShowText("Control scheme changed to Mobile", 2f, 0.5f);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case InputDevice.Joystick:
|
||||
if (isMouseKeyboard())
|
||||
{
|
||||
inputDevice = InputDevice.MouseKeyboard;
|
||||
if (hud != null)
|
||||
{
|
||||
hud.controllerInput = false;
|
||||
hud.ShowText("Control scheme changed to Keyboard/Mouse", 2f, 0.5f);
|
||||
}
|
||||
}
|
||||
else if (isMobileInput())
|
||||
{
|
||||
inputDevice = InputDevice.Mobile;
|
||||
if (hud != null)
|
||||
{
|
||||
hud.controllerInput = true;
|
||||
hud.ShowText("Control scheme changed to Mobile", 2f, 0.5f);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case InputDevice.Mobile:
|
||||
if (isMouseKeyboard())
|
||||
{
|
||||
inputDevice = InputDevice.MouseKeyboard;
|
||||
if (hud != null)
|
||||
{
|
||||
hud.controllerInput = false;
|
||||
hud.ShowText("Control scheme changed to Keyboard/Mouse", 2f, 0.5f);
|
||||
}
|
||||
}
|
||||
else if (isJoystickInput())
|
||||
{
|
||||
inputDevice = InputDevice.Joystick;
|
||||
if (hud != null)
|
||||
{
|
||||
hud.controllerInput = true;
|
||||
hud.ShowText("Control scheme changed to Controller", 2f, 0.5f);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private bool isMobileInput()
|
||||
{
|
||||
#if UNITY_EDITOR && UNITY_MOBILE
|
||||
if (EventSystem.current.IsPointerOverGameObject() && Input.GetMouseButtonDown(0))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
#elif MOBILE_INPUT
|
||||
if (EventSystem.current.IsPointerOverGameObject() || (Input.touches.Length > 0))
|
||||
return true;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool isMouseKeyboard()
|
||||
{
|
||||
#if MOBILE_INPUT
|
||||
return false;
|
||||
#else
|
||||
// mouse & keyboard buttons
|
||||
if (Event.current.isKey || Event.current.isMouse)
|
||||
return true;
|
||||
// mouse movement
|
||||
if (Input.GetAxis("Mouse X") != 0.0f || Input.GetAxis("Mouse Y") != 0.0f)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
private bool isJoystickInput()
|
||||
{
|
||||
// joystick buttons
|
||||
if (Input.GetKey(KeyCode.Joystick1Button0) ||
|
||||
Input.GetKey(KeyCode.Joystick1Button1) ||
|
||||
Input.GetKey(KeyCode.Joystick1Button2) ||
|
||||
Input.GetKey(KeyCode.Joystick1Button3) ||
|
||||
Input.GetKey(KeyCode.Joystick1Button4) ||
|
||||
Input.GetKey(KeyCode.Joystick1Button5) ||
|
||||
Input.GetKey(KeyCode.Joystick1Button6) ||
|
||||
Input.GetKey(KeyCode.Joystick1Button7) ||
|
||||
Input.GetKey(KeyCode.Joystick1Button8) ||
|
||||
Input.GetKey(KeyCode.Joystick1Button9) ||
|
||||
Input.GetKey(KeyCode.Joystick1Button10) ||
|
||||
Input.GetKey(KeyCode.Joystick1Button11) ||
|
||||
Input.GetKey(KeyCode.Joystick1Button12) ||
|
||||
Input.GetKey(KeyCode.Joystick1Button13) ||
|
||||
Input.GetKey(KeyCode.Joystick1Button14) ||
|
||||
Input.GetKey(KeyCode.Joystick1Button15) ||
|
||||
Input.GetKey(KeyCode.Joystick1Button16) ||
|
||||
Input.GetKey(KeyCode.Joystick1Button17) ||
|
||||
Input.GetKey(KeyCode.Joystick1Button18) ||
|
||||
Input.GetKey(KeyCode.Joystick1Button19))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// joystick axis
|
||||
if (Input.GetAxis("LeftAnalogHorizontal") != 0.0f ||
|
||||
Input.GetAxis("LeftAnalogVertical") != 0.0f ||
|
||||
Input.GetAxis("RightAnalogHorizontal") != 0.0f ||
|
||||
Input.GetAxis("RightAnalogVertical") != 0.0f ||
|
||||
Input.GetAxis("LT") != 0.0f ||
|
||||
Input.GetAxis("RT") != 0.0f ||
|
||||
Input.GetAxis("D-Pad Horizontal") != 0.0f ||
|
||||
Input.GetAxis("D-Pad Vertical") != 0.0f)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void OnChangeInput()
|
||||
{
|
||||
if (onChangeInputType != null)
|
||||
{
|
||||
onChangeInputType(inputDevice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// INPUT TYPE - check in real time if you are using a joystick, mobile or mouse/keyboard
|
||||
/// </summary>
|
||||
[HideInInspector]
|
||||
public enum InputDevice
|
||||
{
|
||||
MouseKeyboard,
|
||||
Joystick,
|
||||
Mobile
|
||||
};
|
||||
|
||||
[System.Serializable]
|
||||
public class GenericInput
|
||||
{
|
||||
protected InputDevice inputDevice { get { return vInput.instance.inputDevice; } }
|
||||
public bool useInput = true;
|
||||
[SerializeField]
|
||||
private bool isAxisInUse;
|
||||
[SerializeField]
|
||||
private bool isUnityInput;
|
||||
[SerializeField]
|
||||
public string keyboard;
|
||||
[SerializeField]
|
||||
public bool keyboardAxis;
|
||||
[SerializeField]
|
||||
public string joystick;
|
||||
[SerializeField]
|
||||
public bool joystickAxis;
|
||||
[SerializeField]
|
||||
public string mobile;
|
||||
[SerializeField]
|
||||
public bool mobileAxis;
|
||||
|
||||
[SerializeField]
|
||||
public bool joystickAxisInvert;
|
||||
[SerializeField]
|
||||
public bool keyboardAxisInvert;
|
||||
[SerializeField]
|
||||
public bool mobileAxisInvert;
|
||||
|
||||
public float timeButtonWasPressed;
|
||||
public float lastTimeTheButtonWasPressed;
|
||||
public bool inButtomTimer;
|
||||
private float multTapTimer;
|
||||
private int multTapCounter;
|
||||
|
||||
public bool isAxis
|
||||
{
|
||||
get
|
||||
{
|
||||
bool value = false;
|
||||
switch (inputDevice)
|
||||
{
|
||||
case InputDevice.Joystick:
|
||||
value = joystickAxis;
|
||||
break;
|
||||
case InputDevice.MouseKeyboard:
|
||||
value = keyboardAxis;
|
||||
break;
|
||||
case InputDevice.Mobile:
|
||||
value = mobileAxis;
|
||||
break;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool isAxisInvert
|
||||
{
|
||||
get
|
||||
{
|
||||
bool value = false;
|
||||
switch (inputDevice)
|
||||
{
|
||||
case InputDevice.Joystick:
|
||||
value = joystickAxisInvert;
|
||||
break;
|
||||
case InputDevice.MouseKeyboard:
|
||||
value = keyboardAxisInvert;
|
||||
break;
|
||||
case InputDevice.Mobile:
|
||||
value = mobileAxisInvert;
|
||||
break;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialise a new GenericInput
|
||||
/// </summary>
|
||||
/// <param name="keyboard"></param>
|
||||
/// <param name="joystick"></param>
|
||||
/// <param name="mobile"></param>
|
||||
public GenericInput(string keyboard, string joystick, string mobile)
|
||||
{
|
||||
this.keyboard = keyboard;
|
||||
this.joystick = joystick;
|
||||
this.mobile = mobile;
|
||||
|
||||
GenerateKeyCodeHash();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialise a new GenericInput
|
||||
/// </summary>
|
||||
/// <param name="keyboard"></param>
|
||||
/// <param name="joystick"></param>
|
||||
/// <param name="mobile"></param>
|
||||
public GenericInput(string keyboard, bool keyboardAxis, string joystick, bool joystickAxis, string mobile, bool mobileAxis)
|
||||
{
|
||||
this.keyboard = keyboard;
|
||||
this.keyboardAxis = keyboardAxis;
|
||||
this.joystick = joystick;
|
||||
this.joystickAxis = joystickAxis;
|
||||
this.mobile = mobile;
|
||||
this.mobileAxis = mobileAxis;
|
||||
|
||||
GenerateKeyCodeHash();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialise a new GenericInput
|
||||
/// </summary>
|
||||
/// <param name="keyboard"></param>
|
||||
/// <param name="joystick"></param>
|
||||
/// <param name="mobile"></param>
|
||||
public GenericInput(string keyboard, bool keyboardAxis, bool keyboardInvert, string joystick, bool joystickAxis, bool joystickInvert, string mobile, bool mobileAxis, bool mobileInvert)
|
||||
{
|
||||
this.keyboard = keyboard;
|
||||
this.keyboardAxis = keyboardAxis;
|
||||
this.keyboardAxisInvert = keyboardInvert;
|
||||
this.joystick = joystick;
|
||||
this.joystickAxis = joystickAxis;
|
||||
this.joystickAxisInvert = joystickInvert;
|
||||
this.mobile = mobile;
|
||||
this.mobileAxis = mobileAxis;
|
||||
this.mobileAxisInvert = mobileInvert;
|
||||
|
||||
GenerateKeyCodeHash();
|
||||
}
|
||||
/// <summary>
|
||||
/// Button Name
|
||||
/// </summary>
|
||||
public string buttonName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (vInput.instance != null)
|
||||
{
|
||||
if (vInput.instance.inputDevice == InputDevice.MouseKeyboard) return keyboard.ToString();
|
||||
else if (vInput.instance.inputDevice == InputDevice.Joystick) return joystick;
|
||||
else return mobile;
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if button is a Key
|
||||
/// </summary>
|
||||
public bool isKey
|
||||
{
|
||||
get
|
||||
{
|
||||
if (vInput.instance != null && !isUnityInput)
|
||||
{
|
||||
if (string.IsNullOrEmpty(lastButtonName) || lastButtonName != buttonName)
|
||||
{
|
||||
m_isKey = System.Enum.IsDefined(typeof(KeyCode), buttonName);
|
||||
lastButtonName = buttonName;
|
||||
}
|
||||
if (m_isKey)
|
||||
return true;
|
||||
isUnityInput = true;
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
string lastButtonName = "";
|
||||
bool m_isKey = false;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get <see cref="KeyCode"/> value
|
||||
/// </summary>
|
||||
public KeyCode key
|
||||
{
|
||||
get
|
||||
{
|
||||
return (KeyCode)keyCodeHash[buttonName];
|
||||
}
|
||||
}
|
||||
|
||||
private static Hashtable keyCodeHash = new Hashtable();
|
||||
|
||||
static void GenerateKeyCodeHash()
|
||||
{
|
||||
// only want to generate this hash once
|
||||
if (keyCodeHash.Count > 0)
|
||||
return;
|
||||
|
||||
string[] names = Enum.GetNames(typeof(KeyCode));
|
||||
foreach (string name in names)
|
||||
{
|
||||
keyCodeHash.Add(name, (KeyCode)Enum.Parse(typeof(KeyCode), name));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get Button
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool GetButton()
|
||||
{
|
||||
if (string.IsNullOrEmpty(buttonName) || !IsButtonAvailable(this.buttonName)) return false;
|
||||
if (isAxis) return GetAxisButton();
|
||||
|
||||
// mobile
|
||||
if (inputDevice == InputDevice.Mobile)
|
||||
{
|
||||
#if MOBILE_INPUT
|
||||
if (CrossPlatformInputManager.GetButton(this.buttonName))
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
// keyboard/mouse
|
||||
else if (inputDevice == InputDevice.MouseKeyboard)
|
||||
{
|
||||
if (isKey)
|
||||
{
|
||||
if (Input.GetKey(key))
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Input.GetButton(this.buttonName))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// joystick
|
||||
else if (inputDevice == InputDevice.Joystick)
|
||||
{
|
||||
if (Input.GetButton(this.buttonName))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get ButtonDown
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool GetButtonDown()
|
||||
{
|
||||
if (string.IsNullOrEmpty(buttonName) || !IsButtonAvailable(this.buttonName)) return false;
|
||||
if (isAxis) return GetAxisButtonDown();
|
||||
// mobile
|
||||
if (inputDevice == InputDevice.Mobile)
|
||||
{
|
||||
#if MOBILE_INPUT
|
||||
if (CrossPlatformInputManager.GetButtonDown(this.buttonName))
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
// keyboard/mouse
|
||||
else if (inputDevice == InputDevice.MouseKeyboard)
|
||||
{
|
||||
if (isKey)
|
||||
{
|
||||
if (Input.GetKeyDown(key))
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Input.GetButtonDown(this.buttonName))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// joystick
|
||||
else if (inputDevice == InputDevice.Joystick)
|
||||
{
|
||||
if (Input.GetButtonDown(this.buttonName))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Button Up
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool GetButtonUp()
|
||||
{
|
||||
if (string.IsNullOrEmpty(buttonName) || !IsButtonAvailable(this.buttonName)) return false;
|
||||
if (isAxis) return GetAxisButtonUp();
|
||||
|
||||
// mobile
|
||||
if (inputDevice == InputDevice.Mobile)
|
||||
{
|
||||
#if MOBILE_INPUT
|
||||
if (CrossPlatformInputManager.GetButtonUp(this.buttonName))
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
// keyboard/mouse
|
||||
else if (inputDevice == InputDevice.MouseKeyboard)
|
||||
{
|
||||
if (isKey)
|
||||
{
|
||||
if (Input.GetKeyUp(key))
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Input.GetButtonUp(this.buttonName))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// joystick
|
||||
else if (inputDevice == InputDevice.Joystick)
|
||||
{
|
||||
if (Input.GetButtonUp(this.buttonName))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Axis
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public float GetAxis()
|
||||
{
|
||||
if (string.IsNullOrEmpty(buttonName) || !IsButtonAvailable(this.buttonName) || isKey) return 0;
|
||||
|
||||
// mobile
|
||||
if (inputDevice == InputDevice.Mobile)
|
||||
{
|
||||
#if MOBILE_INPUT
|
||||
return CrossPlatformInputManager.GetAxis(this.buttonName);
|
||||
#endif
|
||||
}
|
||||
// keyboard/mouse
|
||||
else if (inputDevice == InputDevice.MouseKeyboard)
|
||||
{
|
||||
return Input.GetAxis(this.buttonName);
|
||||
}
|
||||
// joystick
|
||||
else if (inputDevice == InputDevice.Joystick)
|
||||
{
|
||||
return Input.GetAxis(this.buttonName);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Axis Raw
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public float GetAxisRaw()
|
||||
{
|
||||
if (string.IsNullOrEmpty(buttonName) || !IsButtonAvailable(this.buttonName) || isKey) return 0;
|
||||
|
||||
// mobile
|
||||
if (inputDevice == InputDevice.Mobile)
|
||||
{
|
||||
#if MOBILE_INPUT
|
||||
return CrossPlatformInputManager.GetAxisRaw(this.buttonName);
|
||||
#endif
|
||||
}
|
||||
// keyboard/mouse
|
||||
else if (inputDevice == InputDevice.MouseKeyboard)
|
||||
{
|
||||
return Input.GetAxisRaw(this.buttonName);
|
||||
}
|
||||
// joystick
|
||||
else if (inputDevice == InputDevice.Joystick)
|
||||
{
|
||||
return Input.GetAxisRaw(this.buttonName);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Double Button Down Check if button is pressed Within the defined time
|
||||
/// </summary>
|
||||
/// <param name="inputTime"></param>
|
||||
/// <returns></returns>
|
||||
public bool GetDoubleButtonDown(float inputTime = 1)
|
||||
{
|
||||
if (string.IsNullOrEmpty(buttonName) || !IsButtonAvailable(this.buttonName)) return false;
|
||||
|
||||
|
||||
if (multTapCounter == 0 && GetButtonDown())
|
||||
{
|
||||
multTapTimer = Time.time;
|
||||
multTapCounter = 1;
|
||||
return false;
|
||||
}
|
||||
else if (multTapCounter == 1 && GetButtonDown())
|
||||
{
|
||||
var time = multTapTimer + inputTime;
|
||||
var valid = (Time.time < time);
|
||||
multTapTimer = 0;
|
||||
multTapCounter = 0;
|
||||
return valid;
|
||||
}
|
||||
else if (multTapCounter == 1 && multTapTimer + inputTime < Time.time)
|
||||
{
|
||||
multTapTimer = 0;
|
||||
multTapCounter = 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Buttom Timer Check if a button is pressed for defined time
|
||||
/// </summary>
|
||||
/// <param name="inputTime"> time to check button press</param>
|
||||
/// <returns></returns>
|
||||
public bool GetButtonTimer(float inputTime = 2)
|
||||
{
|
||||
if (string.IsNullOrEmpty(buttonName) || !IsButtonAvailable(this.buttonName)) return false;
|
||||
if (GetButtonDown() && !inButtomTimer)
|
||||
{
|
||||
lastTimeTheButtonWasPressed = Time.time + 0.1f;
|
||||
timeButtonWasPressed = Time.time;
|
||||
inButtomTimer = true;
|
||||
}
|
||||
if (inButtomTimer)
|
||||
{
|
||||
var time = timeButtonWasPressed + inputTime;
|
||||
var valid = (time - Time.time <= 0);
|
||||
|
||||
if (!GetButton() || lastTimeTheButtonWasPressed < Time.time)
|
||||
{
|
||||
inButtomTimer = false;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
lastTimeTheButtonWasPressed = Time.time + 0.1f;
|
||||
}
|
||||
if (valid)
|
||||
{
|
||||
inButtomTimer = false;
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Buttom Timer Check if a button is pressed for defined time
|
||||
/// </summary>
|
||||
/// <param name="inputTime"> time to check button press</param>
|
||||
/// <returns></returns>
|
||||
public bool GetButtonTimer(ref float currentTimer, float inputTime = 2)
|
||||
{
|
||||
if (string.IsNullOrEmpty(buttonName) || !IsButtonAvailable(this.buttonName)) return false;
|
||||
if (GetButtonDown() && !inButtomTimer)
|
||||
{
|
||||
lastTimeTheButtonWasPressed = Time.time + 0.1f;
|
||||
timeButtonWasPressed = Time.time;
|
||||
inButtomTimer = true;
|
||||
}
|
||||
if (inButtomTimer)
|
||||
{
|
||||
var time = timeButtonWasPressed + inputTime;
|
||||
currentTimer = time - Time.time;
|
||||
var valid = (time - Time.time <= 0);
|
||||
|
||||
if (!GetButton() || lastTimeTheButtonWasPressed < Time.time)
|
||||
{
|
||||
inButtomTimer = false;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
lastTimeTheButtonWasPressed = Time.time + 0.1f;
|
||||
}
|
||||
if (valid)
|
||||
{
|
||||
inButtomTimer = false;
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Buttom Timer Check if a button is pressed for defined time
|
||||
/// </summary>
|
||||
/// <param name="inputTime"> time to check button press</param>
|
||||
/// <returns></returns>
|
||||
public bool GetButtonTimer(ref float currentTimer, ref bool upAfterPressed, float inputTime = 2)
|
||||
{
|
||||
if (string.IsNullOrEmpty(buttonName) || !IsButtonAvailable(this.buttonName)) return false;
|
||||
if (GetButtonDown())
|
||||
{
|
||||
lastTimeTheButtonWasPressed = Time.time + 0.1f;
|
||||
timeButtonWasPressed = Time.time;
|
||||
inButtomTimer = true;
|
||||
}
|
||||
if (inButtomTimer)
|
||||
{
|
||||
var time = timeButtonWasPressed + inputTime;
|
||||
currentTimer = (inputTime - (time - Time.time)) / inputTime;
|
||||
var valid = (time - Time.time <= 0);
|
||||
|
||||
if (!GetButton() || lastTimeTheButtonWasPressed < Time.time)
|
||||
{
|
||||
inButtomTimer = false;
|
||||
upAfterPressed = true;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
upAfterPressed = false;
|
||||
lastTimeTheButtonWasPressed = Time.time + 0.1f;
|
||||
}
|
||||
if (valid)
|
||||
{
|
||||
inButtomTimer = false;
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Axis like a button
|
||||
/// </summary>
|
||||
/// <param name="value">Value to check need to be diferent 0</param>
|
||||
/// <returns></returns>
|
||||
public bool GetAxisButton(float value = 0.5f)
|
||||
{
|
||||
if (string.IsNullOrEmpty(buttonName) || !IsButtonAvailable(this.buttonName)) return false;
|
||||
if (isAxisInvert) value *= -1f;
|
||||
if (value > 0)
|
||||
{
|
||||
return GetAxisRaw() >= value;
|
||||
}
|
||||
else if (value < 0)
|
||||
{
|
||||
return GetAxisRaw() <= value;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Axis like a buttonDown
|
||||
/// </summary>
|
||||
/// <param name="value">Value to check need to be diferent 0</param>
|
||||
/// <returns></returns>
|
||||
public bool GetAxisButtonDown(float value = 0.5f)
|
||||
{
|
||||
if (string.IsNullOrEmpty(buttonName) || !IsButtonAvailable(this.buttonName)) return false;
|
||||
if (isAxisInvert) value *= -1f;
|
||||
if (value > 0)
|
||||
{
|
||||
if (!isAxisInUse && GetAxisRaw() >= value)
|
||||
{
|
||||
isAxisInUse = true;
|
||||
return true;
|
||||
}
|
||||
else if (isAxisInUse && GetAxisRaw() == 0)
|
||||
{
|
||||
isAxisInUse = false;
|
||||
}
|
||||
}
|
||||
else if (value < 0)
|
||||
{
|
||||
if (!isAxisInUse && GetAxisRaw() <= value)
|
||||
{
|
||||
isAxisInUse = true;
|
||||
return true;
|
||||
}
|
||||
else if (isAxisInUse && GetAxisRaw() == 0)
|
||||
{
|
||||
isAxisInUse = false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Axis like a buttonUp
|
||||
/// Check if Axis is zero after press
|
||||
/// <returns></returns>
|
||||
public bool GetAxisButtonUp()
|
||||
{
|
||||
if (string.IsNullOrEmpty(buttonName) || !IsButtonAvailable(this.buttonName)) return false;
|
||||
if (isAxisInUse && GetAxisRaw() == 0)
|
||||
{
|
||||
isAxisInUse = false;
|
||||
return true;
|
||||
}
|
||||
else if (!isAxisInUse && GetAxisRaw() != 0)
|
||||
{
|
||||
isAxisInUse = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsButtonAvailable(string btnName)
|
||||
{
|
||||
if (!useInput) return false;
|
||||
try
|
||||
{
|
||||
if (isKey) return true;
|
||||
Input.GetButton(buttonName);
|
||||
return true;
|
||||
}
|
||||
catch (System.Exception exc)
|
||||
{
|
||||
if(isUnityInput)
|
||||
{
|
||||
isUnityInput = false;
|
||||
return isKey;
|
||||
}
|
||||
Debug.LogWarning($" Failure to try access Unity Input or KeyCode : {buttonName} \n {exc.Message}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a5f38ff1cd2f5aa458b6c1879bfc739d
|
||||
timeCreated: 1462203566
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
namespace Invector.vCharacterController
|
||||
{
|
||||
public class vOnDeadTrigger : MonoBehaviour
|
||||
{
|
||||
|
||||
public UnityEvent OnDead;
|
||||
void Start()
|
||||
{
|
||||
vCharacter character = GetComponent<vCharacter>();
|
||||
if (character)
|
||||
character.onDead.AddListener(OnDeadHandle);
|
||||
}
|
||||
|
||||
public void OnDeadHandle(GameObject target)
|
||||
{
|
||||
OnDead.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54d76107ccc5bf24b9863c2179f13dba
|
||||
timeCreated: 1475006679
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,360 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace Invector.vCharacterController
|
||||
{
|
||||
using vEventSystems;
|
||||
public class vThirdPersonAnimator : vThirdPersonMotor
|
||||
{
|
||||
#region Variables
|
||||
public float randomIdleCount;
|
||||
public const float walkSpeed = 0.5f;
|
||||
public const float runningSpeed = 1f;
|
||||
public const float sprintSpeed = 1.5f;
|
||||
public Vector3 lastCharacterPosition { get; protected set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[ContextMenu("Enable AnimatorStateInfos Debug")]
|
||||
void EnableAnimatorStateInfosDebug()
|
||||
{
|
||||
if (animatorStateInfos != null)
|
||||
{
|
||||
animatorStateInfos.debug = true;
|
||||
}
|
||||
}
|
||||
|
||||
[ContextMenu("Disable AnimatorStateInfos Debug")]
|
||||
void DisableAnimatorStateInfosDebug()
|
||||
{
|
||||
if (animatorStateInfos != null)
|
||||
{
|
||||
animatorStateInfos.debug = false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
RegisterAnimatorStateInfos();
|
||||
}
|
||||
|
||||
protected virtual void RegisterAnimatorStateInfos()
|
||||
{
|
||||
animatorStateInfos = new vAnimatorStateInfos(GetComponent<Animator>());
|
||||
animatorStateInfos.RegisterListener();
|
||||
}
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
if (animatorStateInfos.animator != null)
|
||||
{
|
||||
animatorStateInfos.RegisterListener();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
base.OnDisable();
|
||||
animatorStateInfos.RemoveListener();
|
||||
}
|
||||
|
||||
public virtual void UpdateAnimator()
|
||||
{
|
||||
if (animator == null || !animator.enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AnimatorLayerControl();
|
||||
ActionsControl();
|
||||
|
||||
TriggerRandomIdle();
|
||||
|
||||
UpdateAnimatorParameters();
|
||||
DeadAnimation();
|
||||
}
|
||||
|
||||
public virtual void AnimatorLayerControl()
|
||||
{
|
||||
baseLayerInfo = animator.GetCurrentAnimatorStateInfo(baseLayer);
|
||||
underBodyInfo = animator.GetCurrentAnimatorStateInfo(underBodyLayer);
|
||||
rightArmInfo = animator.GetCurrentAnimatorStateInfo(rightArmLayer);
|
||||
leftArmInfo = animator.GetCurrentAnimatorStateInfo(leftArmLayer);
|
||||
upperBodyInfo = animator.GetCurrentAnimatorStateInfo(upperBodyLayer);
|
||||
fullBodyInfo = animator.GetCurrentAnimatorStateInfo(fullbodyLayer);
|
||||
}
|
||||
|
||||
public virtual void ActionsControl()
|
||||
{
|
||||
// to have better control of your actions, you can assign bools to know if an animation is playing or not
|
||||
// this way you can use this bool to create custom behavior for the controller
|
||||
|
||||
// identify if the rolling animations is playing
|
||||
isRolling = IsAnimatorTag("IsRolling");
|
||||
// identify if a turn on spot animation is playing
|
||||
isTurningOnSpot = IsAnimatorTag("TurnOnSpot");
|
||||
// locks player movement while a animation with tag 'LockMovement' is playing
|
||||
lockAnimMovement = IsAnimatorTag("LockMovement");
|
||||
// locks player rotation while a animation with tag 'LockRotation' is playing
|
||||
lockAnimRotation = IsAnimatorTag("LockRotation");
|
||||
// ! -- you can add the Tag "CustomAction" into a AnimationState and the character will not perform any Melee action -- !
|
||||
customAction = IsAnimatorTag("CustomAction");
|
||||
// identify if the controller is airborne
|
||||
isInAirborne = IsAnimatorTag("Airborne");
|
||||
}
|
||||
|
||||
public virtual void UpdateAnimatorParameters()
|
||||
{
|
||||
if (disableAnimations)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
animator.SetBool(vAnimatorParameters.IsStrafing, isStrafing);
|
||||
animator.SetBool(vAnimatorParameters.IsSprinting, isSprinting);
|
||||
animator.SetBool(vAnimatorParameters.IsSliding, isSliding && !isRolling);
|
||||
animator.SetBool(vAnimatorParameters.IsCrouching, isCrouching);
|
||||
animator.SetBool(vAnimatorParameters.IsGrounded, isGrounded);
|
||||
animator.SetBool(vAnimatorParameters.IsDead, isDead);
|
||||
animator.SetFloat(vAnimatorParameters.GroundDistance, groundDistance);
|
||||
animator.SetFloat(vAnimatorParameters.GroundAngle, GroundAngleFromDirection());
|
||||
|
||||
if (!isGrounded)
|
||||
{
|
||||
animator.SetFloat(vAnimatorParameters.VerticalVelocity, verticalVelocity);
|
||||
}
|
||||
|
||||
//if (!lockAnimMovement)
|
||||
{
|
||||
if (isStrafing)
|
||||
{
|
||||
animator.SetFloat(vAnimatorParameters.InputHorizontal, horizontalSpeed, strafeSpeed.animationSmooth, Time.fixedDeltaTime);
|
||||
animator.SetFloat(vAnimatorParameters.InputVertical, verticalSpeed, strafeSpeed.animationSmooth, Time.fixedDeltaTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
animator.SetFloat(vAnimatorParameters.InputVertical, verticalSpeed, freeSpeed.animationSmooth, Time.fixedDeltaTime);
|
||||
animator.SetFloat(vAnimatorParameters.InputHorizontal, 0, freeSpeed.animationSmooth, Time.fixedDeltaTime);
|
||||
}
|
||||
|
||||
animator.SetFloat(vAnimatorParameters.InputMagnitude, Mathf.LerpUnclamped(inputMagnitude, 0f, stopMoveWeight), isStrafing ? strafeSpeed.animationSmooth : freeSpeed.animationSmooth, Time.fixedDeltaTime);
|
||||
|
||||
if (useLeanMovementAnim && inputMagnitude >= 0.1f)
|
||||
{
|
||||
animator.SetFloat(vAnimatorParameters.RotationMagnitude, rotationMagnitude, leanSmooth, Time.fixedDeltaTime);
|
||||
}
|
||||
else if (useTurnOnSpotAnim && inputMagnitude < 0.1f)
|
||||
{
|
||||
animator.SetFloat(vAnimatorParameters.RotationMagnitude, (float)System.Math.Round(rotationMagnitude, 2), turnOnSpotSmooth, Time.fixedDeltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void SetAnimatorMoveSpeed(vMovementSpeed speed)
|
||||
{
|
||||
Vector3 relativeInput = transform.InverseTransformDirection(moveDirection);
|
||||
verticalSpeed = relativeInput.z;
|
||||
horizontalSpeed = relativeInput.x;
|
||||
|
||||
var newInput = new Vector2(verticalSpeed, horizontalSpeed);
|
||||
|
||||
if (speed.walkByDefault || alwaysWalkByDefault)
|
||||
{
|
||||
inputMagnitude = Mathf.Clamp(newInput.magnitude, 0, isSprinting ? runningSpeed : walkSpeed);
|
||||
}
|
||||
else
|
||||
{
|
||||
var mag = newInput.magnitude;
|
||||
sprintWeight = Mathf.Lerp(sprintWeight, isSprinting ? 1f : 0f, (isStrafing ? strafeSpeed.movementSmooth : freeSpeed.movementSmooth) * Time.fixedDeltaTime);
|
||||
inputMagnitude = Mathf.Clamp(Mathf.Lerp(mag, mag + (newInput.magnitude > 0.1f ? 0.5f : 0), sprintWeight), 0, isSprinting ? sprintSpeed : runningSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void SetInputDirection(Vector3 direction)
|
||||
{
|
||||
float movementDirection = direction.magnitude >= .1 ? transform.forward.AngleFormOtherDirection(direction).y : 0;
|
||||
if (vAnimatorParameters.InputDirection != -1) animator.SetFloat(vAnimatorParameters.InputDirection, movementDirection);
|
||||
}
|
||||
|
||||
public virtual void ResetInputAnimatorParameters()
|
||||
{
|
||||
animator.SetBool(vAnimatorParameters.IsSprinting, false);
|
||||
animator.SetBool(vAnimatorParameters.IsSliding, false);
|
||||
animator.SetBool(vAnimatorParameters.IsCrouching, false);
|
||||
animator.SetBool(vAnimatorParameters.IsGrounded, true);
|
||||
animator.SetFloat(vAnimatorParameters.GroundDistance, 0f);
|
||||
animator.SetFloat("InputHorizontal", 0);
|
||||
animator.SetFloat("InputVertical", 0);
|
||||
animator.SetFloat("InputMagnitude", 0);
|
||||
}
|
||||
|
||||
protected virtual void TriggerRandomIdle()
|
||||
{
|
||||
if (input != Vector3.zero || customAction)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (randomIdleTime > 0)
|
||||
{
|
||||
if (input.sqrMagnitude == 0 && !isCrouching && _capsuleCollider.enabled && isGrounded)
|
||||
{
|
||||
randomIdleCount += Time.fixedDeltaTime;
|
||||
if (randomIdleCount > 6)
|
||||
{
|
||||
randomIdleCount = 0;
|
||||
animator.SetTrigger(vAnimatorParameters.IdleRandomTrigger);
|
||||
animator.SetInteger(vAnimatorParameters.IdleRandom, Random.Range(1, 4));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
randomIdleCount = 0;
|
||||
animator.SetInteger(vAnimatorParameters.IdleRandom, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void DeadAnimation()
|
||||
{
|
||||
if (!isDead)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// death by animation
|
||||
if (deathBy == DeathBy.Animation)
|
||||
{
|
||||
int deadLayer = 0;
|
||||
|
||||
var info = animatorStateInfos.GetStateInfoUsingTag("Dead");
|
||||
if (info != null)
|
||||
{
|
||||
if (!animator.IsInTransition(deadLayer) && info.normalizedTime >= 0.99f && groundDistance <= 0.15f)
|
||||
{
|
||||
RemoveComponents();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// death by animation & ragdoll after a time
|
||||
else if (deathBy == DeathBy.AnimationWithRagdoll)
|
||||
{
|
||||
int deadLayer = 0;
|
||||
var info = animatorStateInfos.GetStateInfoUsingTag("Dead");
|
||||
if (info != null)
|
||||
{
|
||||
if (!animator.IsInTransition(deadLayer) && info.normalizedTime >= 0.8f)
|
||||
{
|
||||
onActiveRagdoll.Invoke(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
// death by ragdoll
|
||||
else if (deathBy == DeathBy.Ragdoll)
|
||||
{
|
||||
onActiveRagdoll.Invoke(null);
|
||||
}
|
||||
}
|
||||
|
||||
#region Generic Animations Methods
|
||||
|
||||
public virtual void SetActionState(int value)
|
||||
{
|
||||
animator.SetInteger(vAnimatorParameters.ActionState, value);
|
||||
}
|
||||
|
||||
public virtual bool IsAnimatorTag(string tag)
|
||||
{
|
||||
if (animator == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (animatorStateInfos != null)
|
||||
{
|
||||
if (animatorStateInfos.HasTag(tag))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (baseLayerInfo.IsTag(tag))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (underBodyInfo.IsTag(tag))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (rightArmInfo.IsTag(tag))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (leftArmInfo.IsTag(tag))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (upperBodyInfo.IsTag(tag))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (fullBodyInfo.IsTag(tag))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual void MatchTarget(Vector3 matchPosition, Quaternion matchRotation, AvatarTarget target, MatchTargetWeightMask weightMask, float normalisedStartTime, float normalisedEndTime)
|
||||
{
|
||||
if (animator.isMatchingTarget || animator.IsInTransition(0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float normalizeTime = Mathf.Repeat(animator.GetCurrentAnimatorStateInfo(0).normalizedTime, 1f);
|
||||
|
||||
if (normalizeTime > normalisedEndTime)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
animator.MatchTarget(matchPosition, matchRotation, target, weightMask, normalisedStartTime, normalisedEndTime);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
public static partial class vAnimatorParameters
|
||||
{
|
||||
public static int InputHorizontal = Animator.StringToHash("InputHorizontal");
|
||||
public static int InputVertical = Animator.StringToHash("InputVertical");
|
||||
public static int InputMagnitude = Animator.StringToHash("InputMagnitude");
|
||||
public static int RotationMagnitude = Animator.StringToHash("RotationMagnitude");
|
||||
public static int TurnOnSpotDirection = Animator.StringToHash("TurnOnSpotDirection");
|
||||
public static int ActionState = Animator.StringToHash("ActionState");
|
||||
public static int ResetState = Animator.StringToHash("ResetState");
|
||||
public static int IsDead = Animator.StringToHash("isDead");
|
||||
public static int IsGrounded = Animator.StringToHash("IsGrounded");
|
||||
public static int IsCrouching = Animator.StringToHash("IsCrouching");
|
||||
public static int IsStrafing = Animator.StringToHash("IsStrafing");
|
||||
public static int IsSprinting = Animator.StringToHash("IsSprinting");
|
||||
public static int IsSliding = Animator.StringToHash("IsSliding");
|
||||
public static int GroundDistance = Animator.StringToHash("GroundDistance");
|
||||
public static int GroundAngle = Animator.StringToHash("GroundAngle");
|
||||
public static int VerticalVelocity = Animator.StringToHash("VerticalVelocity");
|
||||
public static int IdleRandom = Animator.StringToHash("IdleRandom");
|
||||
public static int IdleRandomTrigger = Animator.StringToHash("IdleRandomTrigger");
|
||||
public static int InputDirection = Animator.StringToHash("InputDirection");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b74f4ff80d113374fb65bf806f887874
|
||||
timeCreated: 1439258392
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,353 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Invector.vCharacterController
|
||||
{
|
||||
[vClassHeader("THIRD PERSON CONTROLLER", iconName = "controllerIcon")]
|
||||
public class vThirdPersonController : vThirdPersonAnimator
|
||||
{
|
||||
/// <summary>
|
||||
/// When Disabling the Controller Component we change the Capsule Collider to Fullsize to avoid sinking in the ground
|
||||
/// </summary>
|
||||
protected override void OnDisable()
|
||||
{
|
||||
base.OnDisable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Move the controller to a specific Position, you must Lock the Input first
|
||||
/// </summary>
|
||||
/// <param name="targetPosition"></param>
|
||||
public virtual void MoveToPosition(Transform targetPosition)
|
||||
{
|
||||
MoveToPosition(targetPosition.position);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Move the controller to a specific Position, you must Lock the Input first
|
||||
/// </summary>
|
||||
/// <param name="targetPosition"></param>
|
||||
public virtual void MoveToPosition(Vector3 targetPosition)
|
||||
{
|
||||
Vector3 dir = targetPosition - transform.position;
|
||||
dir.y = 0;
|
||||
/*dir = dir.normalized * Mathf.Min(1f, dir.magnitude);*/ /*That is to make smootly stop*/
|
||||
|
||||
if (dir.magnitude < 0.1f)
|
||||
{
|
||||
input = Vector3.zero;
|
||||
moveDirection = Vector3.zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
input = transform.InverseTransformDirection(dir.normalized);
|
||||
moveDirection = dir.normalized;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle RootMotion movement and specific Actions
|
||||
/// </summary>
|
||||
public virtual void ControlAnimatorRootMotion()
|
||||
{
|
||||
if (!this.enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (isRolling)
|
||||
{
|
||||
RollBehavior();
|
||||
return;
|
||||
}
|
||||
|
||||
if (customAction || lockAnimMovement)
|
||||
{
|
||||
StopCharacterWithLerp();
|
||||
transform.position = animator.rootPosition;
|
||||
transform.rotation = animator.rootRotation;
|
||||
}
|
||||
|
||||
if (useRootMotion)
|
||||
{
|
||||
MoveCharacter(moveDirection);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the Controller movement speed (rigidbody, animator and root motion)
|
||||
/// </summary>
|
||||
public virtual void ControlLocomotionType()
|
||||
{
|
||||
if (lockAnimMovement || lockMovement || customAction)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!lockSetMoveSpeed)
|
||||
{
|
||||
if (locomotionType.Equals(LocomotionType.FreeWithStrafe) && !isStrafing || locomotionType.Equals(LocomotionType.OnlyFree))
|
||||
{
|
||||
SetControllerMoveSpeed(freeSpeed);
|
||||
SetAnimatorMoveSpeed(freeSpeed);
|
||||
}
|
||||
else if (locomotionType.Equals(LocomotionType.OnlyStrafe) || locomotionType.Equals(LocomotionType.FreeWithStrafe) && isStrafing)
|
||||
{
|
||||
isStrafing = true;
|
||||
SetControllerMoveSpeed(strafeSpeed);
|
||||
SetAnimatorMoveSpeed(strafeSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
if (!useRootMotion)
|
||||
{
|
||||
MoveCharacter(moveDirection);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Manage the Control Rotation Type of the Player
|
||||
/// </summary>
|
||||
public virtual void ControlRotationType()
|
||||
{
|
||||
if (lockAnimRotation || lockRotation || customAction || isRolling)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool validInput = input != Vector3.zero || (isStrafing ? strafeSpeed.rotateWithCamera : freeSpeed.rotateWithCamera);
|
||||
|
||||
if (validInput)
|
||||
{
|
||||
if (lockAnimMovement)
|
||||
{
|
||||
// calculate input smooth
|
||||
inputSmooth = Vector3.Lerp(inputSmooth, input, (isStrafing ? strafeSpeed.movementSmooth : freeSpeed.movementSmooth) * Time.deltaTime);
|
||||
}
|
||||
Vector3 dir = (isStrafing && isGrounded && (!isSprinting || sprintOnlyFree == false) || (freeSpeed.rotateWithCamera && input == Vector3.zero)) && rotateTarget ? rotateTarget.forward : moveDirection;
|
||||
|
||||
//RotationTest(dir);
|
||||
|
||||
RotateToDirection(dir);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use it to keep the direction the Player is moving (most used with CCV camera)
|
||||
/// </summary>
|
||||
public virtual void ControlKeepDirection()
|
||||
{
|
||||
// update oldInput to compare with current Input if keepDirection is true
|
||||
if (!keepDirection)
|
||||
{
|
||||
oldInput = input;
|
||||
}
|
||||
else if ((input.magnitude < 0.01f || Vector3.Distance(oldInput, input) > 0.9f) && keepDirection)
|
||||
{
|
||||
keepDirection = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine the direction the player will face based on input and the referenceTransform
|
||||
/// </summary>
|
||||
/// <param name="referenceTransform"></param>
|
||||
public virtual void UpdateMoveDirection(Transform referenceTransform = null)
|
||||
{
|
||||
if (isRolling && !rollControl /*|| input.magnitude <= 0.01*/)
|
||||
{
|
||||
moveDirection = Vector3.Lerp(moveDirection, Vector3.zero, (isStrafing ? strafeSpeed.movementSmooth : freeSpeed.movementSmooth) * Time.deltaTime);
|
||||
return;
|
||||
}
|
||||
|
||||
if (referenceTransform && !rotateByWorld)
|
||||
{
|
||||
//get the right-facing direction of the referenceTransform
|
||||
var right = referenceTransform.right;
|
||||
right.y = 0;
|
||||
//get the forward direction relative to referenceTransform Right
|
||||
var forward = Quaternion.AngleAxis(-90, Vector3.up) * right;
|
||||
// determine the direction the player will face based on input and the referenceTransform's right and forward directions
|
||||
moveDirection = (inputSmooth.x * right) + (inputSmooth.z * forward);
|
||||
var moveDirectionRaw = (input.x * right) + (input.z * forward);
|
||||
SetInputDirection(moveDirectionRaw);
|
||||
}
|
||||
else
|
||||
{
|
||||
moveDirection = new Vector3(inputSmooth.x, 0, inputSmooth.z);
|
||||
var moveDirectionRaw = new Vector3(input.x, 0, input.z);
|
||||
SetInputDirection(moveDirectionRaw);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the isSprinting bool and manage the Sprint Behavior
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public virtual void Sprint(bool value)
|
||||
{
|
||||
var sprintConditions = (!isCrouching || (!inCrouchArea && CanExitCrouch())) && (currentStamina > 0 && hasMovementInput &&
|
||||
!(isStrafing && (horizontalSpeed >= 0.5 || horizontalSpeed <= -0.5 || verticalSpeed <= 0.1f) && !sprintOnlyFree));
|
||||
|
||||
if (value && sprintConditions)
|
||||
{
|
||||
if (currentStamina > (finishStaminaOnSprint ? sprintStamina : 0) && hasMovementInput)
|
||||
{
|
||||
finishStaminaOnSprint = false;
|
||||
if (isGrounded && useContinuousSprint)
|
||||
{
|
||||
isCrouching = false;
|
||||
isSprinting = !isSprinting;
|
||||
if (isSprinting)
|
||||
{
|
||||
OnStartSprinting.Invoke();
|
||||
alwaysWalkByDefault = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
OnFinishSprinting.Invoke();
|
||||
}
|
||||
}
|
||||
else if (!isSprinting)
|
||||
{
|
||||
OnStartSprinting.Invoke();
|
||||
|
||||
alwaysWalkByDefault = false;
|
||||
isSprinting = true;
|
||||
}
|
||||
}
|
||||
else if (!useContinuousSprint && isSprinting)
|
||||
{
|
||||
if (currentStamina <= 0)
|
||||
{
|
||||
finishStaminaOnSprint = true;
|
||||
OnFinishSprintingByStamina.Invoke();
|
||||
}
|
||||
isSprinting = false;
|
||||
OnFinishSprinting.Invoke();
|
||||
}
|
||||
}
|
||||
else if (isSprinting && (!useContinuousSprint || !sprintConditions))
|
||||
{
|
||||
if (currentStamina <= 0)
|
||||
{
|
||||
finishStaminaOnSprint = true;
|
||||
OnFinishSprintingByStamina.Invoke();
|
||||
}
|
||||
|
||||
isSprinting = false;
|
||||
OnFinishSprinting.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Manage the isCrouching bool
|
||||
/// </summary>
|
||||
public virtual void Crouch()
|
||||
{
|
||||
if (isGrounded && !customAction)
|
||||
{
|
||||
AutoCrouch();
|
||||
if (isCrouching && CanExitCrouch())
|
||||
{
|
||||
isCrouching = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
isCrouching = true;
|
||||
isSprinting = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the isStrafing bool
|
||||
/// </summary>
|
||||
public virtual void Strafe()
|
||||
{
|
||||
isStrafing = !isStrafing;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Triggers the Jump Animation and set the necessary variables to make the Jump behavior in the <seealso cref="vThirdPersonMotor"/>
|
||||
/// </summary>
|
||||
/// <param name="consumeStamina">Option to consume or not the stamina</param>
|
||||
public virtual void Jump(bool consumeStamina = false)
|
||||
{
|
||||
// trigger jump behaviour
|
||||
jumpCounter = jumpTimer;
|
||||
OnJump.Invoke();
|
||||
|
||||
// trigger jump animations
|
||||
if (input.sqrMagnitude < 0.1f)
|
||||
{
|
||||
StartCoroutine(DelayToJump());
|
||||
animator.CrossFadeInFixedTime("Jump", 0.1f);
|
||||
}
|
||||
else
|
||||
{
|
||||
isJumping = true;
|
||||
animator.CrossFadeInFixedTime("JumpMove", .2f);
|
||||
}
|
||||
|
||||
// reduce stamina
|
||||
if (consumeStamina)
|
||||
{
|
||||
ReduceStamina(jumpStamina, false);
|
||||
currentStaminaRecoveryDelay = 1f;
|
||||
}
|
||||
}
|
||||
|
||||
protected IEnumerator DelayToJump()
|
||||
{
|
||||
inJumpStarted = true;
|
||||
yield return new WaitForSeconds(jumpStandingDelay);
|
||||
isJumping = true;
|
||||
inJumpStarted = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Triggers the Roll Animation and set the stamina cost for this action
|
||||
/// </summary>
|
||||
public virtual void Roll()
|
||||
{
|
||||
OnRoll.Invoke();
|
||||
isRolling = true;
|
||||
animator.CrossFadeInFixedTime("Roll", rollTransition, baseLayer);
|
||||
ReduceStamina(rollStamina, false);
|
||||
currentStaminaRecoveryDelay = 2f;
|
||||
}
|
||||
|
||||
|
||||
#region Check Action Triggers
|
||||
|
||||
/// <summary>
|
||||
/// Call this in OnTriggerEnter or OnTriggerStay to check if enter in triggerActions
|
||||
/// </summary>
|
||||
/// <param name="other">collider trigger</param>
|
||||
protected override void OnTriggerStay(Collider other)
|
||||
{
|
||||
try
|
||||
{
|
||||
CheckForAutoCrouch(other);
|
||||
}
|
||||
catch (UnityException e)
|
||||
{
|
||||
Debug.LogWarning(e.Message);
|
||||
}
|
||||
base.OnTriggerStay(other);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call this in OnTriggerExit to check if exit of triggerActions
|
||||
/// </summary>
|
||||
/// <param name="other"></param>
|
||||
protected override void OnTriggerExit(Collider other)
|
||||
{
|
||||
AutoCrouchExit(other);
|
||||
base.OnTriggerExit(other);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 73fbf3aa05f6be24780438449f505aa3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- idleMaterial: {fileID: 13400000, guid: 7fd155be5691cd24797fd888e1cea4aa, type: 2}
|
||||
- movingMaterial: {fileID: 13400000, guid: ecda60bb52da5dd4cb42ae4f4962d24b, type: 2}
|
||||
- airborneMaterial: {fileID: 13400000, guid: 25d92df314f63cc4a98dfbd6ab725b6c, type: 2}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,754 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace Invector.vCharacterController
|
||||
{
|
||||
[vClassHeader("Input Manager", iconName = "inputIcon")]
|
||||
public class vThirdPersonInput : vMonoBehaviour, vIAnimatorMoveReceiver
|
||||
{
|
||||
public delegate void OnUpdateEvent();
|
||||
public event OnUpdateEvent onUpdate;
|
||||
public event OnUpdateEvent onLateUpdate;
|
||||
public event OnUpdateEvent onFixedUpdate;
|
||||
public event OnUpdateEvent onAnimatorMove;
|
||||
|
||||
#region Variables
|
||||
|
||||
[vEditorToolbar("Inputs")]
|
||||
[vHelpBox("Check these options if you need to use the mouse cursor, ex: <b>2.5D, Topdown or Mobile</b>", vHelpBoxAttribute.MessageType.Info)]
|
||||
public bool unlockCursorOnStart = false;
|
||||
public bool showCursorOnStart = false;
|
||||
[vHelpBox("PC only - use it to toggle between run/walk", vHelpBoxAttribute.MessageType.Info)]
|
||||
public KeyCode toggleWalk = KeyCode.CapsLock;
|
||||
|
||||
[Header("Movement Input")]
|
||||
public GenericInput horizontalInput = new GenericInput("Horizontal", "LeftAnalogHorizontal", "Horizontal");
|
||||
public GenericInput verticalInput = new GenericInput("Vertical", "LeftAnalogVertical", "Vertical");
|
||||
public GenericInput sprintInput = new GenericInput("LeftShift", "LeftStickClick", "LeftStickClick");
|
||||
public GenericInput crouchInput = new GenericInput("C", "Y", "Y");
|
||||
public GenericInput strafeInput = new GenericInput("Tab", "RightStickClick", "RightStickClick");
|
||||
public GenericInput jumpInput = new GenericInput("Space", "X", "X");
|
||||
public GenericInput rollInput = new GenericInput("Q", "B", "B");
|
||||
|
||||
protected bool _lockInput = false;
|
||||
[HideInInspector] public virtual bool lockInput { get { return _lockInput; } set { _lockInput = value; } }
|
||||
|
||||
[vEditorToolbar("Camera Settings")]
|
||||
public bool lockCameraInput;
|
||||
public bool invertCameraInputVertical, invertCameraInputHorizontal;
|
||||
[vEditorToolbar("Inputs")]
|
||||
[Header("Camera Input")]
|
||||
public GenericInput rotateCameraXInput = new GenericInput("Mouse X", "RightAnalogHorizontal", "Mouse X");
|
||||
public GenericInput rotateCameraYInput = new GenericInput("Mouse Y", "RightAnalogVertical", "Mouse Y");
|
||||
public GenericInput cameraZoomInput = new GenericInput("Mouse ScrollWheel", "", "");
|
||||
|
||||
[vEditorToolbar("Events")]
|
||||
public UnityEvent OnLockCamera;
|
||||
public UnityEvent OnUnlockCamera;
|
||||
public UnityEvent onEnableAnimatorMove = new UnityEvent();
|
||||
public UnityEvent onDisableDisableAnimatorMove = new UnityEvent();
|
||||
|
||||
[HideInInspector]
|
||||
public vCamera.vThirdPersonCamera tpCamera; // access tpCamera info
|
||||
[HideInInspector]
|
||||
public bool ignoreTpCamera; // controls whether update the cameraStates of not
|
||||
[HideInInspector]
|
||||
public string customCameraState; // generic string to change the CameraState
|
||||
[HideInInspector]
|
||||
public string customlookAtPoint; // generic string to change the CameraPoint of the Fixed Point Mode
|
||||
[HideInInspector]
|
||||
public bool changeCameraState; // generic bool to change the CameraState
|
||||
[HideInInspector]
|
||||
public bool smoothCameraState; // generic bool to know if the state will change with or without lerp
|
||||
[HideInInspector]
|
||||
public vThirdPersonController cc; // access the ThirdPersonController component
|
||||
[HideInInspector]
|
||||
public vHUDController hud; // access vHUDController component
|
||||
protected bool updateIK = false;
|
||||
protected bool isInit;
|
||||
[HideInInspector] public bool lockMoveInput;
|
||||
protected InputDevice inputDevice { get { return vInput.instance.inputDevice; } }
|
||||
|
||||
protected Camera _cameraMain;
|
||||
protected bool withoutMainCamera;
|
||||
public virtual bool lockUpdateMoveDirection { get; set; } // lock the method UpdateMoveDirection
|
||||
|
||||
public virtual Camera cameraMain
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_cameraMain && !withoutMainCamera)
|
||||
{
|
||||
if (!Camera.main)
|
||||
{
|
||||
Debug.Log("Missing a Camera with the tag MainCamera, please add one.");
|
||||
withoutMainCamera = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_cameraMain = Camera.main;
|
||||
cc.rotateTarget = _cameraMain.transform;
|
||||
}
|
||||
}
|
||||
return _cameraMain;
|
||||
}
|
||||
set
|
||||
{
|
||||
_cameraMain = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Animator animator
|
||||
{
|
||||
get
|
||||
{
|
||||
if (cc == null)
|
||||
{
|
||||
cc = GetComponent<vThirdPersonController>();
|
||||
}
|
||||
|
||||
if (cc.animator == null)
|
||||
{
|
||||
return GetComponent<Animator>();
|
||||
}
|
||||
|
||||
return cc.animator;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Initialize Character, Camera & HUD when LoadScene
|
||||
|
||||
protected virtual void Start()
|
||||
{
|
||||
cc = GetComponent<vThirdPersonController>();
|
||||
|
||||
if (cc != null)
|
||||
{
|
||||
cc.Init();
|
||||
}
|
||||
|
||||
cc.onDead.AddListener((GameObject _gameObject) => { cc.ResetInputAnimatorParameters(); SetLockAllInput(true); cc.StopCharacter(); });
|
||||
StartCoroutine(CharacterInit());
|
||||
|
||||
ShowCursor(showCursorOnStart);
|
||||
LockCursor(unlockCursorOnStart);
|
||||
EnableOnAnimatorMove();
|
||||
}
|
||||
|
||||
protected virtual IEnumerator CharacterInit()
|
||||
{
|
||||
FindCamera();
|
||||
yield return new WaitForEndOfFrame();
|
||||
FindHUD();
|
||||
}
|
||||
|
||||
public virtual void FindHUD()
|
||||
{
|
||||
if (hud == null && vHUDController.instance != null)
|
||||
{
|
||||
hud = vHUDController.instance;
|
||||
hud.Init(cc);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void FindCamera()
|
||||
{
|
||||
var tpCameras = FindObjectsOfType<vCamera.vThirdPersonCamera>();
|
||||
|
||||
if (tpCameras.Length > 1)
|
||||
{
|
||||
tpCamera = System.Array.Find(tpCameras, tp => !tp.isInit);
|
||||
|
||||
if (tpCamera == null)
|
||||
{
|
||||
tpCamera = tpCameras[0];
|
||||
}
|
||||
|
||||
if (tpCamera != null)
|
||||
{
|
||||
for (int i = 0; i < tpCameras.Length; i++)
|
||||
{
|
||||
if (tpCamera != tpCameras[i])
|
||||
{
|
||||
Destroy(tpCameras[i].gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (tpCameras.Length == 1)
|
||||
{
|
||||
tpCamera = tpCameras[0];
|
||||
}
|
||||
|
||||
if (tpCamera && tpCamera.mainTarget != transform)
|
||||
{
|
||||
tpCamera.SetMainTarget(this.transform);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected virtual void LateUpdate()
|
||||
{
|
||||
if (cc == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!updateIK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (onLateUpdate != null)
|
||||
{
|
||||
onLateUpdate.Invoke();
|
||||
}
|
||||
|
||||
CameraInput(); // update camera input
|
||||
UpdateCameraStates(); // update camera states
|
||||
updateIK = false;
|
||||
}
|
||||
|
||||
protected virtual void FixedUpdate()
|
||||
{
|
||||
if (onFixedUpdate != null)
|
||||
{
|
||||
onFixedUpdate.Invoke();
|
||||
}
|
||||
|
||||
Physics.SyncTransforms();
|
||||
cc.UpdateMotor(); // handle the ThirdPersonMotor methods
|
||||
cc.ControlLocomotionType(); // handle the controller locomotion type and movespeed
|
||||
ControlRotation();
|
||||
cc.UpdateAnimator(); // handle the ThirdPersonAnimator methods
|
||||
updateIK = true;
|
||||
}
|
||||
|
||||
protected virtual void Update()
|
||||
{
|
||||
if (cc == null || Time.timeScale == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (onUpdate != null)
|
||||
{
|
||||
onUpdate.Invoke();
|
||||
}
|
||||
|
||||
InputHandle(); // update input methods
|
||||
UpdateHUD(); // update hud graphics
|
||||
}
|
||||
|
||||
public virtual void OnAnimatorMoveEvent()
|
||||
{
|
||||
if (cc == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cc.ControlAnimatorRootMotion();
|
||||
if (onAnimatorMove != null)
|
||||
{
|
||||
onAnimatorMove.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
#region Generic Methods
|
||||
// you can call this methods anywhere in the inspector or third party assets to have better control of the controller or cutscenes
|
||||
|
||||
/// <summary>
|
||||
/// Lock all Basic Input from the Player
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public virtual void SetLockBasicInput(bool value)
|
||||
{
|
||||
lockInput = value;
|
||||
if (value)
|
||||
{
|
||||
//cc.input = Vector2.zero;
|
||||
//cc.isSprinting = false;
|
||||
//cc.animator.SetFloat("InputHorizontal", 0, 0.25f, Time.deltaTime);
|
||||
//cc.animator.SetFloat("InputVertical", 0, 0.25f, Time.deltaTime);
|
||||
//cc.animator.SetFloat("InputMagnitude", 0, 0.25f, Time.deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lock all Inputs
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public virtual void SetLockAllInput(bool value)
|
||||
{
|
||||
SetLockBasicInput(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show/Hide Cursor
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public virtual void ShowCursor(bool value)
|
||||
{
|
||||
Cursor.visible = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lock/Unlock the cursor to the center of screen
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public virtual void LockCursor(bool value)
|
||||
{
|
||||
if (!value)
|
||||
{
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
}
|
||||
else
|
||||
{
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lock the Camera Input
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public virtual void SetLockCameraInput(bool value)
|
||||
{
|
||||
lockCameraInput = value;
|
||||
|
||||
if (lockCameraInput)
|
||||
{
|
||||
OnLockCamera.Invoke();
|
||||
}
|
||||
else
|
||||
{
|
||||
OnUnlockCamera.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If you're using the MoveCharacter method with a custom targetDirection, check this true to align the character with your custom targetDirection
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public virtual void SetLockUpdateMoveDirection(bool value)
|
||||
{
|
||||
lockUpdateMoveDirection = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Limits the character to walk only, useful for cutscenes and 'indoor' areas
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public virtual void SetWalkByDefault(bool value)
|
||||
{
|
||||
cc.freeSpeed.walkByDefault = value;
|
||||
cc.strafeSpeed.walkByDefault = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reset the character to the default walk settings
|
||||
/// </summary>
|
||||
public virtual void ResetWalkByDefault()
|
||||
{
|
||||
cc.freeSpeed.walkByDefault = cc.freeSpeed.defaultWalkByDefault;
|
||||
cc.strafeSpeed.walkByDefault = cc.strafeSpeed.defaultWalkByDefault;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the character to Strafe Locomotion
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public virtual void SetStrafeLocomotion(bool value)
|
||||
{
|
||||
cc.lockInStrafe = value;
|
||||
cc.isStrafing = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// OnAnimatorMove Event Sender
|
||||
/// </summary>
|
||||
public virtual vAnimatorMoveSender animatorMoveSender { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Use Animator Move Event Sender <seealso cref="vAnimatorMoveSender"/>
|
||||
/// </summary>
|
||||
protected bool _useAnimatorMove { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Check if OnAnimatorMove is Enabled
|
||||
/// </summary>
|
||||
public virtual bool UseAnimatorMove
|
||||
{
|
||||
get
|
||||
{
|
||||
return _useAnimatorMove;
|
||||
}
|
||||
set
|
||||
{
|
||||
|
||||
if (_useAnimatorMove != value)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
animatorMoveSender = gameObject.AddComponent<vAnimatorMoveSender>();
|
||||
onEnableAnimatorMove?.Invoke();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (animatorMoveSender)
|
||||
{
|
||||
Destroy(animatorMoveSender);
|
||||
}
|
||||
|
||||
onEnableAnimatorMove?.Invoke();
|
||||
}
|
||||
}
|
||||
_useAnimatorMove = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable OnAnimatorMove event
|
||||
/// </summary>
|
||||
public virtual void EnableOnAnimatorMove()
|
||||
{
|
||||
UseAnimatorMove = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disable OnAnimatorMove event
|
||||
/// </summary>
|
||||
public virtual void DisableOnAnimatorMove()
|
||||
{
|
||||
UseAnimatorMove = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Basic Locomotion Inputs
|
||||
|
||||
public virtual void InputHandle()
|
||||
{
|
||||
if (lockInput || cc.ragdolled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MoveInput();
|
||||
SprintInput();
|
||||
CrouchInput();
|
||||
StrafeInput();
|
||||
JumpInput();
|
||||
RollInput();
|
||||
}
|
||||
|
||||
public virtual void MoveInput()
|
||||
{
|
||||
if (!lockMoveInput)
|
||||
{
|
||||
// gets input
|
||||
var input = cc.input;
|
||||
input.x = horizontalInput.GetAxisRaw();
|
||||
input.z = verticalInput.GetAxisRaw();
|
||||
cc.input = input;
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(toggleWalk))
|
||||
{
|
||||
cc.alwaysWalkByDefault = !cc.alwaysWalkByDefault;
|
||||
}
|
||||
|
||||
cc.ControlKeepDirection();
|
||||
}
|
||||
|
||||
public virtual bool rotateToLockTargetConditions => tpCamera && tpCamera.lockTarget && cc.isStrafing && !cc.isRolling && !cc.isJumping && !cc.customAction;
|
||||
public virtual void ControlRotation()
|
||||
{
|
||||
if (cameraMain && !lockUpdateMoveDirection)
|
||||
{
|
||||
if (!cc.keepDirection)
|
||||
{
|
||||
cc.UpdateMoveDirection(cameraMain.transform);
|
||||
}
|
||||
}
|
||||
|
||||
if (rotateToLockTargetConditions)
|
||||
{
|
||||
cc.RotateToPosition(tpCamera.lockTarget.position); // rotate the character to a specific target
|
||||
}
|
||||
else
|
||||
{
|
||||
cc.ControlRotationType(); // handle the controller rotation type (strafe or free)
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void StrafeInput()
|
||||
{
|
||||
if (strafeInput.GetButtonDown())
|
||||
{
|
||||
cc.Strafe();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void SprintInput()
|
||||
{
|
||||
if (sprintInput.useInput)
|
||||
{
|
||||
cc.Sprint(cc.useContinuousSprint ? sprintInput.GetButtonDown() : sprintInput.GetButton());
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void CrouchInput()
|
||||
{
|
||||
cc.AutoCrouch();
|
||||
|
||||
if (crouchInput.useInput && crouchInput.GetButtonDown())
|
||||
{
|
||||
cc.Crouch();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Conditions to trigger the Jump animation & behavior
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual bool JumpConditions()
|
||||
{
|
||||
return !cc.inJumpStarted && !cc.customAction && !cc.isCrouching && cc.isGrounded && !((int)cc.GroundAngle() > cc.slopeLimit) && cc.currentStamina >= cc.jumpStamina && !cc.isJumping && !cc.isRolling;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Input to trigger the Jump
|
||||
/// </summary>
|
||||
public virtual void JumpInput()
|
||||
{
|
||||
if (jumpInput.GetButtonDown() && JumpConditions())
|
||||
{
|
||||
cc.Jump(true);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Conditions to trigger the Roll animation & behavior
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual bool RollConditions()
|
||||
{
|
||||
return (!cc.isRolling || cc.canRollAgain) && cc.isGrounded && cc.input != Vector3.zero && !cc.customAction && cc.currentStamina > cc.rollStamina && !cc.isJumping && !cc.isSliding;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Input to trigger the Roll
|
||||
/// </summary>
|
||||
public virtual void RollInput()
|
||||
{
|
||||
if (rollInput.GetButtonDown() && RollConditions())
|
||||
{
|
||||
cc.Roll();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Camera Methods
|
||||
|
||||
public virtual void CameraInput()
|
||||
{
|
||||
if (!cameraMain)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (tpCamera == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var Y = lockCameraInput ? 0f : rotateCameraYInput.GetAxis();
|
||||
var X = lockCameraInput ? 0f : rotateCameraXInput.GetAxis();
|
||||
if (invertCameraInputHorizontal)
|
||||
{
|
||||
X *= -1;
|
||||
}
|
||||
|
||||
if (invertCameraInputVertical)
|
||||
{
|
||||
Y *= -1;
|
||||
}
|
||||
|
||||
var zoom = cameraZoomInput.GetAxis();
|
||||
|
||||
tpCamera.RotateCamera(X, Y);
|
||||
if (!lockCameraInput)
|
||||
{
|
||||
tpCamera.Zoom(zoom);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void UpdateCameraStates()
|
||||
{
|
||||
// CAMERA STATE - you can change the CameraState here, the bool means if you want lerp of not, make sure to use the same CameraState String that you named on TPCameraListData
|
||||
if (ignoreTpCamera)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (tpCamera == null)
|
||||
{
|
||||
tpCamera = FindObjectOfType<vCamera.vThirdPersonCamera>();
|
||||
if (tpCamera == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (tpCamera)
|
||||
{
|
||||
tpCamera.SetMainTarget(this.transform);
|
||||
tpCamera.Init();
|
||||
}
|
||||
}
|
||||
|
||||
if (changeCameraState)
|
||||
{
|
||||
tpCamera.ChangeState(customCameraState, customlookAtPoint, smoothCameraState);
|
||||
}
|
||||
else if (cc.isCrouching)
|
||||
{
|
||||
tpCamera.ChangeState("Crouch", true);
|
||||
}
|
||||
else if (cc.isStrafing)
|
||||
{
|
||||
tpCamera.ChangeState("Strafing", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
tpCamera.ChangeState("Default", true);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void ChangeCameraState(string cameraState, bool useLerp = true)
|
||||
{
|
||||
if (useLerp)
|
||||
{
|
||||
ChangeCameraStateWithLerp(cameraState);
|
||||
}
|
||||
else
|
||||
{
|
||||
ChangeCameraStateNoLerp(cameraState);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void ResetCameraAngleSmooth()
|
||||
{
|
||||
if (tpCamera)
|
||||
{
|
||||
tpCamera.ResetAngle();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void ResetCameraAngleWithoutSmooth()
|
||||
{
|
||||
if (tpCamera)
|
||||
{
|
||||
tpCamera.ResetAngleWithoutSmooth();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void ChangeCameraStateWithLerp(string cameraState)
|
||||
{
|
||||
changeCameraState = true;
|
||||
customCameraState = cameraState;
|
||||
smoothCameraState = true;
|
||||
}
|
||||
|
||||
public virtual void ChangeCameraStateNoLerp(string cameraState)
|
||||
{
|
||||
changeCameraState = true;
|
||||
customCameraState = cameraState;
|
||||
smoothCameraState = false;
|
||||
}
|
||||
|
||||
public virtual void ResetCameraState()
|
||||
{
|
||||
changeCameraState = false;
|
||||
customCameraState = string.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region HUD
|
||||
|
||||
public virtual void UpdateHUD()
|
||||
{
|
||||
if (hud == null)
|
||||
{
|
||||
if (vHUDController.instance != null)
|
||||
{
|
||||
hud = vHUDController.instance;
|
||||
hud.Init(cc);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
hud.UpdateHUD(cc);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Interface to receive events from <seealso cref="vAnimatorMoveSender"/>
|
||||
/// </summary>
|
||||
public interface vIAnimatorMoveReceiver
|
||||
{
|
||||
/// <summary>
|
||||
/// Check if Component is Enabled
|
||||
/// </summary>
|
||||
bool enabled { get; set; }
|
||||
/// <summary>
|
||||
/// Method Called from <seealso cref="vAnimatorMoveSender"/>
|
||||
/// </summary>
|
||||
void OnAnimatorMoveEvent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// OnAnimatorMove Event Sender
|
||||
/// </summary>
|
||||
public class vAnimatorMoveSender : MonoBehaviour
|
||||
{
|
||||
protected virtual void Awake()
|
||||
{
|
||||
///Hide in Inpector
|
||||
this.hideFlags = HideFlags.HideInInspector;
|
||||
vIAnimatorMoveReceiver[] animatorMoves = GetComponents<vIAnimatorMoveReceiver>();
|
||||
for (int i = 0; i < animatorMoves.Length; i++)
|
||||
{
|
||||
var receiver = animatorMoves[i];
|
||||
animatorMoveEvent += () =>
|
||||
{
|
||||
if (receiver.enabled)
|
||||
{
|
||||
receiver.OnAnimatorMoveEvent();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// AnimatorMove event called using default unity OnAnimatorMove
|
||||
/// </summary>
|
||||
public System.Action animatorMoveEvent;
|
||||
|
||||
protected virtual void OnAnimatorMove()
|
||||
{
|
||||
animatorMoveEvent?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5deb9ff5611cb9d4596d397ac57ee8c7
|
||||
timeCreated: 1469642972
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 11faa0ff55786fa4588b84ab450ec41b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- idleMaterial: {fileID: 13400000, guid: 7fd155be5691cd24797fd888e1cea4aa, type: 2}
|
||||
- movingMaterial: {fileID: 13400000, guid: ecda60bb52da5dd4cb42ae4f4962d24b, type: 2}
|
||||
- airborneMaterial: {fileID: 13400000, guid: 25d92df314f63cc4a98dfbd6ab725b6c, type: 2}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4d7570a9a8501334e8bb4847e0209711
|
||||
folderAsset: yes
|
||||
timeCreated: 1438045379
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df007b377a2cd274bbfba12dd4f131b2
|
||||
folderAsset: yes
|
||||
timeCreated: 1445804257
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,178 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 7592ac57a97621844bb7d05b6822c040, type: 3}
|
||||
m_Name: vBasicLocomotiont@CameraState
|
||||
m_EditorClassIdentifier:
|
||||
Name:
|
||||
tpCameraStates:
|
||||
- Name: Default
|
||||
forward: -1
|
||||
right: 0
|
||||
defaultDistance: 2.5
|
||||
maxDistance: 80
|
||||
minDistance: 0.6
|
||||
height: 1.25
|
||||
smooth: 10
|
||||
smoothDamp: 2
|
||||
xMouseSensitivity: 3
|
||||
yMouseSensitivity: 3
|
||||
yMinLimit: -75
|
||||
yMaxLimit: 75
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 0.84, y: 0.99, z: 0}
|
||||
cullingHeight: 1.8
|
||||
cullingMinDist: 0.01
|
||||
fov: 60
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 360, y: 78}
|
||||
lookPoints:
|
||||
- pointName: point_01
|
||||
positionPoint: {x: 0, y: 1, z: -10}
|
||||
eulerAngle: {x: -0, y: 0, z: 0}
|
||||
freeRotation: 0
|
||||
cameraMode: 0
|
||||
- Name: Sprinting
|
||||
forward: -1
|
||||
right: 0
|
||||
defaultDistance: 2.5
|
||||
maxDistance: 80
|
||||
minDistance: 0.6
|
||||
height: 1.25
|
||||
smooth: 10
|
||||
smoothDamp: 2
|
||||
xMouseSensitivity: 3
|
||||
yMouseSensitivity: 3
|
||||
yMinLimit: -75
|
||||
yMaxLimit: 75
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 0.84, y: 0.99, z: 0}
|
||||
cullingHeight: 1.8
|
||||
cullingMinDist: 0.01
|
||||
fov: 70
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 360, y: 78}
|
||||
lookPoints:
|
||||
- pointName: point_01
|
||||
positionPoint: {x: 0, y: 1, z: -10}
|
||||
eulerAngle: {x: -0, y: 0, z: 0}
|
||||
freeRotation: 0
|
||||
cameraMode: 0
|
||||
- Name: Crouch
|
||||
forward: -1
|
||||
right: 0.15
|
||||
defaultDistance: 2
|
||||
maxDistance: 6.55
|
||||
minDistance: 0.5
|
||||
height: 1
|
||||
smooth: 10
|
||||
smoothDamp: 4
|
||||
xMouseSensitivity: 3
|
||||
yMouseSensitivity: 3
|
||||
yMinLimit: -40
|
||||
yMaxLimit: 70
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 0, y: 0, z: 0}
|
||||
cullingHeight: 0.7
|
||||
cullingMinDist: 0.1
|
||||
fov: 60
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 0, y: 0}
|
||||
lookPoints: []
|
||||
cameraMode: 0
|
||||
- Name: Strafing
|
||||
forward: -1
|
||||
right: 0
|
||||
defaultDistance: 2.5
|
||||
maxDistance: 1.5
|
||||
minDistance: 0.25
|
||||
height: 1.6
|
||||
smooth: 10
|
||||
smoothDamp: 4
|
||||
xMouseSensitivity: 3
|
||||
yMouseSensitivity: 3
|
||||
yMinLimit: -40
|
||||
yMaxLimit: 80
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 5, y: 0, z: 0}
|
||||
cullingHeight: 1.5
|
||||
cullingMinDist: 0.1
|
||||
fov: 50
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 0, y: 0}
|
||||
lookPoints: []
|
||||
cameraMode: 0
|
||||
- Name: Pendulum
|
||||
forward: -1
|
||||
right: 0.28
|
||||
defaultDistance: 12
|
||||
maxDistance: 3
|
||||
minDistance: 0.5
|
||||
height: 1.8
|
||||
smooth: 10
|
||||
smoothDamp: 4
|
||||
xMouseSensitivity: 0
|
||||
yMouseSensitivity: 0
|
||||
yMinLimit: -40
|
||||
yMaxLimit: 80
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 0, y: 0, z: 0}
|
||||
cullingHeight: 1
|
||||
cullingMinDist: 0.1
|
||||
fov: 55
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 0, y: 0}
|
||||
lookPoints:
|
||||
- pointName: point_01
|
||||
positionPoint: {x: 26.55739, y: 11.5149355, z: -14.382481}
|
||||
eulerAngle: {x: 18.395489, y: 3.074889, z: 0.00039735218}
|
||||
freeRotation: 1
|
||||
cameraMode: 2
|
||||
- Name: Sliding
|
||||
forward: -1
|
||||
right: 0
|
||||
defaultDistance: 1
|
||||
maxDistance: 3
|
||||
minDistance: 0.5
|
||||
height: 0.5
|
||||
smooth: 10
|
||||
smoothDamp: 10
|
||||
xMouseSensitivity: 1
|
||||
yMouseSensitivity: 1
|
||||
yMinLimit: -10
|
||||
yMaxLimit: 20
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 0, y: 0, z: 0}
|
||||
cullingHeight: 0.2
|
||||
cullingMinDist: 0.1
|
||||
fov: 60
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 0, y: 0}
|
||||
lookPoints:
|
||||
- pointName: point_01
|
||||
positionPoint: {x: 26.55739, y: 11.5149355, z: -14.382481}
|
||||
eulerAngle: {x: 18.395489, y: 3.0748892, z: 0.00039735215}
|
||||
freeRotation: 0
|
||||
- pointName: point_02
|
||||
positionPoint: {x: 29.395, y: 0.709, z: 2.2409992}
|
||||
eulerAngle: {x: 357.80994, y: 88.88348, z: 359.81253}
|
||||
freeRotation: 0
|
||||
- pointName: point_03
|
||||
positionPoint: {x: 37.249695, y: 0.97621524, z: 2.2345524}
|
||||
eulerAngle: {x: 2.0625482, y: 271.75256, z: -0.00016467154}
|
||||
freeRotation: 0
|
||||
cameraMode: 2
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbf2c7a931be7ae4d960bc178dc4dda6
|
||||
timeCreated: 1488647899
|
||||
licenseType: Store
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,143 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 7592ac57a97621844bb7d05b6822c040, type: 3}
|
||||
m_Name: vFastShooter@CameraState
|
||||
m_EditorClassIdentifier:
|
||||
Name:
|
||||
tpCameraStates:
|
||||
- Name: Default
|
||||
forward: -1
|
||||
right: 0.25
|
||||
defaultDistance: 2
|
||||
maxDistance: 8
|
||||
minDistance: 0.6
|
||||
height: 1.5
|
||||
smooth: 10
|
||||
smoothDamp: 0
|
||||
xMouseSensitivity: 3
|
||||
yMouseSensitivity: 3
|
||||
yMinLimit: -39.999996
|
||||
yMaxLimit: 80
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 0, y: 0, z: 0}
|
||||
cullingHeight: 1.5
|
||||
cullingMinDist: 0.01
|
||||
fov: 60
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 360, y: 78}
|
||||
lookPoints:
|
||||
- pointName: point_01
|
||||
positionPoint: {x: 0, y: 1, z: -10}
|
||||
eulerAngle: {x: -0, y: 0, z: 0}
|
||||
freeRotation: 0
|
||||
cameraMode: 0
|
||||
- Name: Crouch
|
||||
forward: -1
|
||||
right: 0.4
|
||||
defaultDistance: 1.5
|
||||
maxDistance: 6.55
|
||||
minDistance: 0.5
|
||||
height: 1.3
|
||||
smooth: 10
|
||||
smoothDamp: 0
|
||||
xMouseSensitivity: 3
|
||||
yMouseSensitivity: 3
|
||||
yMinLimit: -40
|
||||
yMaxLimit: 70
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 0, y: 0, z: 0}
|
||||
cullingHeight: 0.7
|
||||
cullingMinDist: 0.1
|
||||
fov: 40
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 0, y: 0}
|
||||
lookPoints: []
|
||||
cameraMode: 0
|
||||
- Name: Strafing
|
||||
forward: -1
|
||||
right: 0.25
|
||||
defaultDistance: 2
|
||||
maxDistance: 1.5
|
||||
minDistance: 0.25
|
||||
height: 1.5
|
||||
smooth: 10
|
||||
smoothDamp: 0
|
||||
xMouseSensitivity: 2.5
|
||||
yMouseSensitivity: 2.5
|
||||
yMinLimit: -40
|
||||
yMaxLimit: 80
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 0, y: 0, z: 0}
|
||||
cullingHeight: 1.5
|
||||
cullingMinDist: 0.1
|
||||
fov: 60
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 0, y: 0}
|
||||
lookPoints: []
|
||||
cameraMode: 0
|
||||
- Name: Aiming
|
||||
forward: -1
|
||||
right: 0.4
|
||||
defaultDistance: 2
|
||||
maxDistance: 3
|
||||
minDistance: 0.5
|
||||
height: 1.5
|
||||
smooth: 10
|
||||
smoothDamp: 1
|
||||
xMouseSensitivity: 2
|
||||
yMouseSensitivity: 2
|
||||
yMinLimit: -40
|
||||
yMaxLimit: 80
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 0, y: 0, z: 0}
|
||||
cullingHeight: 1
|
||||
cullingMinDist: 0.1
|
||||
fov: 60
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 0, y: 15}
|
||||
lookPoints:
|
||||
- pointName: point_01
|
||||
positionPoint: {x: 27.862371, y: 8.697912, z: -13.253475}
|
||||
eulerAngle: {x: 1.2032634, y: 0.6535967, z: 0.0000026131736}
|
||||
freeRotation: 1
|
||||
cameraMode: 0
|
||||
- Name: ScopeAiming
|
||||
forward: -1
|
||||
right: 0.4
|
||||
defaultDistance: 2
|
||||
maxDistance: 3
|
||||
minDistance: 0.5
|
||||
height: 1.5
|
||||
smooth: 10
|
||||
smoothDamp: 1
|
||||
xMouseSensitivity: 0.2
|
||||
yMouseSensitivity: 0.2
|
||||
yMinLimit: -40
|
||||
yMaxLimit: 80
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 0, y: 0, z: 0}
|
||||
cullingHeight: 1
|
||||
cullingMinDist: 0.1
|
||||
fov: 60
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 0, y: 15}
|
||||
lookPoints:
|
||||
- pointName: point_01
|
||||
positionPoint: {x: 27.862371, y: 8.697912, z: -13.253475}
|
||||
eulerAngle: {x: 1.2032634, y: 0.6535967, z: 0.0000026131736}
|
||||
freeRotation: 1
|
||||
cameraMode: 0
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 08d781d2411aa4a41b60c84b60c87c98
|
||||
timeCreated: 1486916120
|
||||
licenseType: Store
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,116 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 7592ac57a97621844bb7d05b6822c040, type: 3}
|
||||
m_Name: vMeleeCombat@CameraState
|
||||
m_EditorClassIdentifier:
|
||||
Name:
|
||||
tpCameraStates:
|
||||
- Name: Default
|
||||
forward: -1
|
||||
right: 0
|
||||
defaultDistance: 2.5
|
||||
maxDistance: 8
|
||||
minDistance: 0.6
|
||||
height: 1.8
|
||||
smooth: 10
|
||||
smoothDamp: 4
|
||||
xMouseSensitivity: 3
|
||||
yMouseSensitivity: 3
|
||||
yMinLimit: -40
|
||||
yMaxLimit: 80
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 8, y: 0, z: 0}
|
||||
cullingHeight: 1.8
|
||||
cullingMinDist: 0.01
|
||||
fov: 60
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 360, y: 78}
|
||||
lookPoints:
|
||||
- pointName: point_01
|
||||
positionPoint: {x: 0, y: 1, z: -10}
|
||||
eulerAngle: {x: -0, y: 0, z: 0}
|
||||
freeRotation: 0
|
||||
cameraMode: 0
|
||||
- Name: Strafing
|
||||
forward: -1
|
||||
right: 0
|
||||
defaultDistance: 2.5
|
||||
maxDistance: 8
|
||||
minDistance: 0.6
|
||||
height: 1.8
|
||||
smooth: 10
|
||||
smoothDamp: 4
|
||||
xMouseSensitivity: 3
|
||||
yMouseSensitivity: 3
|
||||
yMinLimit: 0
|
||||
yMaxLimit: 0
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 8, y: 0, z: 0}
|
||||
cullingHeight: 1.8
|
||||
cullingMinDist: 0.01
|
||||
fov: 60
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 360, y: 78}
|
||||
lookPoints:
|
||||
- pointName: point_01
|
||||
positionPoint: {x: 0, y: 1, z: -10}
|
||||
eulerAngle: {x: -0, y: 0, z: 0}
|
||||
freeRotation: 0
|
||||
cameraMode: 0
|
||||
- Name: Crouch
|
||||
forward: -1
|
||||
right: 0.2
|
||||
defaultDistance: 1.5
|
||||
maxDistance: 6.55
|
||||
minDistance: 0.5
|
||||
height: 0.7
|
||||
smooth: 10
|
||||
smoothDamp: 4
|
||||
xMouseSensitivity: 3
|
||||
yMouseSensitivity: 3
|
||||
yMinLimit: -40
|
||||
yMaxLimit: 70
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 0, y: 0, z: 0}
|
||||
cullingHeight: 0.7
|
||||
cullingMinDist: 0.1
|
||||
fov: 40
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 0, y: 0}
|
||||
lookPoints: []
|
||||
cameraMode: 0
|
||||
- Name: _
|
||||
forward: -1
|
||||
right: 0.82
|
||||
defaultDistance: 1.35
|
||||
maxDistance: 1.5
|
||||
minDistance: 0.25
|
||||
height: 1.6
|
||||
smooth: 10
|
||||
smoothDamp: 6
|
||||
xMouseSensitivity: 1
|
||||
yMouseSensitivity: 1
|
||||
yMinLimit: -40
|
||||
yMaxLimit: 80
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 0, y: 0, z: 0}
|
||||
cullingHeight: 1.5
|
||||
cullingMinDist: 0.1
|
||||
fov: 71.1
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 0, y: 0}
|
||||
lookPoints: []
|
||||
cameraMode: 0
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 026ed2280610ee74194cd3af679c75a3
|
||||
timeCreated: 1426901672
|
||||
licenseType: Store
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,312 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 7592ac57a97621844bb7d05b6822c040, type: 3}
|
||||
m_Name: vShooterMelee@CameraState
|
||||
m_EditorClassIdentifier:
|
||||
Name:
|
||||
tpCameraStates:
|
||||
- Name: Default
|
||||
forward: -1
|
||||
right: 0.2
|
||||
defaultDistance: 1.8
|
||||
maxDistance: 12
|
||||
minDistance: 0.6
|
||||
height: 1.6
|
||||
smooth: 10
|
||||
smoothDamp: 6
|
||||
xMouseSensitivity: 3
|
||||
yMouseSensitivity: 3
|
||||
yMinLimit: -70
|
||||
yMaxLimit: 70
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 8, y: 0, z: 0}
|
||||
cullingHeight: 1.9
|
||||
cullingMinDist: 0.01
|
||||
fov: 60
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 360, y: 78}
|
||||
lookPoints:
|
||||
- pointName: point_01
|
||||
positionPoint: {x: 0, y: 1, z: -10}
|
||||
eulerAngle: {x: -0, y: 0, z: 0}
|
||||
freeRotation: 0
|
||||
cameraMode: 0
|
||||
- Name: ThrowStanding
|
||||
forward: -1
|
||||
right: 0.75
|
||||
defaultDistance: 1
|
||||
maxDistance: 12
|
||||
minDistance: 0.6
|
||||
height: 1.75
|
||||
smooth: 10
|
||||
smoothDamp: 1
|
||||
xMouseSensitivity: 3
|
||||
yMouseSensitivity: 3
|
||||
yMinLimit: -70
|
||||
yMaxLimit: 70
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 8, y: 0, z: 0}
|
||||
cullingHeight: 1.9
|
||||
cullingMinDist: 0.01
|
||||
fov: 60
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 360, y: 78}
|
||||
lookPoints:
|
||||
- pointName: point_01
|
||||
positionPoint: {x: 0, y: 1, z: -10}
|
||||
eulerAngle: {x: -0, y: 0, z: 0}
|
||||
freeRotation: 0
|
||||
cameraMode: 0
|
||||
- Name: ThrowCrouching
|
||||
forward: -1
|
||||
right: 0.4
|
||||
defaultDistance: 1.5
|
||||
maxDistance: 6.55
|
||||
minDistance: 0.5
|
||||
height: 0.8
|
||||
smooth: 10
|
||||
smoothDamp: 0
|
||||
xMouseSensitivity: 3
|
||||
yMouseSensitivity: 3
|
||||
yMinLimit: -40
|
||||
yMaxLimit: 70
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 0, y: 0, z: 0}
|
||||
cullingHeight: 1.5
|
||||
cullingMinDist: 0.1
|
||||
fov: 70
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 0, y: 0}
|
||||
lookPoints: []
|
||||
cameraMode: 0
|
||||
- Name: Crouch
|
||||
forward: -1
|
||||
right: 0.4
|
||||
defaultDistance: 1.5
|
||||
maxDistance: 6.55
|
||||
minDistance: 0.5
|
||||
height: 0.8
|
||||
smooth: 10
|
||||
smoothDamp: 0
|
||||
xMouseSensitivity: 3
|
||||
yMouseSensitivity: 3
|
||||
yMinLimit: -40
|
||||
yMaxLimit: 70
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 0, y: 0, z: 0}
|
||||
cullingHeight: 1.5
|
||||
cullingMinDist: 0.1
|
||||
fov: 70
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 0, y: 0}
|
||||
lookPoints: []
|
||||
cameraMode: 0
|
||||
- Name: Aiming
|
||||
forward: -1
|
||||
right: 0.34
|
||||
defaultDistance: 1.23
|
||||
maxDistance: 1.5
|
||||
minDistance: 0.25
|
||||
height: 1.6
|
||||
smooth: 10
|
||||
smoothDamp: 1
|
||||
xMouseSensitivity: 3
|
||||
yMouseSensitivity: 3
|
||||
yMinLimit: -50
|
||||
yMaxLimit: 70
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 0, y: 0, z: 0}
|
||||
cullingHeight: 1.5
|
||||
cullingMinDist: 0.1
|
||||
fov: 35
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 0, y: 0}
|
||||
lookPoints: []
|
||||
cameraMode: 0
|
||||
- Name: AimingScopeView
|
||||
forward: 1
|
||||
right: 0
|
||||
defaultDistance: -0.2
|
||||
maxDistance: 1.5
|
||||
minDistance: 0.25
|
||||
height: 0
|
||||
smooth: 60
|
||||
smoothDamp: 0
|
||||
xMouseSensitivity: 2
|
||||
yMouseSensitivity: 1
|
||||
yMinLimit: -50
|
||||
yMaxLimit: 70
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 0, y: 0, z: 0}
|
||||
cullingHeight: 1.5
|
||||
cullingMinDist: 0.1
|
||||
fov: 31
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 0, y: 0}
|
||||
lookPoints: []
|
||||
cameraMode: 0
|
||||
- Name: Strafing
|
||||
forward: -1
|
||||
right: 0.15
|
||||
defaultDistance: 2.8
|
||||
maxDistance: 3
|
||||
minDistance: 0.5
|
||||
height: 1.61
|
||||
smooth: 10
|
||||
smoothDamp: 1
|
||||
xMouseSensitivity: 3
|
||||
yMouseSensitivity: 3
|
||||
yMinLimit: -80
|
||||
yMaxLimit: 80
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 8, y: 0, z: 0}
|
||||
cullingHeight: 1.9
|
||||
cullingMinDist: 0.1
|
||||
fov: 50
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 0, y: 15}
|
||||
lookPoints:
|
||||
- pointName: point_01
|
||||
positionPoint: {x: 27.862371, y: 8.697912, z: -13.253475}
|
||||
eulerAngle: {x: 1.2032634, y: 0.6535967, z: 0.0000026131736}
|
||||
freeRotation: 1
|
||||
cameraMode: 0
|
||||
- Name: LockOn
|
||||
forward: -1
|
||||
right: 0.4
|
||||
defaultDistance: 1.3
|
||||
maxDistance: 3
|
||||
minDistance: 0.5
|
||||
height: 1.9
|
||||
smooth: 2
|
||||
smoothDamp: 10
|
||||
xMouseSensitivity: 2.5
|
||||
yMouseSensitivity: 2.5
|
||||
yMinLimit: -40
|
||||
yMaxLimit: 80
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 8, y: 0, z: 0}
|
||||
cullingHeight: 1.9
|
||||
cullingMinDist: 0.1
|
||||
fov: 70
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 0, y: 15}
|
||||
lookPoints:
|
||||
- pointName: point_01
|
||||
positionPoint: {x: 27.862371, y: 8.697912, z: -13.253475}
|
||||
eulerAngle: {x: 1.2032634, y: 0.6535967, z: 0.0000026131736}
|
||||
freeRotation: 1
|
||||
cameraMode: 0
|
||||
- Name: Building
|
||||
forward: -1
|
||||
right: 0
|
||||
defaultDistance: 2
|
||||
maxDistance: 3
|
||||
minDistance: 0.5
|
||||
height: 1.5
|
||||
smooth: 10
|
||||
smoothDamp: 10
|
||||
xMouseSensitivity: 3
|
||||
yMouseSensitivity: 3
|
||||
yMinLimit: -40
|
||||
yMaxLimit: 80
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 0, y: 0, z: 0}
|
||||
cullingHeight: 1
|
||||
cullingMinDist: 0.1
|
||||
fov: 70
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 0, y: 0}
|
||||
lookPoints: []
|
||||
cameraMode: 0
|
||||
- Name: CrouchingAiming
|
||||
forward: -1
|
||||
right: 0.5
|
||||
defaultDistance: 1.5
|
||||
maxDistance: 3
|
||||
minDistance: 0.5
|
||||
height: 1.2
|
||||
smooth: 10
|
||||
smoothDamp: 0
|
||||
xMouseSensitivity: 3
|
||||
yMouseSensitivity: 3
|
||||
yMinLimit: -40
|
||||
yMaxLimit: 80
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 0, y: 0, z: 0}
|
||||
cullingHeight: 0.2
|
||||
cullingMinDist: 0.1
|
||||
fov: 60
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 0, y: 0}
|
||||
lookPoints: []
|
||||
cameraMode: 0
|
||||
- Name: Parachute
|
||||
forward: -1
|
||||
right: 0
|
||||
defaultDistance: 3
|
||||
maxDistance: 3
|
||||
minDistance: 0.5
|
||||
height: 1
|
||||
smooth: 10
|
||||
smoothDamp: 6
|
||||
xMouseSensitivity: 3
|
||||
yMouseSensitivity: 3
|
||||
yMinLimit: -70
|
||||
yMaxLimit: 70
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 27.43, y: 0, z: 0}
|
||||
cullingHeight: 1.9
|
||||
cullingMinDist: 0.1
|
||||
fov: 80
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 0, y: 0}
|
||||
lookPoints: []
|
||||
cameraMode: 0
|
||||
- Name: Pendulum
|
||||
forward: 60
|
||||
right: 0
|
||||
defaultDistance: 1.5
|
||||
maxDistance: 3
|
||||
minDistance: 0.5
|
||||
height: 0
|
||||
smooth: 10
|
||||
smoothDamp: 0
|
||||
xMouseSensitivity: 3
|
||||
yMouseSensitivity: 3
|
||||
yMinLimit: -40
|
||||
yMaxLimit: 80
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 0, y: 0, z: 0}
|
||||
cullingHeight: 0.2
|
||||
cullingMinDist: 0.1
|
||||
fov: 60
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 0, y: 0}
|
||||
lookPoints:
|
||||
- pointName: point_01
|
||||
positionPoint: {x: 243.86966, y: 8.007825, z: 164.1816}
|
||||
eulerAngle: {x: 24.449335, y: 135.46579, z: 0.001277386}
|
||||
freeRotation: 1
|
||||
cameraMode: 2
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8616a8d80006bfb4d9069ea692c278da
|
||||
timeCreated: 1486632713
|
||||
licenseType: Store
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,139 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 7592ac57a97621844bb7d05b6822c040, type: 3}
|
||||
m_Name: vShooterOnly@CameraState
|
||||
m_EditorClassIdentifier:
|
||||
Name:
|
||||
tpCameraStates:
|
||||
- Name: Default
|
||||
forward: -1
|
||||
right: 0.25
|
||||
defaultDistance: 2
|
||||
maxDistance: 8
|
||||
minDistance: 0.6
|
||||
height: 1.5
|
||||
smooth: 10
|
||||
smoothDamp: 4
|
||||
xMouseSensitivity: 3
|
||||
yMouseSensitivity: 3
|
||||
yMinLimit: -39.999996
|
||||
yMaxLimit: 80
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 8, y: 0, z: 0}
|
||||
cullingHeight: 1.5
|
||||
cullingMinDist: 0.01
|
||||
fov: 60
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 360, y: 78}
|
||||
lookPoints:
|
||||
- pointName: point_01
|
||||
positionPoint: {x: 0, y: 1, z: -10}
|
||||
eulerAngle: {x: -0, y: 0, z: 0}
|
||||
freeRotation: 0
|
||||
cameraMode: 0
|
||||
- Name: Crouch
|
||||
forward: -1
|
||||
right: 0.4
|
||||
defaultDistance: 1.5
|
||||
maxDistance: 6.55
|
||||
minDistance: 0.5
|
||||
height: 1.2
|
||||
smooth: 10
|
||||
smoothDamp: 4
|
||||
xMouseSensitivity: 3
|
||||
yMouseSensitivity: 3
|
||||
yMinLimit: -40
|
||||
yMaxLimit: 70
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 0, y: 0, z: 0}
|
||||
cullingHeight: 0.7
|
||||
cullingMinDist: 0.1
|
||||
fov: 40
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 0, y: 0}
|
||||
lookPoints: []
|
||||
cameraMode: 0
|
||||
- Name: Aiming
|
||||
forward: -1
|
||||
right: 0.3
|
||||
defaultDistance: 1.5
|
||||
maxDistance: 1.5
|
||||
minDistance: 0.25
|
||||
height: 1.7
|
||||
smooth: 10
|
||||
smoothDamp: 2
|
||||
xMouseSensitivity: 1
|
||||
yMouseSensitivity: 1
|
||||
yMinLimit: -65
|
||||
yMaxLimit: 70
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 8, y: 0, z: 0}
|
||||
cullingHeight: 1.5
|
||||
cullingMinDist: 0.1
|
||||
fov: 35
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 0, y: 0}
|
||||
lookPoints: []
|
||||
cameraMode: 0
|
||||
- Name: CrouchingAiming
|
||||
forward: -1
|
||||
right: 0.35
|
||||
defaultDistance: 1.5
|
||||
maxDistance: 1.5
|
||||
minDistance: 0.25
|
||||
height: 1.5
|
||||
smooth: 10
|
||||
smoothDamp: 2
|
||||
xMouseSensitivity: 1
|
||||
yMouseSensitivity: 1
|
||||
yMinLimit: -65
|
||||
yMaxLimit: 70
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 8, y: 0, z: 0}
|
||||
cullingHeight: 1.5
|
||||
cullingMinDist: 0.1
|
||||
fov: 45
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 0, y: 0}
|
||||
lookPoints: []
|
||||
cameraMode: 0
|
||||
- Name: Strafing
|
||||
forward: -1
|
||||
right: 0.25
|
||||
defaultDistance: 1.26
|
||||
maxDistance: 3
|
||||
minDistance: 0.5
|
||||
height: 1.62
|
||||
smooth: 10
|
||||
smoothDamp: 1
|
||||
xMouseSensitivity: 2.5
|
||||
yMouseSensitivity: 2.5
|
||||
yMinLimit: -40
|
||||
yMaxLimit: 80
|
||||
xMinLimit: -360
|
||||
xMaxLimit: 360
|
||||
rotationOffSet: {x: 8, y: 0, z: 0}
|
||||
cullingHeight: 1
|
||||
cullingMinDist: 0.1
|
||||
fov: 60
|
||||
useZoom: 0
|
||||
fixedAngle: {x: 0, y: 15}
|
||||
lookPoints:
|
||||
- pointName: point_01
|
||||
positionPoint: {x: 27.862371, y: 8.697912, z: -13.253475}
|
||||
eulerAngle: {x: 1.2032634, y: 0.6535967, z: 0.0000026131736}
|
||||
freeRotation: 1
|
||||
cameraMode: 0
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user