Using Resources Folder in Unity

You can’t read the Resources directory with the StreamReader or the File class. You must use Resources.Load. 1.The path is relative to any Resources folder inside the Assets folder of your project. 2.Do not include the file extension names such as .txt, .png, .mp3 in the path parameter. 3.Use forward slashes instead of back slashes … Read more

Using new Unity VideoPlayer and VideoClip API to play video

Found the problem. Below is the FIXED code that plays Video and Audio: //Raw Image to Show Video Images [Assign from the Editor] public RawImage image; //Video To Play [Assign from the Editor] public VideoClip videoToPlay; private VideoPlayer videoPlayer; private VideoSource videoSource; //Audio private AudioSource audioSource; // Use this for initialization void Start() { Application.runInBackground … Read more

What is the best way to save game state?

But I heard this way has some issues and not suitable for save. That’s right. On some devices, there are issues with BinaryFormatter. It gets worse when you update or change the class. Your old settings might be lost since the classes non longer match. Sometimes, you get an exception when reading the saved data … Read more

How to detect click/touch events on UI and GameObjects

You don’t use the Input API for the new UI. You subscribe to UI events or implement interface depending on the event. These are the proper ways to detect events on the new UI components: 1.Image, RawImage and Text Components: Implement the needed interface and override its function. The example below implements the most used … Read more

Serialize and Deserialize Json and Json Array in Unity

Unity added JsonUtility to their API after 5.3.3 Update. Forget about all the 3rd party libraries unless you are doing something more complicated. JsonUtility is faster than other Json libraries. Update to Unity 5.3.3 version or above then try the solution below. JsonUtility is a lightweight API. Only simple types are supported. It does not … Read more

UNITY: Google Play Authentication failed when download from Google Play store

Thanks Github issues, I had finally solve the solution. The problem is happen with Google app sign in. From https://github.com/playgameservices/play-games-plugin-for-unity/issues/1754#issuecomment-304581707 What I did: Google Play Console -> Select your app -> Release Management -> App signing -> App signing certificate : copy SHA-1 (dont copy word ‘SHA1:’) open console.developers.google.com , select your project -> credentials … Read more

tech