Make builtin object invisible through a script?

urukyay

Well-known member
Featured Contributor
Messages
52
Reactions
347
Points
53
Hi, I have a script that creates several Capsule and Sphere objects, and I'd like a way to make them invisible, but still active in the scene.

What I've tried already is to GetComponent<Renderer> on the atoms, and their gameobjects and set the renderer.enable to false, which only works on the spheres weirdly. I can't make heads or tails of the materials or what to access from where, or anything like that :(

Basically, the same as setting their material Alpha Adjust to -1, or enabling "Hide Material" from the shader tab in material options, but from within a script.

How do I do that? I'm not very familiar with unity, and the VaM codebase is quite large, and I don't know where to begin to look for this ... Nor could I find any existing plugin that looked adjacent to what I want to peep into. The ones that alter textures do so on full characters which don't seem relevant to simple objects ...
 
Can you elaborate more what you are trying to do? Would using an "Empty" atom work?

Anyway, disabling the renderer should do it, though. If it doesn't work, maybe the Renderer is not where you think it is or there are multiple. AcidBubbles has a GameObjectExplorer plugin which sounds helpful in this case, although I have not tried it myself, yet. https://hub.virtamate.com/resources/dev-tools.171/
 
Thanks, I will try searching with the gameObjectExplorer, it looks very useful.

I'm trying to make a plugin that creates several spheres and capsules (the builtin atoms), because they have functioning gpu colliders in them, tweak the colliders, and attach the objects to bones on a male character, so that I can make and use sim-enabled clothes.

It's working ok so far for something this hodgepodgey, and the overhead is quite small, but I have to disable the material on each and every one of these objects by hand.
 
In unity the Transform is treated as the container for the game object.

transform.gameObject.SetActive(false);

is how you deactivate a unity gameobject.

GetComponentInParent<Transform>().gameObject.SetActive(false);

can be used if the object is nested, it will access the transform of the parent object (or the invoker if there is no parent)

GetComponentInParentS<T>()

will give you a list of every component found in the parent(s)

If you are trying to access a built in object, or something your script isn't attatched to, you can try

GameObject.Find("ObjectName");

GameObject.FindGameObjectsWithTag("ObjectTag");

If you don't have the name or the tag you can STILL find a game object you're looking for in the scene by process of elimination, if you know what components the object has (especially useful if they have unique components)

I'm not sure but I think the names you can put in for game objects in VAM are the names unity uses for GameObject.Find because they use the same automated numbering scheme for duplicates... so this is probably a good bet.

Just remember if you're finding objects by names, the whole script can break if those names get changed.
 
Last edited:
Back
Top Bottom