-
Force Unity to scroll to the bottom of a scroll rect
So, I’ve got a textbox (TextMeshPro) with a load of text in it. As the game progresses, I add more text to the textbox and I want the user to see the bottom of the text (the last bit added)… /// <summary> /// Add text to the panel at the bottom of the screen ///…
-
Unity: DllNotFoundException: openvr_api
In my case, this was caused by having a VR project that I was running on a new version of Unity (2018.3.0f2) without having the OpenVR package installed. Easy fix: Open the Package Manager (Window->Package Manager), select “OpenVR” in the package list and click install. Restart Unity
-
C#: Counting specific characters in a string
Quick and simple: – var count = mrString.Count(x => x == ‘$’)
-
.NET: Deserializing XML
Quick example of deserializing a chunk of XML into a set of classes: – <?xml version=”1.0″ encoding=”UTF-8″?> <!– Parser configuration control XML –> <parserConfig version=”1.0″> <parsers> <!– Test–> <parse count=”6″ output=”[0][3] = [5];”> <checks> <check index=”0″ type=”whiteSpace” /> <check index=”1″ type=”alphaNumeric” content=”test”/> <check index=”2″ type=”whiteSpace” /> <check index=”3″ type=”alphaNumeric” /> <check index=”4″ type=”separator” /> <check…
-
Unity: Get all scene names
Quick code snippet to grab all scene names in a project: – public List<string> scenes; int sceneCount = UnityEngine.SceneManagement.SceneManager.sceneCountInBuildSettings; for (int i = 0; i < sceneCount; i++) { string sceneName = System.IO.Path.GetFileNameWithoutExtension(UnityEngine.SceneManagement.SceneUtility.GetScenePathByBuildIndex(i)); scenes.Add(sceneName); Debug.Log(“Scene: ” + sceneName); }
-
OpenGL Version Information
How to read the version information from OpenGL: – int[] OpenGLMajorVersion = new int[1]; gl.GetInteger(OpenGL.GL_MAJOR_VERSION, OpenGLMajorVersion); int[] OpenGLMinorVersion = new int[1]; gl.GetInteger(OpenGL.GL_MAJOR_VERSION, OpenGLMinorVersion); Console.WriteLine(“OpenGL Version: ” + OpenGLMajorVersion[0] + “.” + OpenGLMinorVersion[0]);
-
Another game released…
Just completed this one for Verizon. Link here
-
C#: Distance from a ray to a point
Nice little piece of code found here public static float DistanceToLine(Ray ray, Vector3 point) { return Vector3.Cross(ray.direction, point – ray.origin).magnitude; }
-
Disable Cache on Google Chrome
It took a while to nail this down. There are a few plug-ins for Google Chrome but, from looking at various forum posts, they seem to be unreliable. I eventually ended up running Google Chrome with two command line options as follows: – –disk-cache-dir=null –disk-cache-size=0 I’ve been using this for a while now, and it…
-
JavaScript: string replace
Another quick code snippet showing how to replace a piece of a string with an alternate string: – var myString = “development environment”; myString = myString.replace(“development”, “release”);
