summaryrefslogtreecommitdiff
path: root/Runtime/Export/UnityEngineComponent.txt
blob: 2fa9b9c6d123aceeed02de56413cd00bb7171777 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
C++RAW


#include "UnityPrefix.h"
#include "Runtime/Graphics/Transform.h"
#include "Runtime/Mono/MonoBehaviour.h"
#include "Runtime/BaseClasses/Tags.h"
#if ENABLE_AUDIO
#include "Runtime/Audio/AudioClip.h"
#include "Runtime/Audio/AudioSource.h"
#include "Runtime/Audio/AudioListener.h"
#endif
#include "Runtime/Animation/Animation.h"
#include "Runtime/Math/Color.h"
#include "Runtime/Utilities/PlayerPrefs.h"
#include "Runtime/Camera/Camera.h"
#include "Runtime/Utilities/Word.h"
#include "Runtime/Camera/Light.h"
#include "Runtime/Filters/Misc/TextMesh.h"
#include "Runtime/Dynamics/ConstantForce.h"
#include "Runtime/Filters/Renderer.h"
#include "Runtime/Network/NetworkView.h"
#include "Runtime/Camera/RenderLayers/GUIText.h"
#include "Runtime/Camera/RenderLayers/GUITexture.h"
#include "Runtime/Scripting/ScriptingUtility.h"
#include "Runtime/Scripting/GetComponent.h"
#include "Runtime/Misc/GameObjectUtility.h"
#if ENABLE_PHYSICS
#include "Runtime/Dynamics/RigidBody.h"
#include "Runtime/Dynamics/Collider.h"
#include "Runtime/Dynamics/HingeJoint.h"
#endif
#if ENABLE_2D_PHYSICS
#include "Runtime/Physics2D/RigidBody2D.h"
#include "Runtime/Physics2D/Collider2D.h"
#endif
#include "Runtime/Filters/Particles/ParticleEmitter.h"
#include "Runtime/Graphics/ParticleSystem/ParticleSystem.h"
#include "Runtime/Animation/AnimationClip.h"
#include "Runtime/File/ApplicationSpecificPersistentDataPath.h"
#if ENABLE_MONO
#include "Runtime/Mono/Coroutine.h"
#endif

#if UNITY_WII
	#include "PlatformDependent/Wii/WiiUtility.h"
#endif

#include "Runtime/Scripting/Scripting.h"
	
using namespace Unity;

CSRAW
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Collections;
using UnityEngineInternal;

namespace UnityEngine
{

// Base class for everything attached to GameObjects.
NONSEALED_CLASS Component : Object
	
	C++RAW
 #define FAST_COMPONENT_QUERY_COMPONENT_HANDLE(x) DISALLOW_IN_CONSTRUCTOR  GameObject* go = self->GetGameObjectPtr(); if (go) {Unity::Component* com = go->QueryComponent (x); Scripting::GetComponentObjectToScriptingObject (com, *go, ClassID (x)); return com->GetGCHandle(); } else { Scripting::RaiseMonoException ("The component is not attached to any game object!"); return 0; }

	C++RAW
 #define FAST_COMPONENT_QUERY_COMPONENT(x) DISALLOW_IN_CONSTRUCTOR  GameObject* go = self->GetGameObjectPtr(); if (go) return Scripting::GetComponentObjectToScriptingObject (go->QueryComponent (x), *go, ClassID (x)); else { Scripting::RaiseMonoException ("The component is not attached to any game object!"); return SCRIPTING_NULL; }

	// The [[Transform]] attached to this [[GameObject]] (null if there is none attached).
	CSRAW
	CSRAW public Transform transform 
	{ 
		get
		{
			return InternalGetTransform();
		}
	}

	CUSTOM internal Transform InternalGetTransform()
	{ 
		FAST_COMPONENT_QUERY_COMPONENT(Transform);
	}

	// The [[Rigidbody]] attached to this [[GameObject]] (null if there is none attached).
	CONDITIONAL ENABLE_PHYSICS
	CUSTOM_PROP Rigidbody rigidbody { FAST_COMPONENT_QUERY_COMPONENT(Rigidbody) }
	CONDITIONAL ENABLE_2D_PHYSICS
	CUSTOM_PROP Rigidbody2D rigidbody2D { FAST_COMPONENT_QUERY_COMPONENT(Rigidbody2D) }

	// The [[Camera]] attached to this [[GameObject]] (null if there is none attached).
	CUSTOM_PROP Camera camera { FAST_COMPONENT_QUERY_COMPONENT(Camera) }
	// The [[Light]] attached to this [[GameObject]] (null if there is none attached).
	CUSTOM_PROP Light light { FAST_COMPONENT_QUERY_COMPONENT(Light) }
	// The [[Animation]] attached to this [[GameObject]] (null if there is none attached).
	CUSTOM_PROP Animation animation { FAST_COMPONENT_QUERY_COMPONENT(Animation) }
	// The [[ConstantForce]] attached to this [[GameObject]] (null if there is none attached).
	CONDITIONAL ENABLE_PHYSICS
	CUSTOM_PROP ConstantForce constantForce { FAST_COMPONENT_QUERY_COMPONENT(ConstantForce) }
	// The [[Renderer]] attached to this [[GameObject]] (null if there is none attached).
	CUSTOM_PROP Renderer renderer { FAST_COMPONENT_QUERY_COMPONENT(Renderer) }
	// The [[AudioSource]] attached to this [[GameObject]] (null if there is none attached).
	CONDITIONAL ENABLE_AUDIO
	CUSTOM_PROP AudioSource audio { FAST_COMPONENT_QUERY_COMPONENT(AudioSource) }
	// The [[GUIText]] attached to this [[GameObject]] (null if there is none attached).
	CUSTOM_PROP GUIText guiText { FAST_COMPONENT_QUERY_COMPONENT(GUIText) }
	
	CONDITIONAL ENABLE_NETWORK
	// The [[NetworkView]] attached to this [[GameObject]] (RO). (null if there is none attached)
	CUSTOM_PROP NetworkView networkView
	{
		#if ENABLE_NETWORK
		FAST_COMPONENT_QUERY_COMPONENT(NetworkView)
		#else
		return SCRIPTING_NULL;
		#endif
	}

	FLUSHCONDITIONS

	CSRAW
#if ENABLE_NETWORK
	OBSOLETE warning Please use guiTexture instead
#endif
	CUSTOM_PROP GUIElement guiElement { FAST_COMPONENT_QUERY_COMPONENT(GUIElement) }

	// The [[GUITexture]] attached to this [[GameObject]] (RO). (null if there is none attached)
	CUSTOM_PROP GUITexture guiTexture { FAST_COMPONENT_QUERY_COMPONENT(GUITexture) }

	// The [[Collider]] attached to this [[GameObject]] (null if there is none attached).
	CONDITIONAL ENABLE_PHYSICS
	CUSTOM_PROP Collider collider { FAST_COMPONENT_QUERY_COMPONENT(Collider) }
	CONDITIONAL ENABLE_2D_PHYSICS
	CUSTOM_PROP Collider2D collider2D { FAST_COMPONENT_QUERY_COMPONENT(Collider2D) }

	// The [[HingeJoint]] attached to this [[GameObject]] (null if there is none attached).
	CONDITIONAL ENABLE_PHYSICS
	CUSTOM_PROP HingeJoint hingeJoint { FAST_COMPONENT_QUERY_COMPONENT(HingeJoint) }
	// The [[ParticleEmitter]] attached to this [[GameObject]] (null if there is none attached).
	CUSTOM_PROP ParticleEmitter particleEmitter { FAST_COMPONENT_QUERY_COMPONENT(ParticleEmitter) }
	// The [[ParticleSystem]] attached to this [[GameObject]] (null if there is none attached).
	CUSTOM_PROP ParticleSystem particleSystem { FAST_COMPONENT_QUERY_COMPONENT(ParticleSystem) }


	// The game object this component is attached to. A component is always attached to a game object.
	
	CSRAW public GameObject gameObject
	{
		get
		{
			return InternalGetGameObject();
		}
	}

	CUSTOM internal GameObject InternalGetGameObject()
	{ 
		DISALLOW_IN_CONSTRUCTOR
		return Scripting::ScriptingWrapperFor(self->GetGameObjectPtr()); 
	}
	// Returns the component of Type /type/ if the game object has one attached, null if it doesn't.
	
	CSRAW
	[TypeInferenceRule(TypeInferenceRules.TypeReferencedByFirstArgument)]
	CUSTOM Component GetComponent (Type type)
	{
		DISALLOW_IN_CONSTRUCTOR
		
		GameObject* go = self->GetGameObjectPtr();
		if (go)
		{
			return ScriptingGetComponentOfType (*go, type);
		}
		else
		{
			Scripting::RaiseMonoException ("The component is not attached to any game object!");
			return SCRIPTING_NULL;
		}
	}

	C++RAW


	#if UNITY_WINRT
	GameObject& GetGameObjectThrow (void* com_)
	{
		ReadOnlyScriptingObjectOfType<Unity::Component> com(com_);
	#else
	GameObject& GetGameObjectThrow (ReadOnlyScriptingObjectOfType<Unity::Component> com)
	{
	#endif
		GameObject* go = com->GetGameObjectPtr();
		if (go)
			return *go;
		{
			Scripting::RaiseMonoException ("The component is not attached to any game object!");
			return *go;
		}
	}

	CSRAW
	#if ENABLE_GENERICS
	// Generic version. See the [[wiki:Generic Functions|Generic Functions]] page for more details.
	public T GetComponent<T>() where T : Component { return GetComponent(typeof(T)) as T; }
	#endif

	// Returns the component with name /type/ if the game object has one attached, null if it doesn't.
	
	CSRAW public Component GetComponent (string type) { return gameObject.GetComponent(type); }
	

	
	
	// Returns the component of Type /type/ in the [[GameObject]] or any of its children using depth first search.
	
	
	CSRAW
	[TypeInferenceRule(TypeInferenceRules.TypeReferencedByFirstArgument)]
	CSRAW public Component GetComponentInChildren (Type t) { return gameObject.GetComponentInChildren (t); }

	CSRAW
	#if ENABLE_GENERICS
	// Generic version. See the [[wiki:Generic Functions|Generic Functions]] page for more details.
	public T GetComponentInChildren<T> () where T : Component { return (T) GetComponentInChildren(typeof(T)); }
	#endif


	// Returns all components of Type /type/ in the [[GameObject]] or any of its children.
	
	CSRAW public Component[] GetComponentsInChildren (Type t, bool includeInactive = false) { return gameObject.GetComponentsInChildren (t, includeInactive); }
	
	CSRAW
	#if ENABLE_GENERICS
	// Generic version. See the [[wiki:Generic Functions|Generic Functions]] page for more details.
	public T[] GetComponentsInChildren<T> (bool includeInactive) where T : Component { return gameObject.GetComponentsInChildren<T>(includeInactive); }
	#endif

	CSRAW
	#if ENABLE_GENERICS
	// adding overload manually because lucas can't figure out how to get the cspreprocess overload generation code to deal with templates right now.
	// Generic version. See the [[wiki:Generic Functions|Generic Functions]] page for more details.
	public T[] GetComponentsInChildren<T> () where T : Component { return GetComponentsInChildren<T>(false); }
	#endif

	
	
	// Returns all components of Type /type/ in the [[GameObject]].
	
	CUSTOM Component[] GetComponents (Type type)  { DISALLOW_IN_CONSTRUCTOR return ScriptingGetComponentsOfType (GetGameObjectThrow(self), type, false, false, true); }

	CUSTOM private Component[] GetComponentsWithCorrectReturnType(Type type) { DISALLOW_IN_CONSTRUCTOR return ScriptingGetComponentsOfType (GetGameObjectThrow(self), type, true, false, true); }
	
	CSRAW
	#if ENABLE_GENERICS
	// Generic version. See the [[wiki:Generic Functions|Generic Functions]] page for more details.
	public T[] GetComponents<T>() where T : Component
	{
		return (T[]) GetComponentsWithCorrectReturnType(typeof(T));
	}
	#endif
		

	OBSOLETE warning the active property is deprecated on components. Please use gameObject.active instead. If you meant to enable / disable a single component use enabled instead.
	CUSTOM_PROP bool active { DISALLOW_IN_CONSTRUCTOR return self->IsActive (); } { DISALLOW_IN_CONSTRUCTOR GameObject& go = GetGameObjectThrow(self); if (value) go.Activate (); else go.Deactivate (); }
	
	// The tag of this game object.
	CUSTOM_PROP string tag
	{
		DISALLOW_IN_CONSTRUCTOR 
		const string& tag = TagToString (GetGameObjectThrow(self).GetTag ());
		if (!tag.empty ())
			return scripting_string_new(tag);
		else
		{
			Scripting::RaiseMonoException ("GameObject has undefined tag!");
			return SCRIPTING_NULL;
		}
	}
	{
		DISALLOW_IN_CONSTRUCTOR 
		GetGameObjectThrow(self).SetTag (ExtractTagThrowing (value));
	}
	
	// Is this game object tagged /tag/?
	CUSTOM public bool CompareTag (string tag) { DISALLOW_IN_CONSTRUCTOR return ExtractTagThrowing (tag) == GetGameObjectThrow(self).GetTag (); }
	

	// Calls the method named /methodName/ on every [[MonoBehaviour]] in this game object and on every ancestor of the behaviour
	CUSTOM void SendMessageUpwards (string methodName, object value = null, SendMessageOptions options = SendMessageOptions.RequireReceiver)
	{
		DISALLOW_IN_CONSTRUCTOR
		Scripting::SendScriptingMessageUpwards(GetGameObjectThrow(self), methodName, value, options);
	}
	
	//*undocumented* Function is for convenience and avoid coming mistakes.
	CSRAW public void SendMessageUpwards (string methodName, SendMessageOptions options)
	{
		SendMessageUpwards(methodName, null, options);
	}

	// Calls the method named /methodName/ on every [[MonoBehaviour]] in this game object.
	CUSTOM void SendMessage (string methodName, object value = null, SendMessageOptions options = SendMessageOptions.RequireReceiver)
	{
		DISALLOW_IN_CONSTRUCTOR
		Scripting::SendScriptingMessage(GetGameObjectThrow(self), methodName, value, options);
	}

	//*undocumented* Function is for convenience and avoid coming mistakes.
	CSRAW public void SendMessage (string methodName, SendMessageOptions options)
	{
		SendMessage (methodName, null, options);
	}

	// Calls the method named /methodName/ on every [[MonoBehaviour]] in this game object or any of its children.
	CUSTOM void BroadcastMessage (string methodName, object parameter = null, SendMessageOptions options = SendMessageOptions.RequireReceiver)
	{
		DISALLOW_IN_CONSTRUCTOR
		Scripting::BroadcastScriptingMessage(GetGameObjectThrow(self), methodName, parameter, options);
	}
	
	//*undocumented* Function is for convenience and avoid coming mistakes.
	CSRAW public void BroadcastMessage (string methodName, SendMessageOptions options)
	{
		BroadcastMessage (methodName, null, options);
	}
END

CSRAW }