How to find child of a GameObject or the script attached to child GameObject via script

Finding child GameObject by index: You can get the first child of a GameObject with the GetChild function. GameObject originalGameObject = GameObject.Find(“MainObj”); GameObject child = originalGameObject.transform.GetChild(0).gameObject; You can get other children by providing index number of the child GameObject such as 1,2,3, to the GetChild function. and if its a child of a child in … Read more

Convert OpenCV Mat to Texture2D?

Use SetPixels32 instead of LoadRawTextureData. Instead of returning the array data from C++, do that from C#. Create Color32 array and pin it in c# with GCHandle.Alloc, send the address of the pinned Color32 array to C++, use cv::resize to resize the cv::Mat to match the size of pixels sent from C#. You must do … Read more

Why is calling Process.killProcess(Process.myPid()) a bad idea?

<rant> In a perfect world, with perfect code and libraries, you shouldn’t need to call Process.killProcess(Process.myPid()) and the OS will correctly kill your application as appropriate. Also there will be peace in the Middle East, pigs will fly, and the halting problem will be solved. Because all of these things haven’t happened yet there are … Read more

Unity: Live Video Streaming

I ran your code and it worked sometimes and failed sometimes(about 90% of the time). It ran with on my computer with 5 FPS. This will not play well on mobile device which I am sure you are targeting iPad. There are few problems in your code but they are very serious problems. 1.Your image … Read more

Cleaning up and Backup / Migrating existing Unity project into new one or another PC

Before starting always make Backups – you never know! Cleaning Up / Migrating as a project folder In general you will always need the folders Assets: Contains all the assets like your scripts, scenes, prefabs, 3D models, textures, sounds, materials, etc ProjectSettings: Contains project settings like e.g. physics, lighting,etc Packages: Contains a manifest.json describing which … Read more

FPS camera with y-axis limit to certain angle

You have to use Mathf.Clamp to do this. Below is what I use to rotate the camera up/down and left/right. You can modify the yMaxLimit and yMinLimit variables to the angles you want to limit it to. There should be no limit while moving in the x direction. public float xMoveThreshold = 1000.0f; public float … Read more

Unity EventManager with delegate instead of UnityEvent

You can use Action which is actually a delegate declared like this: namespace System { public delegate void Action(); } 1.Replace all the UnityAction with Action from the System namespace which uses delegates. 2.Replace all thisEvent.AddListener(listener); with thisEvent += listener; 3.Replace all thisEvent.RemoveListener(listener); with thisEvent -= listener; Here is the modified version of Unity’s original … Read more