1: The class is nested, in which case you’ll have to see ContainerClass.ContainedClass.
2: The class is in a different namespace. Solution same as above or “using Namespace” at top.
3: Restart Unity / the editor you use- sometimes it just happens inexplicably.
Also make sure all of the scripts are saved and that there are no errors.
I don’t think the list being empty would be a possibility, as it would still have the normal object-inherited static methods like Equals()…
A nested class is just a class that’s defined within another class (also called an “inner class”), for instance:
public class SomeContainer
{
public class SomeContained
{
}
}
In a case like this, in order to access SomeContained, you have to do so with SomeContainer.SomeContained. It’s important to note that other than the naming convention, there’s little practical correlation between the two. A SomeContained class created from within the SomeContainer class isn’t going to have any knowledge of the SomeContainer class that it wouldn’t always have if it weren’t nested. Doing things this way is purely organizational, unless you make the inner class private, in which case the outer class is the ONLY class that can utilize it.
Side-stepping the problem for a moment, is there a reason you need two different lists of references to the same set of items? You can copy the reference itself by simply assigning one list to the other, then you’ll have two access points to the same list and won’t have to manually sync them.
Does the GameManager class have any public static members? If not you’ll need an instance of it to access any members, or you need to make some members static instead.
@DonLoquacious I have a GameObject with a script GameManager which is a singleton and i want to keep all my data in it. @GroZZleR In the GameManager? No, I’m pretty sure it won’t change anything… I tried it. No, but if you can tell my anything how it could help i would be very happy. @Kiwasi There is error.
using System;
using System.Collections.Generic;
using System.Collections;
using UnityEngine;
using System.Diagnostics;
public class GameManager : MonoBehaviour
{
private static GameManager _instance;
public string Quest;
public DateTime LastLogin;
public int player_money;
public int Player_damage;
public int player_xp;
public int xp_req;
public int player_armor;
public int player_health;
public int player_potions;
public int player_armorpen;
public int player_level;
public int boosterpacks;
public int player_base_health;
public float player_xp_modifier;
public string player_name;
public bool dead;
public bool showinventory;
public List<Item> Inventoryitems = new List<Item>();
public Saver ment;
public Sitelock locker;
//public List<Item> Inventory;
public API ka;
public static GameManager instance
{
get
{
if(_instance == null)
{
_instance = GameObject.FindObjectOfType<GameManager>();
//Tell unity not to destroy this object when loading a new scene!
DontDestroyOnLoad(_instance.gameObject);
}
return _instance;
}
}
void Awake()
{
ka = gameObject.AddComponent<API>();
if(_instance == null)
{
//If I am the first instance, make me the Singleton
_instance = this;
DontDestroyOnLoad(this);
}
else
{
//If a Singleton already exists and you find
//another reference in scene, destroy it!
if(this != _instance)
Destroy(this.gameObject);
}
ment = gameObject.AddComponent<Saver>();
ka.Connect();
ment.StartSave();
}
}