Skip to content

Commit 679bddc

Browse files
committed
* Reset camera function changed
* Changed Camera target variables as public * Added target position with offset position
1 parent 337cd30 commit 679bddc

File tree

3 files changed

+70
-19
lines changed

3 files changed

+70
-19
lines changed

Scripts/Camera/CameraTarget.cs

Lines changed: 59 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,23 @@ public class CameraTarget : MonoBehaviour
3333
private static UnityEngine.Camera mp_CameraAttached = null;
3434
[SerializeField]
3535
private bool m_UseCustomPosition = false;
36+
[SerializeField]
3637
private Vector3 m_CustomPosition = Vector3.zero;
3738
[SerializeField]
39+
private Vector3 m_OffsetPosition = Vector3.zero;
40+
private Quaternion m_OffsetPositionRotation = Quaternion.identity;
41+
[SerializeField]
3842
private bool m_UseCustomRotation = false;
3943
private Quaternion m_CustomRotation = Quaternion.identity;
4044
private bool m_UseTargetObjectToRotate = false;
45+
[SerializeField]
4146
private GameObject m_CustomTargetObjectToLookAt = null;
4247

48+
[SerializeField]
49+
private bool m_TextEnableCamera = false;
50+
[SerializeField]
51+
private bool m_TestToMakeItCurrent = false;
52+
4353
#endregion
4454

4555
#region Public Members
@@ -57,9 +67,13 @@ public Vector3 TargetPosition
5767
{
5868
return m_CustomPosition;
5969
}
70+
else if (m_OffsetPosition != Vector3.zero)
71+
{
72+
return transform.position + ( Quaternion.Euler(transform.rotation.eulerAngles - m_OffsetPositionRotation.eulerAngles) * m_OffsetPosition);
73+
}
6074
else
6175
{
62-
return transform.position;
76+
return transform.position ;
6377
}
6478
}
6579
set
@@ -77,11 +91,7 @@ public Quaternion TargetRotation
7791
{
7892
get
7993
{
80-
if (m_UseCustomRotation)
81-
{
82-
return m_CustomRotation;
83-
}
84-
else if (m_UseTargetObjectToRotate)
94+
if (m_UseTargetObjectToRotate)
8595
{
8696
if (TargetObject != null)
8797
{
@@ -102,6 +112,10 @@ public Quaternion TargetRotation
102112
return Quaternion.identity;
103113
}
104114
}
115+
else if (m_UseCustomRotation)
116+
{
117+
return m_CustomRotation;
118+
}
105119
else
106120
{
107121
return transform.rotation;
@@ -114,20 +128,28 @@ public Quaternion TargetRotation
114128
}
115129
}
116130

117-
protected GameObject TargetObject
131+
public GameObject TargetObject
118132
{
119133
get
120134
{
121135
return m_CustomTargetObjectToLookAt;
122136
}
123137
set
124138
{
125-
m_UseTargetObjectToRotate = true;
126-
m_CustomTargetObjectToLookAt = value;
139+
if (value != null)
140+
{
141+
m_UseTargetObjectToRotate = true;
142+
m_CustomTargetObjectToLookAt = value;
143+
}
144+
else
145+
{
146+
m_UseTargetObjectToRotate = false;
147+
m_CustomTargetObjectToLookAt = null;
148+
}
127149
}
128150
}
129151

130-
protected UnityEngine.Camera CameraAttached
152+
public UnityEngine.Camera CameraAttached
131153
{
132154
get
133155
{
@@ -140,7 +162,7 @@ protected UnityEngine.Camera CameraAttached
140162
}
141163
}
142164

143-
protected WatsonCamera WatsonCameraAttached
165+
public WatsonCamera WatsonCameraAttached
144166
{
145167
get
146168
{
@@ -156,7 +178,7 @@ protected WatsonCamera WatsonCameraAttached
156178

157179
#region Set Target on Camera
158180

159-
protected void SetCurrentTargetOnCamera(bool enable)
181+
public void SetCurrentTargetOnCamera(bool enable)
160182
{
161183
if (WatsonCamera.Instance != null)
162184
{
@@ -167,15 +189,15 @@ protected void SetCurrentTargetOnCamera(bool enable)
167189
}
168190
}
169191

170-
protected void SetTargetPositionDefault()
192+
public void SetTargetPositionDefault()
171193
{
172194
if (WatsonCamera.Instance != null && WatsonCamera.Instance.DefaultCameraTarget != null)
173195
{
174196
TargetPosition = WatsonCamera.Instance.DefaultCameraTarget.TargetPosition;
175197
}
176198
}
177199

178-
protected void SetTargetRotationDefault()
200+
public void SetTargetRotationDefault()
179201
{
180202
if (WatsonCamera.Instance != null && WatsonCamera.Instance.DefaultCameraTarget != null)
181203
{
@@ -184,6 +206,29 @@ protected void SetTargetRotationDefault()
184206
}
185207

186208
#endregion
209+
210+
#region Update
211+
212+
void Update()
213+
{
214+
if (m_TestToMakeItCurrent)
215+
{
216+
m_TestToMakeItCurrent = false;
217+
SetCurrentTargetOnCamera(m_TextEnableCamera);
218+
}
219+
}
220+
221+
#endregion
222+
223+
#region public Functions
224+
225+
public void SetTargetPositionWithOffset(Vector3 offsetPosition)
226+
{
227+
m_OffsetPosition = offsetPosition;
228+
m_OffsetPositionRotation = this.transform.rotation;
229+
}
230+
231+
#endregion
187232
}
188233

189234
}

Scripts/Camera/WatsonCamera.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,10 @@ protected virtual void InitializeCameraTargetList()
174174

175175
m_ListCameraTarget.Clear();
176176

177-
CameraTarget defaultCameraTarget = this.gameObject.AddComponent<CameraTarget>();
177+
CameraTarget defaultCameraTarget = this.gameObject.GetComponent<CameraTarget>();
178+
if(defaultCameraTarget == null)
179+
defaultCameraTarget = this.gameObject.AddComponent<CameraTarget>();
180+
178181
defaultCameraTarget.TargetPosition = m_CameraInitialLocation;
179182
defaultCameraTarget.TargetRotation = m_CameraInitialRotation;
180183
m_ListCameraTarget.Add(defaultCameraTarget);
@@ -269,10 +272,10 @@ protected virtual void ResetCameraPosition(System.Object[] args)
269272
if (m_DisableInteractivity)
270273
return;
271274
//Log.Status("WatsonCamera", "Reset Camera Position");
272-
DefaultCameraTarget.TargetPosition = m_CameraInitialLocation;
273-
DefaultCameraTarget.TargetRotation = m_CameraInitialRotation;
275+
InitializeCameraTargetList();
274276
}
275277

278+
276279
/// <summary>
277280
/// Event handler moving the camera up.
278281
/// </summary>

ThirdParty/WebSocketSharp/WebSocket.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,8 +1125,11 @@ private void fatal (string message, Exception exception)
11251125
var code = exception is WebSocketException
11261126
? ((WebSocketException) exception).Code
11271127
: CloseStatusCode.Abnormal;
1128-
1129-
fatal (message, code);
1128+
1129+
if(exception != null)
1130+
fatal (message + exception.Message + exception.StackTrace, code);
1131+
else
1132+
fatal (message, code);
11301133
}
11311134

11321135
private void fatal (string message, CloseStatusCode code)

0 commit comments

Comments
 (0)