Continued:
In Unity3d, the idea of dealing with backpacks in the game is that each lattice of a backpack is a clickable object, and a single lattice can be made into one
Prefabs is then added to the game, and each grid has a logic judgment, whether there are items in the current grid, whether the current grid is empty
My approach is not to dynamically generate objects, but to manually load backpack objects one by one, and then name each backpack. In this way, you can check the current backpack
After the object is loaded, the name of the Current Grid Object is distributed.
The ICOn of the current backpack is only an empty UISprite that has been adjusted
A. Define an object group to store all ICON objects
B. Load the background image to be displayed in the current backpack one by one.
Void SetIcon (int I ){
If (obj [I])
NGUITools. AddSprite (obj [I], atlax, "Orc Armor-Shoulders ");
If (! String. IsNullOrEmpty (obj [I]. GetComponent <UISprite> (). spriteName )){
NGUITools. Broadcast ("OnDetailsResult", "rc" + I );
} Else {
// Reload
}
}
C. Use the NGUI tool class to dynamically load image objects to the UISprite of the ICON
D. Then broadcast the event for logic processing.
Void OnDetailsResult (string rc ){
BetterList <string> entrtys = new BetterList <string> ();
If (! String. IsNullOrEmpty (rc )){
Entrtys. Add (rc );
//If(Entrtys.Size>0)
//TiledController.Index=Entrtys.Size;
}
TiledController. index ++;
Print ("size" + entrtys. size );
}
In this way, the backpack can be loaded. It is also a backpack for static display. You can add display items.
:)