I get an error, Assets\scripts\Skins.cs(9,12): error CS0116: A namespace cannot directly contain members such as fields or methods
on the Internet they write what it means incorrectly placed brackets, but I don’t see any errors
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public GameObject choise1;
public GameObject choise2;
public GameObject choise3;
public int skin = 1;
public class Skins : MonoBehaviour {
void Choise () {
if (Input.GetMouseDown(choise1)){
choise2.SetActive (false);
}
}
}
CodePudding user response:
GameObject and that int skin need to be under Skins class, like Choise
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Skins : MonoBehaviour {
public GameObject choise1;
public GameObject choise2;
public GameObject choise3;
public int skin = 1;
void Choise () {
if (Input.GetMouseDown(choise1)){
choise2.SetActive (false);
}
}
}
If you still have some problems here, because I don't know what are u trying to do with that choiseX, maybe you need to create them. I mean, maybe u are trying to write something like this
void Choise () {
var GameObject choise1 = new GameObject();
var GameObject choise2 = new GameObject();
var GameObject choise3 = new GameObject();
int skin = 1;
if (Input.GetMouseDown(choise1)){
choise2.SetActive (false);
}
}