Looking through walls (Unity-based C#)

Posts 111 of 11 · Page 1 of 1
Looking through walls (Unity-based C#)
So if you can run unity-based code inside Rust, you can do some neat things, like in-game menus.
This code snippet for example allows to quickly analyze buildings to detect weak points.

Unity C# Code

Code:
                object[] allObjects = Resources.FindObjectsOfTypeAll(typeof(GameObject));
                ArrayList all = new ArrayList();
                foreach (object thisObject in allObjects)
                {
                    if (((GameObject)thisObject).activeInHierarchy)
                    {
                        GameObject obj = (GameObject)thisObject;
                        if (obj.name == "WoodWall(Clone)" || obj.name == "WoodDoorFrame(Clone)" || obj.name == "WoodCeiling(Clone)")
                        {
                            all.Add(obj);
                            obj.SetActive(false);
                        }
                    }
                }
                allHidden = all.ToArray(typeof(GameObject)) as GameObject[];
What it looks like

Before:


After:
Nice, fixed screenies for you.
Agreed; there's a lot of cool things you can do once you get your own assemblies loaded into Rust. Modding is so much easier not having to go through Reflexil aside from setting up your function hooks. I've been playing with it for a few weeks now.

To avoid using GameObject and name checks, you can use the actual types for those structure objects:

Code:
foreach (StructureComponent obj in UnityEngine.Object.FindObjectsOfType(typeof(StructureComponent)))
{
	if (obj.type == StructureComponent.StructureComponentType.Wall || 
	    obj.type == StructureComponent.StructureComponentType.Doorway || 
	    obj.type == StructureComponent.StructureComponentType.Ceiling)
	{
		if(obj.gameObject != null && obj.gameObject.activeInHierarchy)
		{
			obj.gameObject.SetActive(false);
		}
	}
}
I've been playing with shaders and labeling the structure components for experimental raiding tools, but the really large bases pose some issues with depth and figuring out the best way to go about it. I've come across bases with so many doors that when using the text gui shader, the entire thing is pretty much white.

I think the best option, and probably coolest, would be to make a second camera that you control that can just move around the base itself so you can see the layout first hand. Attached is an image of something I was playing with tonight, but for a different purpose. I'm working on setting up the camera and changing the terrain settings to be able to make my own external minimap.

Anyways though, nice share! I'm still learning Unity and whatnot, but I didn't think about disabling the walls to see through them. I was trying to look into using shaders to render them transparently, but this works much better and is a lot easier to implement.
Screenshot 2014-02-01 03.24.16.jpg206 KB · 233 downloads
Great, your code is much cleaner thanks for posting. Yea a second camera could work, but the internal camera code is pretty heavy (lots of manual camera control/rendering) so its possible to run into some issues. Ever tried changing FOV? You will see what I mean.
so uhm, about that tutorial? how do i use this lmao
Quote Originally Posted by noVaee View Post
so uhm, about that tutorial? how do i use this lmao
Learn C# and make a hack
You try to put this code somewhere into Assembly-CSharp (together with Oxidizer), that might be the easiest way. My own menu is injected.
Quote Originally Posted by HackRust View Post
You try to put this code somewhere into Assembly-CSharp (together with Oxidizer), that might be the easiest way. My own menu is injected.
Noob aleart,

How do you get the files. i have the source from .net refractor, but how do i compile it. theres about a million errors? am i doing something wrong please tell me.
Hey guys i'm trying to write my own hack using reflexil, I use the "replace all with code..." option, but when I try to compile it throws error CS1703, saying somthing about referencing mscorlib twice. I'm a noob so i dont know much about references, anybody got a fix for this?
hey how do i edit the assets?
Im a good programmer, ive made a few hacks for rust in the assets, but when i edit that stuff it dosnt let me compile it. how do i inject the .cs?
Posts 111 of 11 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?