- Home /
when we double click any button this is error occurring, where is the error
This is the error occurring :-
NullReferenceException: (null) UnityEngine.MonoBehaviour.StopCoroutine (UnityEngine.Coroutine routine) (at C:/buildslave/unity/build/artifacts/generated/common/runtime/MonoBehaviourBindings.gen.cs:99)
This is the Code :-
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Test : MonoBehaviour {
public GameObject Testobject;
public GameObject Main_Menu;
public Material[] TestShaders;
public Texture[] TestTextures;
public Texture[] TestPatterns;
public Color[] TestColors;
int m;
//To Change Menus
public void Change_Menus(int x)
{
for (int y = 1; y < Main_Menu.transform.childCount; y++)
{
Main_Menu.transform.GetChild(y).gameObject.SetActive (false);
}
Main_Menu.transform.GetChild (x).gameObject.SetActive (true);
x = m;
}
//To Function Shader
public void Function_Shader_Menus(int x)
{
Testobject.GetComponent<Renderer> ().material = TestShaders[x];
}
//To Function Texture
public void Function_Texture_Menus(int x)
{
Testobject.GetComponent<Renderer> ().material.mainTexture = TestTextures[x];
}
//To Function Pattern
public void Function_Pattern_Menus(int x)
{
Testobject.GetComponent<Renderer> ().material.mainTexture = TestPatterns[x];
}
//To Function Pattern Color
public void Function_Pattern_Color_Menus(int x)
{
Testobject.GetComponent<Renderer> ().material.color = TestColors[x];
}
}
Answer by OneCept-Games · Jan 03, 2018 at 03:53 PM
May not be in the code you have attached. It seems like a Coroutine is broken, but you are not using Coroutines in this snippet. Try not to SetActive(false) in your loop, Debug.Log you x and y values and compare with what you have initiated them with. This is my best advice based on the provided information.
Answer by HUNTERSUBBU · Jan 04, 2018 at 08:35 AM
Thanks Bro for the quick response. I figured out though using VRTK, It was a code error in VRTK UI canvas.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Please Help Me With My Stamina Bar! 1 Answer
Distribute terrain in zones 3 Answers
Scaling RectTransform to fit screen size in code 1 Answer
SetBool and SetTrigger not work on UI button click in unity 0 Answers