Как использовать SDK плагина Android в единстве?Android

Форум для тех, кто программирует под Android
Ответить
Anonymous
 Как использовать SDK плагина Android в единстве?

Сообщение Anonymous »


For example, i have LiveKit SDK for Android and i need to integrate this plugin into my Unity project for android devices.
I have searched for many tutorials, but none of them had good explanation how to implement this whole SDK to my project and properly use it
In addition, i just took livekit.aar file from .gradle folder and put it in unity project
Then, I coded it like that

Код: Выделить всё

private void Start() {
AndroidJavaClass liveKit = new AndroidJavaClass("io.livekit.android.LiveKit");
devInf.text = "Found LiveKit Class";
AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity = unityPlayer.GetStatic("currentActivity");
AndroidJavaObject applicationContext = currentActivity.Call("getApplicationContext");

AndroidJavaObject room = liveKit.CallStatic("create", applicationContext);

token = PlayerPrefs.GetString("stream-token", "");
Debug.LogWarning(token);

StartCoroutine(ConnectCoroutine(room, url, token));
//Invoke("CreateRoomWithDelay", 3f);
}

IEnumerator ConnectCoroutine(AndroidJavaObject room, string url, string token) {
devInf.text = "Starting Connection";
yield return room.Call("connect", url, token);

AndroidJavaObject localParticipant = room.Call("localParticipant");

if (localParticipant != null) {
AndroidJavaObject audioTrack = localParticipant.Call("createAudioTrack");
AndroidJavaObject videoTrack = localParticipant.Call("createVideoTrack");

localParticipant.Call("publishAudioTrack", audioTrack);
localParticipant.Call("publishVideoTrack", videoTrack);

localParticipant.Call("setCameraEnabled", true);
localParticipant.Call("setMicrophoneEnabled", true);
}
}


Источник: https://stackoverflow.com/questions/781 ... k-in-unity
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Android»