Skip to content

Commit 41002ce

Browse files
committed
* Some changes on camera Target and camera itself.
1 parent 679bddc commit 41002ce

File tree

2 files changed

+76
-2
lines changed

2 files changed

+76
-2
lines changed

Scripts/Camera/CameraTarget.cs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,40 @@ public class CameraTarget : MonoBehaviour
5454

5555
#region Public Members
5656

57+
/// <summary>
58+
/// Gets or sets a value indicating whether this <see cref="IBM.Watson.DeveloperCloud.Camera.CameraTarget"/> use
59+
/// custom position.
60+
/// </summary>
61+
/// <value><c>true</c> if use custom position; otherwise, <c>false</c>.</value>
62+
public bool UseCustomPosition
63+
{
64+
get
65+
{
66+
return m_UseCustomPosition;
67+
}
68+
set
69+
{
70+
m_UseCustomPosition = value;
71+
}
72+
}
73+
74+
/// <summary>
75+
/// Gets or sets a value indicating whether this <see cref="IBM.Watson.DeveloperCloud.Camera.CameraTarget"/> use
76+
/// custom rotation.
77+
/// </summary>
78+
/// <value><c>true</c> if use custom rotation; otherwise, <c>false</c>.</value>
79+
public bool UseCustomRotation
80+
{
81+
get
82+
{
83+
return m_UseCustomRotation;
84+
}
85+
set
86+
{
87+
m_UseCustomRotation = value;
88+
}
89+
}
90+
5791
/// <summary>
5892
/// Gets or sets the target position.
5993
/// </summary>
@@ -128,6 +162,10 @@ public Quaternion TargetRotation
128162
}
129163
}
130164

165+
/// <summary>
166+
/// Gets or sets the target object.
167+
/// </summary>
168+
/// <value>The target object.</value>
131169
public GameObject TargetObject
132170
{
133171
get
@@ -149,6 +187,10 @@ public GameObject TargetObject
149187
}
150188
}
151189

190+
/// <summary>
191+
/// Gets the camera attached.
192+
/// </summary>
193+
/// <value>The camera attached.</value>
152194
public UnityEngine.Camera CameraAttached
153195
{
154196
get
@@ -162,6 +204,10 @@ public UnityEngine.Camera CameraAttached
162204
}
163205
}
164206

207+
/// <summary>
208+
/// Gets the watson camera attached.
209+
/// </summary>
210+
/// <value>The watson camera attached.</value>
165211
public WatsonCamera WatsonCameraAttached
166212
{
167213
get
@@ -178,6 +224,10 @@ public WatsonCamera WatsonCameraAttached
178224

179225
#region Set Target on Camera
180226

227+
/// <summary>
228+
/// Sets the current target on camera.
229+
/// </summary>
230+
/// <param name="enable">If set to <c>true</c> enable.</param>
181231
public void SetCurrentTargetOnCamera(bool enable)
182232
{
183233
if (WatsonCamera.Instance != null)
@@ -189,6 +239,9 @@ public void SetCurrentTargetOnCamera(bool enable)
189239
}
190240
}
191241

242+
/// <summary>
243+
/// Sets the target position default.
244+
/// </summary>
192245
public void SetTargetPositionDefault()
193246
{
194247
if (WatsonCamera.Instance != null && WatsonCamera.Instance.DefaultCameraTarget != null)
@@ -197,6 +250,9 @@ public void SetTargetPositionDefault()
197250
}
198251
}
199252

253+
/// <summary>
254+
/// Sets the target rotation default.
255+
/// </summary>
200256
public void SetTargetRotationDefault()
201257
{
202258
if (WatsonCamera.Instance != null && WatsonCamera.Instance.DefaultCameraTarget != null)

Scripts/Camera/WatsonCamera.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ protected virtual void CameraPositionOnUpdate()
163163
if (CurrentCameraTarget != null)
164164
{
165165
transform.localPosition = Vector3.Lerp(transform.localPosition, CurrentCameraTarget.TargetPosition, Time.deltaTime * m_SpeedForCameraAnimation);
166-
transform.rotation = Quaternion.Lerp(transform.localRotation, CurrentCameraTarget.TargetRotation, Time.deltaTime * m_SpeedForCameraAnimation);
166+
transform.rotation = Quaternion.Slerp(transform.localRotation, CurrentCameraTarget.TargetRotation, Time.deltaTime * m_SpeedForCameraAnimation);
167167
}
168168
}
169169

@@ -172,6 +172,11 @@ protected virtual void InitializeCameraTargetList()
172172
if (m_ListCameraTarget == null)
173173
m_ListCameraTarget = new List<CameraTarget>();
174174

175+
for (int i = 0; m_ListCameraTarget != null && i < m_ListCameraTarget.Count; i++)
176+
{
177+
Destroy(m_ListCameraTarget[i]);
178+
}
179+
175180
m_ListCameraTarget.Clear();
176181

177182
CameraTarget defaultCameraTarget = this.gameObject.GetComponent<CameraTarget>();
@@ -263,6 +268,18 @@ protected virtual void OnCameraSetTwoFingerDrag(System.Object[] args)
263268
}
264269

265270

271+
/// <summary>
272+
/// Event handler reseting the camera. Deleting all camera target and set the initial as default.
273+
/// </summary>
274+
/// <param name="args">Arguments.</param>
275+
protected virtual void ResetCamera(System.Object[] args)
276+
{
277+
if (m_DisableInteractivity)
278+
return;
279+
280+
InitializeCameraTargetList();
281+
}
282+
266283
/// <summary>
267284
/// Event handler reseting the camera position.
268285
/// </summary>
@@ -272,7 +289,8 @@ protected virtual void ResetCameraPosition(System.Object[] args)
272289
if (m_DisableInteractivity)
273290
return;
274291
//Log.Status("WatsonCamera", "Reset Camera Position");
275-
InitializeCameraTargetList();
292+
CurrentCameraTarget.TargetPosition = m_CameraInitialLocation;
293+
CurrentCameraTarget.TargetRotation = m_CameraInitialRotation;
276294
}
277295

278296

0 commit comments

Comments
 (0)