@@ -33,17 +33,61 @@ 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
4656
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+
4791 /// <summary>
4892 /// Gets or sets the target position.
4993 /// </summary>
@@ -57,9 +101,13 @@ public Vector3 TargetPosition
57101 {
58102 return m_CustomPosition ;
59103 }
104+ else if ( m_OffsetPosition != Vector3 . zero )
105+ {
106+ return transform . position + ( Quaternion . Euler ( transform . rotation . eulerAngles - m_OffsetPositionRotation . eulerAngles ) * m_OffsetPosition ) ;
107+ }
60108 else
61109 {
62- return transform . position ;
110+ return transform . position ;
63111 }
64112 }
65113 set
@@ -77,11 +125,7 @@ public Quaternion TargetRotation
77125 {
78126 get
79127 {
80- if ( m_UseCustomRotation )
81- {
82- return m_CustomRotation ;
83- }
84- else if ( m_UseTargetObjectToRotate )
128+ if ( m_UseTargetObjectToRotate )
85129 {
86130 if ( TargetObject != null )
87131 {
@@ -102,6 +146,10 @@ public Quaternion TargetRotation
102146 return Quaternion . identity ;
103147 }
104148 }
149+ else if ( m_UseCustomRotation )
150+ {
151+ return m_CustomRotation ;
152+ }
105153 else
106154 {
107155 return transform . rotation ;
@@ -114,20 +162,36 @@ public Quaternion TargetRotation
114162 }
115163 }
116164
117- protected GameObject TargetObject
165+ /// <summary>
166+ /// Gets or sets the target object.
167+ /// </summary>
168+ /// <value>The target object.</value>
169+ public GameObject TargetObject
118170 {
119171 get
120172 {
121173 return m_CustomTargetObjectToLookAt ;
122174 }
123175 set
124176 {
125- m_UseTargetObjectToRotate = true ;
126- m_CustomTargetObjectToLookAt = value ;
177+ if ( value != null )
178+ {
179+ m_UseTargetObjectToRotate = true ;
180+ m_CustomTargetObjectToLookAt = value ;
181+ }
182+ else
183+ {
184+ m_UseTargetObjectToRotate = false ;
185+ m_CustomTargetObjectToLookAt = null ;
186+ }
127187 }
128188 }
129189
130- protected UnityEngine . Camera CameraAttached
190+ /// <summary>
191+ /// Gets the camera attached.
192+ /// </summary>
193+ /// <value>The camera attached.</value>
194+ public UnityEngine . Camera CameraAttached
131195 {
132196 get
133197 {
@@ -140,7 +204,11 @@ protected UnityEngine.Camera CameraAttached
140204 }
141205 }
142206
143- protected WatsonCamera WatsonCameraAttached
207+ /// <summary>
208+ /// Gets the watson camera attached.
209+ /// </summary>
210+ /// <value>The watson camera attached.</value>
211+ public WatsonCamera WatsonCameraAttached
144212 {
145213 get
146214 {
@@ -156,7 +224,11 @@ protected WatsonCamera WatsonCameraAttached
156224
157225 #region Set Target on Camera
158226
159- protected void SetCurrentTargetOnCamera ( bool enable )
227+ /// <summary>
228+ /// Sets the current target on camera.
229+ /// </summary>
230+ /// <param name="enable">If set to <c>true</c> enable.</param>
231+ public void SetCurrentTargetOnCamera ( bool enable )
160232 {
161233 if ( WatsonCamera . Instance != null )
162234 {
@@ -167,15 +239,21 @@ protected void SetCurrentTargetOnCamera(bool enable)
167239 }
168240 }
169241
170- protected void SetTargetPositionDefault ( )
242+ /// <summary>
243+ /// Sets the target position default.
244+ /// </summary>
245+ public void SetTargetPositionDefault ( )
171246 {
172247 if ( WatsonCamera . Instance != null && WatsonCamera . Instance . DefaultCameraTarget != null )
173248 {
174249 TargetPosition = WatsonCamera . Instance . DefaultCameraTarget . TargetPosition ;
175250 }
176251 }
177252
178- protected void SetTargetRotationDefault ( )
253+ /// <summary>
254+ /// Sets the target rotation default.
255+ /// </summary>
256+ public void SetTargetRotationDefault ( )
179257 {
180258 if ( WatsonCamera . Instance != null && WatsonCamera . Instance . DefaultCameraTarget != null )
181259 {
@@ -184,6 +262,29 @@ protected void SetTargetRotationDefault()
184262 }
185263
186264 #endregion
265+
266+ #region Update
267+
268+ void Update ( )
269+ {
270+ if ( m_TestToMakeItCurrent )
271+ {
272+ m_TestToMakeItCurrent = false ;
273+ SetCurrentTargetOnCamera ( m_TextEnableCamera ) ;
274+ }
275+ }
276+
277+ #endregion
278+
279+ #region public Functions
280+
281+ public void SetTargetPositionWithOffset ( Vector3 offsetPosition )
282+ {
283+ m_OffsetPosition = offsetPosition ;
284+ m_OffsetPositionRotation = this . transform . rotation ;
285+ }
286+
287+ #endregion
187288 }
188289
189290}
0 commit comments