using System. Collections ;
using System. Collections. Generic ;
using Unity. XR. CoreUtils ;
using UnityEditor ;
using UnityEngine ; public class AutoDetectScript : MonoBehaviour
{ public GameObject[ ] games; [ ContextMenu ( "一键挂载脚本" ) ] public void UpScript ( ) { for ( int i = 0 ; i < games. Length; i++ ) { GameManager manager = games[ i] . transform. GetChild ( 0 ) . gameObject. GetOrAddComponent < GameManager> ( ) ; manager. LoopTime = 1 ; manager. tagMat = AssetDatabase. LoadAssetAtPath < Material> ( "Assets/Scripts/sahn.mat" ) ; } }
}
public static class CustomExtension
{ public static T GetOrAddComponent < T> ( this GameObject obj) where T : Component { var com = obj. GetComponent < T> ( ) ; if ( com != null ) { return com; } else { com = obj. AddComponent < T> ( ) ; return com; } }
}