I believe an option available to you is to use std smart pointers, more specifically the std::shared_ptr and std::weak_ptr.
Typically, those pointers represent ownership. They also offer a ref-counting mechanism, and I think it's this feature that you're after.
std::shared_ptrs hold a reference to a dynamically allocated object, a count of "hard" ...
This sets GameObjects' visibility by name by enabling/disabling their MeshRenderer:
static public class Utility
static public void SetVisible(string name, bool visibility = true)
GameObject.Find(name).GetComponent<MeshRenderer>().enabled = visibility;
This makes the game object named "AnitaBath" visible by ...
GetComponentInChildren traverses the whole object tree below an object using a depth-first search until it finds the first component of the requested type and returns it. I would not advise to use that method unless you are in a situation where you are certain that there is only one child with that component and there will never be a reason to add a second ...
Here is an easy solution for how you get it styled right and working without any need to write extra code.
create the Image/ Tooltip you want as a child of your element that should have the tooltip.
disable the element
attach a Event Trigger component to your ui element that should have the tooltip
add new event type: PointerEnter
select your component that ...
This sets GameObjects' visibility by name by activating/deactivating them:
public class Utility : MonoBehaviour
static Dictionary<string, GameObject> gameObjects;
public void Awake()
gameObjects = new Dictionary<string, GameObject>();
foreach (var o in ...
A List<string> is all well and good if you just want names. But you don't want to delete the name, you want to delete the game object.
Also, if you always want to delete from the start of the collection (First-In, First-Out), and you don't need to traverse or randomly access items in the collection, then the structure you want is a Queue.
Thanks to the helpful input from @DMGregory, I have managed to solve this problem.
I added the "Volume" component to the Camera, then I created a new profile. I then added the "Exposure" override, which resulted in the appearance of two shaded out options, Mode and Fixed Exposure. Clicking on the checkbox to the left activated the options allowing me to set ...
I would suggest two different ways of solving your problem. One close to your current implementation and another more abstract concept, but that is easier to use in the long run.
First the simple changes. If i understand it correctly, your roles are all subclasses from
objectclass. Since objectdoesnt have the onDraw-method, you cant just add it to the ...
It looks like you're using the variable named star to do double-duty:
var star = new Star();
This says "make a new data structure to hold information about this star"
star = Instantiate(ObjectStar, ...);
This says "make a new copy of the ObjectStar game object to represent this star in the game scene, and give me its Transform (since the ObjectStar ...
I think there is a way around this. If I am getting your question right, you want your prefab's public variables to have objects reference from the scene. What you can do is make prefab instances particularly for that scene. Which means
you can drag and drop you prefab in hierarchy.
Unpack the Prefab object in hierarchy
Now attach the references of other ...