Skip to main content

Posts

Showing posts from July, 2015

How to create line graph in unity

Hi guys, previously i have shown how you can create Bar_Graph in unity, after successfully showing bar graph in unity i fell in love with graphs, so when i was asked to show data on a line graph, i got excited and came up with this solution, its almost similar to the bar graph, but this time i have made it more reliable and dynamic.

this is how my setup looks like :




I have an orthographic camera in my scene, which only renders a layer i namded "GUI". and every gameobject in the graph are in "GUI" layer.

why orthographic camera ? its because they easily adjust according to different screen resolutions, i have also used textMesh to show the numbers in graph, which again is the best option if you want to show text in 3d space.


here is a view, how the final graph looks like with data :






in the above image you can see that i am showing data for 99 turns,  but in this small space i cant show data for all the 99 turns, so what i did is i made a dynamic function which give…

Save data to custom PlayerPrefs using xml in Unity

Hello guys!

few months back i did  a project which need to save data in local, so i used PlayerPrefs but soon i realised that PlayerPrefs cant save more than 1mb of data, you can check the game here in this link http://bit.ly/1KhjTsx .

So to cross that 1 mb barrier, i started to find a simple solution which is as flexible and as simple as unity’s default PlayerPrefs.

I choose xml to save data, my class also have functions Like SetFloat(), SetInt(), SetString(), GetFloat(), GetInt() and GetString().



You can find all the functions in PlayerPrefXml class.

To save a Int variable you just need to call
PlayerPrefXml.Ins.SetInt("Speed",10);
To save a String variable you just need to call
PlayerPrefXml.Ins.SetString("Name","Sam");
To save a Float variable you just need to call
PlayerPrefXml.Ins.SetFloat("Velocity",20.22f);

To get a Int variable you just need to call
intx = PlayerPrefXml.Ins.GetInt("Speed");
To get a String variable you just need to…