Merge branch 'feature/look-away' into 'main'
added unseen event triggers See merge request kernel-panic/revival!92
This commit is contained in:
commit
e95005f4b9
File diff suppressed because it is too large
Load Diff
|
@ -9977,6 +9977,49 @@ Transform:
|
||||||
m_Father: {fileID: 8657027507187293339}
|
m_Father: {fileID: 8657027507187293339}
|
||||||
m_RootOrder: 10
|
m_RootOrder: 10
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &6194745904862817580
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 4120508371854579886}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 1288062ae3320c745a7e22cb010b5a18, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
_minDistance: 1
|
||||||
|
_minAngle: 100
|
||||||
|
_onUnseen:
|
||||||
|
game: {fileID: 0}
|
||||||
|
unity:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls:
|
||||||
|
- m_Target: {fileID: 4537531520206852677}
|
||||||
|
m_TargetAssemblyTypeName: UnityEngine.GameObject, UnityEngine
|
||||||
|
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: 2751226988317436797}
|
||||||
|
m_TargetAssemblyTypeName: UnityEngine.GameObject, UnityEngine
|
||||||
|
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
|
||||||
--- !u!1 &4129113587935299500
|
--- !u!1 &4129113587935299500
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -17489,6 +17532,10 @@ PrefabInstance:
|
||||||
propertyPath: m_Enabled
|
propertyPath: m_Enabled
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 2392897904615731006, guid: 539c60fd7808c9f479250b070d605c38, type: 3}
|
||||||
|
propertyPath: m_LocalPosition.x
|
||||||
|
value: 12.901
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 2459802978564044541, guid: 539c60fd7808c9f479250b070d605c38, type: 3}
|
- target: {fileID: 2459802978564044541, guid: 539c60fd7808c9f479250b070d605c38, type: 3}
|
||||||
propertyPath: m_RootOrder
|
propertyPath: m_RootOrder
|
||||||
value: 1
|
value: 1
|
||||||
|
@ -17565,6 +17612,34 @@ PrefabInstance:
|
||||||
propertyPath: m_LocalPosition.z
|
propertyPath: m_LocalPosition.z
|
||||||
value: -0.22
|
value: -0.22
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 3414209630566660394, guid: 539c60fd7808c9f479250b070d605c38, type: 3}
|
||||||
|
propertyPath: _onEnter.unity.m_PersistentCalls.m_Calls.Array.size
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 3414209630566660394, guid: 539c60fd7808c9f479250b070d605c38, type: 3}
|
||||||
|
propertyPath: _onEnter.unity.m_PersistentCalls.m_Calls.Array.data[0].m_Mode
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 3414209630566660394, guid: 539c60fd7808c9f479250b070d605c38, type: 3}
|
||||||
|
propertyPath: _onEnter.unity.m_PersistentCalls.m_Calls.Array.data[0].m_Target
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 6194745904862817580}
|
||||||
|
- target: {fileID: 3414209630566660394, guid: 539c60fd7808c9f479250b070d605c38, type: 3}
|
||||||
|
propertyPath: _onEnter.unity.m_PersistentCalls.m_Calls.Array.data[0].m_CallState
|
||||||
|
value: 2
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 3414209630566660394, guid: 539c60fd7808c9f479250b070d605c38, type: 3}
|
||||||
|
propertyPath: _onEnter.unity.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
|
||||||
|
value: Disarm
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 3414209630566660394, guid: 539c60fd7808c9f479250b070d605c38, type: 3}
|
||||||
|
propertyPath: _onEnter.unity.m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName
|
||||||
|
value: Ktyl.Util.UnseenEventTrigger, Assembly-CSharp
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 3414209630566660394, guid: 539c60fd7808c9f479250b070d605c38, type: 3}
|
||||||
|
propertyPath: _onEnter.unity.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
|
||||||
|
value: UnityEngine.Object, UnityEngine
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 3716559117116650351, guid: 539c60fd7808c9f479250b070d605c38, type: 3}
|
- target: {fileID: 3716559117116650351, guid: 539c60fd7808c9f479250b070d605c38, type: 3}
|
||||||
propertyPath: m_LocalPosition.x
|
propertyPath: m_LocalPosition.x
|
||||||
value: -23.12
|
value: -23.12
|
||||||
|
@ -17641,11 +17716,39 @@ PrefabInstance:
|
||||||
propertyPath: m_Enabled
|
propertyPath: m_Enabled
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 9087919151360837285, guid: 539c60fd7808c9f479250b070d605c38, type: 3}
|
||||||
|
propertyPath: _onEnter.unity.m_PersistentCalls.m_Calls.Array.size
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 9087919151360837285, guid: 539c60fd7808c9f479250b070d605c38, type: 3}
|
||||||
|
propertyPath: _onEnter.unity.m_PersistentCalls.m_Calls.Array.data[0].m_Mode
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 9087919151360837285, guid: 539c60fd7808c9f479250b070d605c38, type: 3}
|
||||||
|
propertyPath: _onEnter.unity.m_PersistentCalls.m_Calls.Array.data[0].m_Target
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 6194745904862817580}
|
||||||
|
- target: {fileID: 9087919151360837285, guid: 539c60fd7808c9f479250b070d605c38, type: 3}
|
||||||
|
propertyPath: _onEnter.unity.m_PersistentCalls.m_Calls.Array.data[0].m_CallState
|
||||||
|
value: 2
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 9087919151360837285, guid: 539c60fd7808c9f479250b070d605c38, type: 3}
|
||||||
|
propertyPath: _onEnter.unity.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
|
||||||
|
value: Arm
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 9087919151360837285, guid: 539c60fd7808c9f479250b070d605c38, type: 3}
|
||||||
|
propertyPath: _onEnter.unity.m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName
|
||||||
|
value: Ktyl.Util.UnseenEventTrigger, Assembly-CSharp
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 9087919151360837285, guid: 539c60fd7808c9f479250b070d605c38, type: 3}
|
||||||
|
propertyPath: _onEnter.unity.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
|
||||||
|
value: UnityEngine.Object, UnityEngine
|
||||||
|
objectReference: {fileID: 0}
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: 539c60fd7808c9f479250b070d605c38, type: 3}
|
m_SourcePrefab: {fileID: 100100000, guid: 539c60fd7808c9f479250b070d605c38, type: 3}
|
||||||
--- !u!4 &4537531520206852678 stripped
|
--- !u!1 &4120508371854579886 stripped
|
||||||
Transform:
|
GameObject:
|
||||||
m_CorrespondingSourceObject: {fileID: 2459802978564044541, guid: 539c60fd7808c9f479250b070d605c38, type: 3}
|
m_CorrespondingSourceObject: {fileID: 2734962257757404181, guid: 539c60fd7808c9f479250b070d605c38, type: 3}
|
||||||
m_PrefabInstance: {fileID: 2079102987037353147}
|
m_PrefabInstance: {fileID: 2079102987037353147}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
--- !u!1 &4537531520206852677 stripped
|
--- !u!1 &4537531520206852677 stripped
|
||||||
|
@ -17658,6 +17761,11 @@ Transform:
|
||||||
m_CorrespondingSourceObject: {fileID: 2459802978197217342, guid: 539c60fd7808c9f479250b070d605c38, type: 3}
|
m_CorrespondingSourceObject: {fileID: 2459802978197217342, guid: 539c60fd7808c9f479250b070d605c38, type: 3}
|
||||||
m_PrefabInstance: {fileID: 2079102987037353147}
|
m_PrefabInstance: {fileID: 2079102987037353147}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!4 &4537531520206852678 stripped
|
||||||
|
Transform:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 2459802978564044541, guid: 539c60fd7808c9f479250b070d605c38, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 2079102987037353147}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
--- !u!1001 &2154871241319455167
|
--- !u!1001 &2154871241319455167
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -18656,16 +18764,16 @@ Transform:
|
||||||
m_CorrespondingSourceObject: {fileID: 1461349035242361838, guid: bc071165ad2d3c14288cf13ac0ff6537, type: 3}
|
m_CorrespondingSourceObject: {fileID: 1461349035242361838, guid: bc071165ad2d3c14288cf13ac0ff6537, type: 3}
|
||||||
m_PrefabInstance: {fileID: 2586681477197472527}
|
m_PrefabInstance: {fileID: 2586681477197472527}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
--- !u!4 &1170184303236858142 stripped
|
|
||||||
Transform:
|
|
||||||
m_CorrespondingSourceObject: {fileID: 3735992582968959505, guid: bc071165ad2d3c14288cf13ac0ff6537, type: 3}
|
|
||||||
m_PrefabInstance: {fileID: 2586681477197472527}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
--- !u!4 &1170184304258922646 stripped
|
--- !u!4 &1170184304258922646 stripped
|
||||||
Transform:
|
Transform:
|
||||||
m_CorrespondingSourceObject: {fileID: 3735992581812067225, guid: bc071165ad2d3c14288cf13ac0ff6537, type: 3}
|
m_CorrespondingSourceObject: {fileID: 3735992581812067225, guid: bc071165ad2d3c14288cf13ac0ff6537, type: 3}
|
||||||
m_PrefabInstance: {fileID: 2586681477197472527}
|
m_PrefabInstance: {fileID: 2586681477197472527}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!4 &1170184303236858142 stripped
|
||||||
|
Transform:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 3735992582968959505, guid: bc071165ad2d3c14288cf13ac0ff6537, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 2586681477197472527}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
--- !u!1001 &2586681477597724647
|
--- !u!1001 &2586681477597724647
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -18675,7 +18783,7 @@ PrefabInstance:
|
||||||
m_Modifications:
|
m_Modifications:
|
||||||
- target: {fileID: 6613058589454542448, guid: 9dc0ffd7f5e4855429cfdf90601da8ce, type: 3}
|
- target: {fileID: 6613058589454542448, guid: 9dc0ffd7f5e4855429cfdf90601da8ce, type: 3}
|
||||||
propertyPath: m_LocalPosition.x
|
propertyPath: m_LocalPosition.x
|
||||||
value: 10.805763
|
value: 10.80577
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 6613058589454542448, guid: 9dc0ffd7f5e4855429cfdf90601da8ce, type: 3}
|
- target: {fileID: 6613058589454542448, guid: 9dc0ffd7f5e4855429cfdf90601da8ce, type: 3}
|
||||||
propertyPath: m_LocalPosition.y
|
propertyPath: m_LocalPosition.y
|
||||||
|
@ -18683,7 +18791,7 @@ PrefabInstance:
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 6613058589454542448, guid: 9dc0ffd7f5e4855429cfdf90601da8ce, type: 3}
|
- target: {fileID: 6613058589454542448, guid: 9dc0ffd7f5e4855429cfdf90601da8ce, type: 3}
|
||||||
propertyPath: m_LocalPosition.z
|
propertyPath: m_LocalPosition.z
|
||||||
value: 7.484809
|
value: 7.4848127
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 6613058589454542451, guid: 9dc0ffd7f5e4855429cfdf90601da8ce, type: 3}
|
- target: {fileID: 6613058589454542451, guid: 9dc0ffd7f5e4855429cfdf90601da8ce, type: 3}
|
||||||
propertyPath: editorData._bezierPath.points.Array.data[0].x
|
propertyPath: editorData._bezierPath.points.Array.data[0].x
|
||||||
|
@ -20018,16 +20126,16 @@ PrefabInstance:
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: 2784d88b6334dc143a910f3d252aa5df, type: 3}
|
m_SourcePrefab: {fileID: 100100000, guid: 2784d88b6334dc143a910f3d252aa5df, type: 3}
|
||||||
--- !u!4 &3882838201459745148 stripped
|
|
||||||
Transform:
|
|
||||||
m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: 2784d88b6334dc143a910f3d252aa5df, type: 3}
|
|
||||||
m_PrefabInstance: {fileID: 3632194575318009495}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
--- !u!1 &4515224116292451270 stripped
|
--- !u!1 &4515224116292451270 stripped
|
||||||
GameObject:
|
GameObject:
|
||||||
m_CorrespondingSourceObject: {fileID: 919132149155446097, guid: 2784d88b6334dc143a910f3d252aa5df, type: 3}
|
m_CorrespondingSourceObject: {fileID: 919132149155446097, guid: 2784d88b6334dc143a910f3d252aa5df, type: 3}
|
||||||
m_PrefabInstance: {fileID: 3632194575318009495}
|
m_PrefabInstance: {fileID: 3632194575318009495}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!4 &3882838201459745148 stripped
|
||||||
|
Transform:
|
||||||
|
m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: 2784d88b6334dc143a910f3d252aa5df, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 3632194575318009495}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
--- !u!1001 &3716639497179111755
|
--- !u!1001 &3716639497179111755
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Events;
|
||||||
|
|
||||||
|
namespace Ktyl.Util
|
||||||
|
{
|
||||||
|
public class UnseenEventTrigger : MonoBehaviour
|
||||||
|
{
|
||||||
|
[System.Serializable]
|
||||||
|
private struct Event
|
||||||
|
{
|
||||||
|
public GameEvent game;
|
||||||
|
public UnityEvent unity;
|
||||||
|
|
||||||
|
public void Raise()
|
||||||
|
{
|
||||||
|
if (game) game.Raise();
|
||||||
|
unity.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
private float _minDistance = 2f;
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
[Range(0f, 180f)]
|
||||||
|
private float _minAngle = 90.0f;
|
||||||
|
|
||||||
|
[SerializeField] private Event _onUnseen;
|
||||||
|
|
||||||
|
private bool _isArmed = false;
|
||||||
|
private Camera _camera;
|
||||||
|
|
||||||
|
public void Disarm()
|
||||||
|
{
|
||||||
|
_isArmed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Arm()
|
||||||
|
{
|
||||||
|
_isArmed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
if ( !_isArmed )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( !IsUnseen() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
_onUnseen.Raise();
|
||||||
|
|
||||||
|
_isArmed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsUnseen()
|
||||||
|
{
|
||||||
|
// lazy init camera
|
||||||
|
if ( _camera == null )
|
||||||
|
{
|
||||||
|
_camera = Camera.main;
|
||||||
|
}
|
||||||
|
|
||||||
|
var camDiff = transform.position - _camera.transform.position;
|
||||||
|
|
||||||
|
// distance check
|
||||||
|
if ( camDiff.sqrMagnitude < _minDistance * _minDistance )
|
||||||
|
{
|
||||||
|
// too close!
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// angle check
|
||||||
|
float angleDiff = Vector3.Angle( camDiff.normalized, _camera.transform.forward );
|
||||||
|
if ( angleDiff < _minAngle )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1288062ae3320c745a7e22cb010b5a18
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue