-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathMonoBehaviour.bindings.cs
More file actions
211 lines (166 loc) · 7.16 KB
/
MonoBehaviour.bindings.cs
File metadata and controls
211 lines (166 loc) · 7.16 KB
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
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
using System;
using System.Collections;
using System.Threading;
using UnityEngine.Bindings;
using UnityEngine.Scripting;
using UnityEngineInternal;
using uei = UnityEngine.Internal;
namespace UnityEngine
{
// MonoBehaviour is the base class every script derives from.
[RequiredByNativeCode]
[ExtensionOfNativeClass]
[NativeHeader("Runtime/Mono/MonoBehaviour.h")]
[NativeHeader("Runtime/Scripting/DelayedCallUtility.h")]
public class MonoBehaviour : Behaviour
{
public MonoBehaviour()
{
ConstructorCheck(this);
}
private CancellationTokenSource m_CancellationTokenSource;
public CancellationToken destroyCancellationToken
{
get
{
if (this == null)
throw new MissingReferenceException("DestroyCancellation token should be called atleast once before destroying the monobehaviour object");
if (m_CancellationTokenSource == null)
{
m_CancellationTokenSource = new CancellationTokenSource();
OnCancellationTokenCreated();
}
return m_CancellationTokenSource.Token;
}
}
[RequiredByNativeCode]
private void RaiseCancellation()
{
m_CancellationTokenSource?.Cancel();
}
// Is any invoke pending on this MonoBehaviour?
public bool IsInvoking()
{
return Internal_IsInvokingAll(this);
}
public void CancelInvoke()
{
Internal_CancelInvokeAll(this);
}
// Invokes the method /methodName/ in time seconds.
public void Invoke(string methodName, float time)
{
InvokeDelayed(this, methodName, time, 0.0f);
}
// Invokes the method /methodName/ in /time/ seconds.
public void InvokeRepeating(string methodName, float repeatRate)
{
InvokeDelayed(this, methodName, repeatRate, repeatRate);
}
// Invokes the method /methodName/ in /time/ seconds.
public void InvokeRepeating(string methodName, float time, float repeatRate)
{
if (repeatRate <= 0.00001f && repeatRate != 0.0f)
throw new UnityException("Invoke repeat rate has to be larger than 0.00001F");
InvokeDelayed(this, methodName, time, repeatRate);
}
// Cancels all Invoke calls with name /methodName/ on this behaviour.
public void CancelInvoke(string methodName)
{
CancelInvoke(this, methodName);
}
// Is any invoke on /methodName/ pending?
public bool IsInvoking(string methodName)
{
return IsInvoking(this, methodName);
}
[uei.ExcludeFromDocs]
public Coroutine StartCoroutine(string methodName)
{
object value = null;
return StartCoroutine(methodName, value);
}
// Starts a coroutine named /methodName/.
public Coroutine StartCoroutine(string methodName, [uei.DefaultValue("null")] object value)
{
if (string.IsNullOrEmpty(methodName))
throw new NullReferenceException("methodName is null or empty");
if (!IsObjectMonoBehaviour(this))
throw new ArgumentException("Coroutines can only be stopped on a MonoBehaviour");
return StartCoroutineManaged(methodName, value);
}
// Starts a coroutine.
public Coroutine StartCoroutine(IEnumerator routine)
{
if (routine == null)
throw new NullReferenceException("routine is null");
if (!IsObjectMonoBehaviour(this))
throw new ArgumentException("Coroutines can only be stopped on a MonoBehaviour");
return StartCoroutineManaged2(routine);
}
//*undocumented*
[Obsolete("StartCoroutine_Auto has been deprecated. Use StartCoroutine instead (UnityUpgradable) -> StartCoroutine([mscorlib] System.Collections.IEnumerator)", false)]
public Coroutine StartCoroutine_Auto(IEnumerator routine)
{
return StartCoroutine(routine);
}
// Stop a coroutine.
public void StopCoroutine(IEnumerator routine)
{
if (routine == null)
throw new NullReferenceException("routine is null");
if (!IsObjectMonoBehaviour(this))
throw new ArgumentException("Coroutines can only be stopped on a MonoBehaviour");
StopCoroutineFromEnumeratorManaged(routine);
}
// Stop a coroutine.
public void StopCoroutine(Coroutine routine)
{
if (routine == null)
throw new NullReferenceException("routine is null");
if (!IsObjectMonoBehaviour(this))
throw new ArgumentException("Coroutines can only be stopped on a MonoBehaviour");
StopCoroutineManaged(routine);
}
// Stops all coroutines named /methodName/ running on this behaviour.
public extern void StopCoroutine(string methodName);
// Stops all coroutines running on this behaviour.
public extern void StopAllCoroutines();
public extern bool useGUILayout { get; set; }
public extern bool didStart { get; }
public extern bool didAwake { get; }
// Allow a specific instance of a MonoBehaviour to run in edit mode (only available in the editor)
public extern bool runInEditMode { get; set; }
internal extern bool allowPrefabModeInPlayMode { get; }
// Logs message to the Unity Console. This function is identical to [[Debug.Log]].
public static void print(object message)
{
Debug.Log(message);
}
[NativeMethod(IsThreadSafe = true)]
extern static void ConstructorCheck([Writable] Object self);
[FreeFunction("CancelInvoke")]
extern static void Internal_CancelInvokeAll([NotNull] MonoBehaviour self);
[FreeFunction("IsInvoking")]
extern static bool Internal_IsInvokingAll([NotNull] MonoBehaviour self);
[FreeFunction]
extern static void InvokeDelayed([NotNull] MonoBehaviour self, string methodName, float time, float repeatRate);
[FreeFunction]
extern static void CancelInvoke([NotNull] MonoBehaviour self, string methodName);
[FreeFunction]
extern static bool IsInvoking([NotNull] MonoBehaviour self, string methodName);
[FreeFunction]
extern static bool IsObjectMonoBehaviour([NotNull] Object obj);
[return: Unmarshalled]
extern Coroutine StartCoroutineManaged(string methodName, object value);
[return: Unmarshalled]
extern Coroutine StartCoroutineManaged2(IEnumerator enumerator);
extern void StopCoroutineManaged(Coroutine routine);
extern void StopCoroutineFromEnumeratorManaged(IEnumerator routine);
extern internal string GetScriptClassName();
extern void OnCancellationTokenCreated();
}
}