Skip to main content
deleted 8 characters in body
Source Link

I have other code that uses this same kind of format but for some reason this one is not working. Is there a specific reason why? It is connected to a game object and if I were to not use the if statement then it would work but I don't see why the if statement would be an issue.

The code is being used to close and open a Raw Image element that is nested within another Canvas.

using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

public class Invetory : MonoBehaviour
{
    void Update()
    {
        if (Input.GetKeyDown("Q"))
            this.gameObject.active = true;
    }
}

I have other code that uses this same kind of format but for some reason this one is not working. Is there a specific reason why? It is connected to a game object and if I were to not use the if statement then it would work but I don't see why the if statement would be an issue.

The code is being used to close and open a Raw Image element that is nested within another Canvas.

using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

public class Invetory : MonoBehaviour
{
    void Update()
    {
        if (Input.GetKeyDown("Q"))
            this.gameObject.active = true;
    }
}

I have other code that uses this same kind of format but for some reason this one is not working. Is there a specific reason why? It is connected to a game object and if I were to not use the if statement then it would work but I don't see why the if statement would be an issue.

The code is being used to close and open a Raw Image element that is nested within Canvas.

using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

public class Invetory : MonoBehaviour
{
    void Update()
    {
        if (Input.GetKeyDown("Q"))
            this.gameObject.active = true;
    }
}
I explained the situation a little bit better.
Source Link

I have other code that uses this same kind of format but for some reason this one is not working. Is there a specific reason why? It is connected to a game object and if I were to not use the if statement then it would work but I don't see why the if statement would be an issue.

The code is being used to close and open a Raw Image element that is nested within another Canvas.

using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

public class Invetory : MonoBehaviour
{
    void Update()
    {
        if (Input.GetKeyDown("Q"))
            this.gameObject.active = true;
    }
}

I have other code that uses this same kind of format but for some reason this one is not working. Is there a specific reason why? It is connected to a game object and if I were to not use the if statement then it would work but I don't see why the if statement would be an issue

using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

public class Invetory : MonoBehaviour
{
    void Update()
    {
        if (Input.GetKeyDown("Q"))
            this.gameObject.active = true;
    }

I have other code that uses this same kind of format but for some reason this one is not working. Is there a specific reason why? It is connected to a game object and if I were to not use the if statement then it would work but I don't see why the if statement would be an issue.

The code is being used to close and open a Raw Image element that is nested within another Canvas.

using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

public class Invetory : MonoBehaviour
{
    void Update()
    {
        if (Input.GetKeyDown("Q"))
            this.gameObject.active = true;
    }
}
Source Link

Why isn't my code running?

I have other code that uses this same kind of format but for some reason this one is not working. Is there a specific reason why? It is connected to a game object and if I were to not use the if statement then it would work but I don't see why the if statement would be an issue

using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

public class Invetory : MonoBehaviour
{
    void Update()
    {
        if (Input.GetKeyDown("Q"))
            this.gameObject.active = true;
    }