33 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			33 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C#
		
	
	
	
|  | using UnityEngine; | |||
|  | 
 | |||
|  | namespace EFSDK | |||
|  | { | |||
|  |     public static class AutoSetEFSdk | |||
|  |     { | |||
|  |         [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] | |||
|  |         public static void SetupCommunicationObject() | |||
|  |         { | |||
|  |             try | |||
|  |             { | |||
|  |                 GameObject communicationObject = new GameObject("EFSdkAndroid"); | |||
|  |                 if (communicationObject != null) | |||
|  |                 { | |||
|  |                     EFSdkAndroid communicationComponent = communicationObject.AddComponent<EFSdkAndroid>(); | |||
|  |                     if (communicationComponent == null) | |||
|  |                     { | |||
|  |                         Debug.LogError("Failed to add EFSdkAndroid component to the GameObject."); | |||
|  |                     } | |||
|  |                     Object.DontDestroyOnLoad(communicationObject); | |||
|  |                 } | |||
|  |                 else | |||
|  |                 { | |||
|  |                     Debug.LogError("Failed to create the EFSdkAndroid GameObject."); | |||
|  |                 } | |||
|  |             } | |||
|  |             catch (System.Exception e) | |||
|  |             { | |||
|  |                 Debug.LogError($"An error occurred while setting up the communication object: {e.Message}"); | |||
|  |             } | |||
|  |         } | |||
|  |     } | |||
|  | } |