The first part is PropsControll, it start the game the player's backpack in the SQL to load a list of the first
Void the Start ()
{
//initialize
A Locator. SetProps (this);
# if UNITY_ANDROID
IconPath=Application. PersistentDataPath + "/Resources/UI/Icons/Props/";
# elif UNITY_IOS
IconPath=Application. PersistentDataPath + "/Resources/UI/Icons/Props/";
# elif UNITY_STANDALONE_WIN
IconPath=Application. DataPath + "/Resources/UI/Icons/Props/";
# the else
IconPath=Application. DataPath + "/Resources/UI/Icons/Props/";
# endif
SQLiteHelper helper=new SQLiteHelper ();
Dt_PropsList=helper. ReadTable (" PropsList ");
Helper. CloseConnection ();
}
//list the backpack data
Public void BagList ()
{
for (int i=0; I & lt; Dt_PropsList. Rows. Count; I++)
{
Props tempbag=new Props ();
Tempbag. Name=(string) dt_PropsList. Rows [I] (" Name "),
Tempbag. Amount=(int) dt_PropsList. Rows [I] (" the Amount ");
Tempbag. The Description=(string) dt_PropsList. Rows [I] (" Description ");
Tempbag. Icon=IconPath + (string) dt_PropsList. Rows [I] [] "Icon" + ". PNG ";
_props. Add (tempbag);
}
}
The second part is tied to the backpack button code, its job is to read PropsControll List, and added into the dictionary
Public PropsMaterial _temp;
Public Image _tempIcon;
Public Text _tempDescription;
Public Dictionary_iconDic=new Dictionary (a);
Public List_material;
Public PropsControll _controll;
Public RectTransform _panel;
Public UIManager _ui;
Public ResearchMusic _research;
Private void Awake ()
{
_controll=FindObjectOfType(a);
_controll. ResearchList ();
_ui=FindObjectOfType(a);
for (int i=0; I & lt; _controll. _props. Count; I++)
{
Sprite temp=FileReadWriteHelper. LoadSprite (_controll _props [I] Icon, 100) 30;
_iconDic. Add (_controll _props [I]. Name, temp);
}
The present question is that, when I first enter the scene, backpack work
But if I switch out of the scene, the problem will appear, and backpack could not show any data
How do I solve?
CodePudding user response:
1, repeat adding problemsHere recommend to join if a judgment has been added the corresponding data, if it is, then give up to add,
Ps: data can be added in the last backpack when joining a signal value as judgment,
2: suggest not actually in the form of official teaching around mount component programming, suggest set up with standard entity class engineering structure, bags would not be affected by the scene,