public CastRemoteDisplayUnityExtension(CastRemoteDisplayExtensionManager extensionManager, CastRemoteDisplaySimulator displaySimulator) { this.extensionManager = extensionManager; this.displaySimulator = displaySimulator; this.displaySimulator.DisplayExtension = this; }
public override void OnInspectorGUI() { CastRemoteDisplaySimulator simulator = (CastRemoteDisplaySimulator)target; serializedObject.Update(); EditorGUILayout.PropertyField(serializedObject.FindProperty("simulateRemoteDisplay"), true); EditorGUILayout.PropertyField(serializedObject.FindProperty("remoteDisplayRect"), true); EditorGUILayout.PropertyField(serializedObject.FindProperty("castDevices"), true); serializedObject.ApplyModifiedProperties(); if (Application.isPlaying) { // Update the list of devices. if (GUILayout.Button("Update devices")) { simulator.UpdateDevices(); } EditorGUILayout.Space(); // Throwing errors. errorCode = (CastErrorCode)EditorGUILayout.EnumPopup("Throw Error", errorCode); if (errorCode != CastErrorCode.NoError) { if (GUILayout.Button("Throw")) { simulator.ThrowError(errorCode); } } } }
/** * Enforces uniqueness of the DisplaySimulator. */ void Awake() { if (instance) { Debug.LogWarning("CastRemoteDisplaySimulator: Duplicate simulator found - destroying."); DestroyImmediate(gameObject); return; } else { instance = this; DontDestroyOnLoad(gameObject); } }
/** * Sets everything up and starts discovery on the native extension. */ private void Activate() { Debug.Log("Activating Cast Remote Display."); if (CastRemoteDisplayManager == null) { Debug.LogError("FATAL: CastRemoteDisplayManager script not found."); return; } if (CastRemoteDisplayManager.CastAppId == null || CastRemoteDisplayManager.CastAppId.Equals("")) { Debug.LogError("FATAL: CastRemoteDisplayManager needs a CastAppId"); return; } if (CastRemoteDisplayManager.Configuration == null) { Debug.LogError("FATAL: CastRemoteDisplayManager has null configuration"); return; } #if UNITY_ANDROID && !UNITY_EDITOR castRemoteDisplayExtension = new CastRemoteDisplayAndroidExtension(this); #elif UNITY_IOS && !UNITY_EDITOR castRemoteDisplayExtension = new CastRemoteDisplayiOSExtension(this); #elif UNITY_EDITOR CastRemoteDisplaySimulator displaySimulator = UnityEngine.Object.FindObjectOfType <CastRemoteDisplaySimulator>(); if (displaySimulator) { castRemoteDisplayExtension = new CastRemoteDisplayUnityExtension(this, displaySimulator); } #endif if (castRemoteDisplayExtension != null) { castRemoteDisplayExtension.Activate(); #if !UNITY_IOS && !UNITY_EDITOR // Non iOS platforms can render using RenderRemoteDisplayCoroutine. StartCoroutine(RenderRemoteDisplayCoroutine()); #endif // Update the list of cast devices in case we missed updates from the native lib while this // object was deactivated. UpdateCastDevicesFromNativeCode(); } else { Debug.LogWarning("Disabling the CastRemoteDisplayManager because the platform is not " + "Android or iOS, and no simulator is found."); } }