@@ -873,27 +873,20 @@ public static void ReattachSelf(RectTransform trans, ReattachCallback callback)
873873 }
874874
875875 /// <summary>
876- /// Retrieves the first active loaded object of Type type .
876+ /// Spwan a game object to another scene .
877877 /// </summary>
878- public static Object FindObjectByType ( System . Type type )
878+ /// <param name="original"> The original game object. </param>
879+ /// <param name="scene"> The target scene </param>
880+ /// <returns> Return the newly spawned game object. </returns>
881+ public static GameObject InstantiateToScene ( GameObject original , Scene scene )
879882 {
880- #if UNITY_2023_1_OR_NEWER
881- return UnityEngine . Object . FindFirstObjectByType ( type ) ;
882- #else
883- return UnityEngine . Object . FindObjectOfType ( type ) ;
884- #endif
885- }
883+ GameObject newObj = MonoBehaviour . Instantiate ( original ) ;
886884
887- /// <summary>
888- /// Retrieves a list of all loaded objects of Type type.
889- /// </summary>
890- public static Object [ ] FindObjectsByType ( System . Type type )
891- {
892- #if UNITY_2023_1_OR_NEWER
893- return UnityEngine . Object . FindObjectsByType ( type , FindObjectsSortMode . None ) ;
894- #else
895- return UnityEngine . Object . FindObjectsOfType ( type ) ;
896- #endif
885+ RemoveCloneString ( newObj ) ;
886+
887+ SceneManager . MoveGameObjectToScene ( newObj , scene ) ;
888+
889+ return newObj ;
897890 }
898891
899892 /// <summary>
@@ -1009,6 +1002,30 @@ public static string RemoveCloneString(GameObject obj)
10091002
10101003 #region Finding
10111004
1005+ /// <summary>
1006+ /// Retrieves the first active loaded object of Type type.
1007+ /// </summary>
1008+ public static Object FindObjectByType ( System . Type type )
1009+ {
1010+ #if UNITY_2023_1_OR_NEWER
1011+ return UnityEngine . Object . FindFirstObjectByType ( type ) ;
1012+ #else
1013+ return UnityEngine . Object . FindObjectOfType ( type ) ;
1014+ #endif
1015+ }
1016+
1017+ /// <summary>
1018+ /// Retrieves a list of all loaded objects of Type type.
1019+ /// </summary>
1020+ public static Object [ ] FindObjectsByType ( System . Type type )
1021+ {
1022+ #if UNITY_2023_1_OR_NEWER
1023+ return UnityEngine . Object . FindObjectsByType ( type , FindObjectsSortMode . None ) ;
1024+ #else
1025+ return UnityEngine . Object . FindObjectsOfType ( type ) ;
1026+ #endif
1027+ }
1028+
10121029 /// <summary>
10131030 /// Find all the objects that are clone in the scene by type.
10141031 /// </summary>
@@ -1285,9 +1302,9 @@ public static float GetLayerWeight(Animator ator, int index)
12851302 /// default `spatialBlend` value.
12861303 /// </summary>
12871304 public static void PlayClipAtPoint (
1288- AudioClip clip ,
1289- Vector3 position ,
1290- float volume ,
1305+ AudioClip clip ,
1306+ Vector3 position ,
1307+ float volume ,
12911308 float spatialBlend )
12921309 {
12931310 var gameObject = new GameObject ( "One shot audio" ) ;
0 commit comments