{"id":15001675,"url":"https://github.com/vkcom/vk-unity-sdk","last_synced_at":"2025-10-03T12:30:42.811Z","repository":{"id":138760445,"uuid":"144011858","full_name":"VKCOM/vk-unity-sdk","owner":"VKCOM","description":null,"archived":true,"fork":false,"pushed_at":"2019-08-12T04:12:30.000Z","size":4570,"stargazers_count":20,"open_issues_count":4,"forks_count":5,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-09-28T13:24:37.466Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VKCOM.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-08T12:39:38.000Z","updated_at":"2024-04-23T13:16:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"cb5227f7-2e5b-4a54-a69a-08d7e6ee2861","html_url":"https://github.com/VKCOM/vk-unity-sdk","commit_stats":{"total_commits":3,"total_committers":2,"mean_commits":1.5,"dds":"0.33333333333333337","last_synced_commit":"784d74e3f8d934c873ac9e0a8aa0fcbe2ced7b2c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VKCOM%2Fvk-unity-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VKCOM%2Fvk-unity-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VKCOM%2Fvk-unity-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VKCOM%2Fvk-unity-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VKCOM","download_url":"https://codeload.github.com/VKCOM/vk-unity-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219876388,"owners_count":16554752,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T18:04:44.349Z","updated_at":"2025-10-03T12:30:36.395Z","avatar_url":"https://github.com/VKCOM.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# VK Unity SDK \n**VK Unity SDK** - tools wich uses VK API, implements many features to integrate your application with VK, works under Unity and created for developers who wants to quickly integrate applications. **(it uses .NET 4.6)**.\n\n## Available platforms\n\n - Android\n - WebGL\n\n## Try it!\nFor using VK Unity SDK you must install Unity since 2017.1 version. Download the latest version from [official website](https://unity3d.com/). You also need to download [VK Unity SDK](https://vk.com/dev/Unity_SDK).\nBasic unity application included in .unitypackage file. You can start it from Unity. This package consists of:\n* **VK.Unity library** which implemented tools for management API methods.\n* **VK.Unity.Editor library** which provides interaction with Unity Editor.\n* **Open sans** font\n* **Plugins** for correct interaction between platforms\n* **Executable .cs file**\n\nWhen you run the .unitypackage file, Unity will ask you to import mentioned files, you might agree this. Header menu will be include **VK** item, inside this item you can see **Edit settings** button and when you clicked on it, settings menu will be visible for you. Inside this menu you can set `API Version` and `Application ID`.\n\nMainMenu scene exists Inside **VKSDK/Examples** folder, you need to move this scene into your project. Also source code of the project you can find inside **Scripts** folder. Elements of user interface will be created automatically in programming code for MainMenu scene therefore you can just build application for platform.\n\n### WebGL. Warnings\n`Application ID` from Unity Editor which you set must be equal with IFrame application id. Our methods available only inside VK application page.\n\n\n## VKSDK Object\n### Fields\n| Field | Available on Android | Available on WebGL |\n| ------ | ------ | ------ |\n| [IsLoggedIn](#isloggedin) | + | - |\n| [IsInitialized](#docnav) | + | + |\n| [OnAccessTokenChanged](#docnav) | + | - |\n| [AppId](#docnav) | + | + |\n| [SDKVersion](#docnav) | + | + |\n| [AccessToken](#docnav) | + | - |\n| [UserId](#docnav) | + | - |\n### Functions\n| Function | Available on Android | Available on WebGL |\n| ------ | ------ | ------ |\n| [AddCallback](#docnav) | - | + |\n| [API]() | + | + |\n| [GetExtraData]() | + | + |\n| [Init]() | + | + |\n| [Login]() | + | - |\n| [Logout]() | + | - |\n| [RemoveCallback]() | - | + |\n\n#### IsLoggedIn\n\n```cs\npublic static bool IsLoggedIn\n```\nThis field contains `true` if method [Login](#login) executed successfully and `false` if not.\n**Example:**\nEnable GUI when a script is enabled. It will be done if [Login](#login) successfully finished.\n```cs\nusing UnityEngine;\nusing VK.Unity;\n\npublic class ExampleClass : MonoBehaviour {\n    void Start() {\n        GUI.enabled = VKSDK.IsLoggedIn;\n    }\n}\n```\n***\n#### IsInitialized\n\n```cs\npublic static bool IsInitialized\n```\nLike a [IsLoggedIn](#isloggedin) this filed contains `true` if [Init](#init) method successfully finished. \n**Example:**\nGetting friends list using [API](#api) method of sdk if initialization complete successfully. If you have not called [Init](#init) method before, then will be warning message.\n```cs\nusing UnityEngine;\nusing VK.Unity;\n\npublic class ExampleClass : MonoBehaviour {\n    protected void FriendsFromVK() {\n        if (VKSDK.IsInitialized) {\n            VKSDK.API(\"friends.get\", new Dictionary\u003cstring, string\u003e() { { \"order\", \"name\" } }  , (result) =\u003e\n            {\n                Debug.Log(\"Your VK friends: \" + result.ToString());\n            });\n        }\n        else\n        {\n            Debug.Warn(\"You must to run VKSDK.Init() first\");\n        }\n    }\n}\n```\n***\n#### OnAccessTokenChanged\n\n```cs\npublic static Action\u003cAccessToken\u003e OnAccessTokenChanged\n```\n***\n#### AppId\n\n```cs\npublic static long AppId\n```\nThis field contains application id you set so in unity editor.\n**Example:**\nFor example you can create link to your VK IFrame application.\n```cs\nusing UnityEngine;\nusing VK.Unity;\n\npublic class ExampleClass : MonoBehaviour {\n    private string AppLink() {\n        return \"https://vk.com/app\" + VKSDK.AppId;\n    }\n}\n```\n***\n#### SDKVersion\n\n```cs\npublic static string SDKVersion\n```\n**SDKVersion** contains current version of VK Unity SDK.\n**Example:**\nMethod writes to console information about developer and used software.\n```cs\nusing UnityEngine;\nusing VK.Unity;\n\npublic class ExampleClass : MonoBehaviour {\n    private static readonly string STARTING_YEAR = \"2018\";\n\n    private string Credits() {\n        Debug.Log(\"Application created using VK Unity SDK v\" + VKSDK.SDKVersion);\n        Debug.Log(\"Supporting by me since \" + STARTING_YEAR);\n    }\n}\n```\n***\n#### AccessToken\n\n```cs\npublic static AccessToken AccessToken\n```\nReturns you current `AccessToken` Object. This object contains fields `TokenString`, `ExpiresIn`, `UserId`. Some platforms uses access tokens to identify your application, this object stores your current access token. More about access tokens [here](https://vk.com/dev/access_token).\n**Example:**\nOur method show information about requested access token.\n```cs\nusing UnityEngine;\nusing VK.Unity;\n\npublic class ExampleClass : MonoBehaviour {\n    private string AccessTokenInfo(AccessToken at) {\n        Debug.Log(\"Token info:\");\n        Debug.Log(\"Owner`s userId: \" + at.UserId);\n        Debug.Log(\"Lifetime to: \" + at.ExpiresIn);\n    }\n}\n```\n***\n#### UserId\n\n```cs\npublic static int UserId\n```\n**UserId** contains UserId from current `AccessToken` object. Look at [AccessToken](#accesstoken) to see example.\n***\n#### AddCallback\n\n```cs\npublic static void AddCallback(string eventName, Action\u003cAPICallResponse\u003e callback = null)\n```\nLook at the [VK JavaScript SDK](https://vk.com/dev/Javascript_SDK) it's supports [adding callbacks](https://vk.com/dev/Javascript_SDK?f=4.1.%20VK.addCallback) and [removing callbacks](https://vk.com/dev/Javascript_SDK?f=4.2.%20VK.removeCallback). List of available events [here](https://vk.com/dev/Javascript_SDK?f=4.3.%20%D0%A1%D0%BF%D0%B8%D1%81%D0%BE%D0%BA%20%D1%81%D0%BE%D0%B1%D1%8B%D1%82%D0%B8%D0%B9). Supporting WebGL in Unity SDK based on our JavaScript SDK. This method adding your function as callback of one of some events, and call it when event occurs.\n**Example:**\nHere created function, wich adds callback on `onSettingsChanged`, stores callback id and gives info about event on console.\n```cs\nusing UnityEngine;\nusing VK.Unity;\n\npublic class ExampleClass : MonoBehaviour {\n    private string callbackListenerId = \"\";\n#if UNITY_WEBGL\n    private void AddCallback()\n    {\n        VKSDK.AddCallback(\"onSettingsChanged\", (result) =\u003e {\n            Debug.Log(\"Event onSettingsChanged with result: \" + result.ToString());\n            callbackListenerId = result.callbackId;\n        });\n    }\n#endif\n}\n```\n***\n#### API\n\n```cs\npublic static void API(string method, IDictionary\u003cstring, string\u003e queryParams, Action\u003cAPICallResponse\u003e callback = null)\n```\nThis method make request to VK API. Full list of methods available [here](https://vk.com/dev/methods).\n**Example:** You may check [IsInitialized](#isinitialized) which using API method.\n***\n#### GetExtraData\n\n```cs\npublic static string GetExtraData(string key)\n```\n***\n#### Init\n\n```cs\npublic static void Init(VKInitParams initParams, Action initializedCallback = null)\npublic static void Init(Action initializedCallback = null)\n```\nThis method initialize your application and makes available every SDK methods to execute.\n**Example:**\n```cs\nusing UnityEngine;\nusing VK.Unity;\n\npublic class ExampleClass : MonoBehaviour {\n    void Start() {\n        VKSDK.Init();\n    }\n}\n```\n***\n#### Login\n\n```cs\npublic static void Login(IEnumerable\u003cScope\u003e scope, Action\u003cAuthResponse\u003e callback = null)\n```\n***\n#### Logout\n\n```cs\npublic static void Logout()\n```\n***\n#### RemoveCallback\n\n```cs\npublic static void RemoveCallback(string eventName, string callbackId)\n```\n**Example:**\nThis function removes callback which has been added earlier by [AddCallback](#addcallback) function using callback id.\n```cs\nusing UnityEngine;\nusing VK.Unity;\n\npublic class ExampleClass : MonoBehaviour {\n    private string callbackListenerId = \"1\";\n#if UNITY_WEBGL\n    private void AddCallback()\n    {\n        VKSDK.RemoveCallback(\"onSettingsChanged\", callbackListenerId);\n    }\n#endif\n}\n```\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvkcom%2Fvk-unity-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvkcom%2Fvk-unity-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvkcom%2Fvk-unity-sdk/lists"}