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

How to find the size of Object and show it on screen [closed]

You can get your object size like this: public double GetObjectSize(Object Obj) { using (var m = new System.IO.MemoryStream()) { System.Runtime.Serialization.Formatters.Binary.BinaryFormatter b = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); b.Serialize(m, Obj); double size = Convert.ToDouble(m.Length); return size; } } But consider that not all objects are serializable. And it will not serialize nested objects too deep.