Hi.
I am working on a script to change a variable of a JS script through a C#
my JS:
static var counter : int = 10 + counter2;
static var counter2 : int = PlayerPrefs.GetInt("CubeCoin");
function Update(){
CubeCoin.counter = 10 + counter2;
if(CubeCoin.counter2>=0){
CubeCoin.counter2=0;
}
}
my C#
using UnityEngine;
using System.Collections;
public class CSharp2 : MonoBehaviour
{
//create a variable to access the JavaScript script
static CubeCoin jsScript;
void Awake()
{
//Get the JavaScript component
jsScript = this.GetComponent<CubeCoin>();
}
void OnGUI()
{
if (GUI.Button (new Rect (15, Screen.height-Screen.height/5, Screen.width/6, Screen.height/13), "bla")) {
jsScript.counter2 +=1;
}
}
}
but this don`t work.
i got error CS0176 Static member CubeCoin.counter2 cannot be accessed with an instance reference, qualify it with a type name instead.
how can i fix that ?
and i have to leave the variable static.