I have this problem “the type or namespace name could not be found”. (Yes, i have seen the posts in the forum, but the answers doesn’t work for me)
I have this script:
using UnityEngine;
using System.Collections;
public class Test: MonoBehaviour {
public GUISkin skin;
public GUISkin skin_menubutton;
#if UNITY_ANDROID || UNITY_IPHONE
private int fontsize;
private bool openMenu = false;
public ScoreMenu menu;
void Awake(){
}
public int clickedRed = 0;
void Update()
{
clickedRed = PlayerPrefs.GetInt("red");
Debug.Log(clickedRed);
}
//And so on...
and now I want to add “public ScoreMenu menu;” there. But I get this error: “the type or namespace name could not be found”. I have not used a namespace or anything like that. When I want to use “public Test test;” in the ScoreMenu script, it works… What could the problem be?
can we see the ScoreMenu script?
Sure. (Yes, it could be a lot better, but it works ;D)
using UnityEngine;
using System.Collections;
public class ScoreMenu : MonoBehaviour {
public PlayerCollider collided;
public Texture BackgroundTexture;
public Rect BackgroundRect;
public GUIStyle FontStyle = null;
public float BackGroundY;
public float PlusBackgroundY;
float einskommafunf = 1.5f;
public MainScore TheScore;
public int score;
public int HighScore;
Rect HighScoreRect;
public Rect ScoreRect;
public int durch;
public Font Font;
public Vector2 labelWidthv;
public float labelHeight;
public float labelWidth;
public Vector2 textDimensions;
public bool used = false;
public Texture PlayAgain;
public Texture Tryagain;
public Texture mainmenu;
public Rect PlayAgainRect;
public Rect TryRect;
public Rect mainmenuRect;
public Rect PlayAgainRect1;
public Rect TryRect1;
public Rect mainmenuRect1;
public Rect hintergrundRect;
public Texture hintergrund;
// Use this for initialization
void Start () {
BackGroundY = 0 - Screen.height / 2;
ScoreF = Screen.height + Screen.height / 2 - ScoreVect.y;
HighScoreF = Screen.height + Screen.height / 2 + HighScoreVect.y;
ScoreSF = Screen.height + Screen.height / 2 - ScoreVect.y - ScoreVect.y;
HighScoreSF = Screen.height + Screen.height / 2;
}
public float z = 1.2f;
// Update is called once per frame
void Update () {
hintergrundRect = new Rect(Screen.width / 2 - Screen.width / z / 2, Screen.height / 2 - Screen.height / z / 2, Screen.width / z, Screen.height / z);
CalcRect();
HighScore = PlayerPrefs.GetInt("HighScore");
score = TheScore.scoreI;
if (collided.collided)
{
if (BackGroundY <= Screen.height / 4)
{
BackGroundY += PlusBackgroundY;
}
if (BackGroundY >= Screen.height / 4)
{
BackGroundY = Screen.height / 4;
used = true;
}
}
BackgroundRect = new Rect(Screen.width / 4, BackGroundY, Screen.width / 2, Screen.height / 2);
//new Rect ()
}
public float x = 10f;
void CalcRect()
{
if (collided.collided)
{
Touch();
mainmenuRect = new Rect(Screen.width / 3 - Screen.width / x / 2, Screen.height / 5 * 4 - Screen.width / x / 2, Screen.width / x, Screen.width / x);
//and so on...
scoremenu isn’t throwing any errors? it’s saved?
Yes, it works fine. But ScoreMenu is just an example. I can use “public Test test;” in every script. But in Test I can’t access any other one…