Sign up with your email address to be the first to know about new products, VIP offers, blog features & more.


You are viewing c#

Code snippets, source codes and free student project done in C#

How to save data to Google Spreadsheet from Unity 3D (No SDK – No Plugins)

Learn how to save data to Google Spreadsheet from Unity 3D to save user and game data without using any plugin or SDK. With help of this tutorial you can create survey apps, newsletter subscription and many other ideas on your Unity App without having to worry for databases. Store all the information on Google Sheet from Unity.


How to play videos on Unity using new VideoPlayer

Unity 5.6 might be released this month. Playing Videos on Unity Apps and Games was one of the most awaited update and finally Unity is working on new video player. And here’s how to play videos on Unity using new VideoPlayer.

Introduction to Unity new VideoPlayer

VideoPlayer is a new game object component for playing back movies in your scenes in Unity. It aims at using the video hardware capabilities of both the editor and target platforms

The VideoPlayer can play movies that were imported with the new VideoClip importer. It can also read movies from StreamingAssets, local files or http sources, using progressive streaming.

[Video Tutorial] on How to play videos on Unity using new VideoPlayer


How to bound gameobject within screen Unity

C# code to keep player or gameobject within the Screen view
[1] This will bound gameobject within screen unity and keep the pivot point a game object visible:

You can clamp it tighter if needed. Example:
pos.x = Mathf.Clamp(pos.x, 0.1, 0.9);
Viewport coordinates start at (0,0) in the lower left of the screen and go to (1,1) in the upper right. This code forces an object to have a viewport coordinate in the (0,0) to (1,1) range, and therefore to be on the screen.
[2] This will clamp the movement; i.e. it will feel like an invisible wall around the edges of the screen.

Just make sure this code happens after any physics movement adjustments, and you should be able to keep your rigidbody  stuff. If you encounter jitter, consider changing the code to something like this:


  • How to keep an object within the camera view?