This repository was archived by the owner on Dec 24, 2020. It is now read-only.
File tree 4 files changed +78
-0
lines changed
4 files changed +78
-0
lines changed Original file line number Diff line number Diff line change @@ -393,6 +393,24 @@ public Actor FindActor(Type type)
393
393
#endif
394
394
}
395
395
396
+ /// <summary>
397
+ /// Tries to find the script of the given type in this actor tree (checks this actor and all children trees).
398
+ /// </summary>
399
+ /// <param name="type">The type of the script to find.</param>
400
+ /// <returns>Script instance if found, null otherwise.</returns>
401
+ #if UNIT_TEST_COMPILANT
402
+ [ Obsolete ( "Unit tests, don't support methods calls." ) ]
403
+ #endif
404
+ [ UnmanagedCall ]
405
+ public Script FindScript ( Type type )
406
+ {
407
+ #if UNIT_TEST_COMPILANT
408
+ throw new NotImplementedException ( "Unit tests, don't support methods calls. Only properties can be get or set." ) ;
409
+ #else
410
+ return Internal_FindScriptByType ( unmanagedPtr , type ) ;
411
+ #endif
412
+ }
413
+
396
414
/// <summary>
397
415
/// Tries to find the actor with the given name in all the loaded scenes.
398
416
/// </summary>
@@ -922,6 +940,9 @@ public static Guid[] TryGetSerializedObjectsIds(byte[] data)
922
940
[ MethodImpl ( MethodImplOptions . InternalCall ) ]
923
941
internal static extern Actor Internal_FindActorByType ( IntPtr obj , Type type ) ;
924
942
943
+ [ MethodImpl ( MethodImplOptions . InternalCall ) ]
944
+ internal static extern Script Internal_FindScriptByType ( IntPtr obj , Type type ) ;
945
+
925
946
[ MethodImpl ( MethodImplOptions . InternalCall ) ]
926
947
internal static extern Actor Internal_FindByName ( string name ) ;
927
948
Original file line number Diff line number Diff line change @@ -260,6 +260,24 @@ public T FindActor<T>() where T : Actor
260
260
#endif
261
261
}
262
262
263
+ /// <summary>
264
+ /// Tries to find the script of the given type in this script tree (checks this actor and all children trees).
265
+ /// </summary>
266
+ /// <typeparam name="T">The type of the script to find.</typeparam>
267
+ /// <returns>Script instance if found, null otherwise.</returns>
268
+ #if UNIT_TEST_COMPILANT
269
+ [ Obsolete ( "Unit tests, don't support methods calls." ) ]
270
+ #endif
271
+ [ UnmanagedCall ]
272
+ public T FindScript < T > ( ) where T : Script
273
+ {
274
+ #if UNIT_TEST_COMPILANT
275
+ throw new NotImplementedException ( "Unit tests, don't support methods calls. Only properties can be get or set." ) ;
276
+ #else
277
+ return Internal_FindScriptByType ( unmanagedPtr , typeof ( T ) ) as T ;
278
+ #endif
279
+ }
280
+
263
281
/// <summary>
264
282
/// Tries to find the actor of the given type in all the loaded scenes.
265
283
/// </summary>
Original file line number Diff line number Diff line change @@ -115,6 +115,24 @@ public void BreakPrefabLink()
115
115
#endif
116
116
}
117
117
118
+ /// <summary>
119
+ /// Tries to find the script of the given type in all the loaded scenes.
120
+ /// </summary>
121
+ /// <param name="type">The type of the script to find.</param>
122
+ /// <returns>Script instance if found, null otherwise.</returns>
123
+ #if UNIT_TEST_COMPILANT
124
+ [ Obsolete ( "Unit tests, don't support methods calls." ) ]
125
+ #endif
126
+ [ UnmanagedCall ]
127
+ public static Script Find ( Type type )
128
+ {
129
+ #if UNIT_TEST_COMPILANT
130
+ throw new NotImplementedException ( "Unit tests, don't support methods calls. Only properties can be get or set." ) ;
131
+ #else
132
+ return Internal_FindByType ( type ) ;
133
+ #endif
134
+ }
135
+
118
136
#region Internal Calls
119
137
120
138
#if ! UNIT_TEST_COMPILANT
@@ -147,6 +165,9 @@ public void BreakPrefabLink()
147
165
148
166
[ MethodImpl ( MethodImplOptions . InternalCall ) ]
149
167
internal static extern void Internal_BreakPrefabLink ( IntPtr obj ) ;
168
+
169
+ [ MethodImpl ( MethodImplOptions . InternalCall ) ]
170
+ internal static extern Script Internal_FindByType ( Type type ) ;
150
171
#endif
151
172
152
173
#endregion
Original file line number Diff line number Diff line change @@ -44,6 +44,24 @@ public Transform LocalTransform
44
44
set => Actor . LocalTransform = value ;
45
45
}
46
46
47
+ /// <summary>
48
+ /// Tries to find the script of the given type in all the loaded scenes.
49
+ /// </summary>
50
+ /// <typeparam name="T">The type of the script to find.</typeparam>
51
+ /// <returns>Script instance if found, null otherwise.</returns>
52
+ #if UNIT_TEST_COMPILANT
53
+ [ Obsolete ( "Unit tests, don't support methods calls." ) ]
54
+ #endif
55
+ [ UnmanagedCall ]
56
+ public static T Find < T > ( ) where T : Script
57
+ {
58
+ #if UNIT_TEST_COMPILANT
59
+ return null ;
60
+ #else
61
+ return Internal_FindByType ( typeof ( T ) ) as T ;
62
+ #endif
63
+ }
64
+
47
65
#region Internal Calls
48
66
49
67
#if ! UNIT_TEST_COMPILANT
You can’t perform that action at this time.
0 commit comments