choosing the path in Resources.Load

Is there a way i can choose where the Orange_Object and Red_Object are being Loaded?

    private void OnTriggerStay2D(Collider2D collision)
    {
        string thisGameobjectName;

        string collisionGameobjectName;

        thisGameobjectName = gameObject.name.Substring(0, name.IndexOf("_"));

        collisionGameobjectName = collision.gameObject.name.Substring(0, name.IndexOf("_"));

        if (mouseButtonReleased && thisGameobjectName == "Yellow" && thisGameobjectName == collisionGameobjectName)
        {
            Instantiate(Resources.Load("Orange_Object"), transform.position, Quaternion.identity);
            mouseButtonReleased = false;
            Destroy(collision.gameObject);
            Destroy(gameObject);
        }
        else if (mouseButtonReleased && thisGameobjectName == "Orange" && thisGameobjectName == collisionGameobjectName)
        {
            Instantiate(Resources.Load("Red_Object"), transform.position, Quaternion.identity);

            mouseButtonReleased = false;
            Destroy(collision.gameObject);
            Destroy(gameObject);
        }
    }

I don’t understand the question. Do you have multiple folders in your Resource folder?

Wow, you want to get away from that kinda coding!!

If you have more than one or two dots (.) in a single statement, you’re just being mean to yourself.

How to break down hairy lines of code:

http://plbm.com/?p=248

Break it up, practice social distancing in your code, one thing per line please.

I would also HIGHLY recommend not doing all the string character flicking… this is 2022, not 1990. Code like the above is extremely fragile and fails in very non-obvious ways.

Instead, stick a tag on it if that suffices, or else put a MonoBehaviour on things you need to later identify. Either have a generic identifier kinda monobehaviour with a value inside it you recognize or need, or else make specific MonoBehaviours to identify different things you care about.

“Programming is hard enough without making it harder for ourselves.” - angrypenguin on Unity3D forums