Various Scripts and Application Code Segments for .NET, VB, C#, C++, C, Java, JavaScript, HTML, Python, Perl, AutoIT, Batch, ASP Classic, Objective-C, Swift, Unreal Engine 4, Unity3D & others. Also contains numerous IT tidbits, procedures, and tricks including Technology Hacks on various platforms.
In Objective-C / Cocoa to grab a substring from an NSString based on beginning and ending characters is easy. This is helpful if you want to parse HTML, JSON, or a REST statement returning. See below:
With this simple coding you can play a playlist on your device from your Unity3D Game. Why license royalties when you can get the user to do it for you per individual basis. I am using this in my game Snowboarding+ (see gameplay demo above). If there is no music on your device it'll finally play the local music in your Unity 3D app. This plays the playlist called Snowboarding+
in AppController.mm (also add MediaPlayer.framework):
This segment is for simple movement for a player in an Air Hockey Game on a 3D plane. You move mouse x and y and the y corresponds on the z plane. This is from my Air Hockey 3D game available currently in the Android, iOS and Mac App Stores.
var other : GameObject ; var dist : float; var hitSound : AudioClip; var spark : Transform; var offset : Vector2 = Vector2.zero; function spark1() { Instantiate (spark, transform.position, transform.rotation); yield WaitForSeconds(0.5); Destroy(GameObject.Find("Sparks(clone)")); } function Update () { if (Time.timeScale != 0) { other = GameObject.Find ("Sphere"); var Menu = GameObject.Find("Menu"); var script : menu = Menu.GetComponent(menu); var hit : RaycastHit; var up = Vector3 ((transform.position.x - other.transform.position.x) * -1 , 0, (transform.position.z - other.transform.position.z) * -1 );