I need some help because I really not sure what is going on. I have this function that I call.
Start() {
...
setupPowerups ();
if (a_powerups.Count > 0) {
foreach (Item item in a_powerups) {
item.setUpItemName ();
Debug.Log("AAUNITY/SOOMLA Item Name: " + item.getItemName());
}
}
...
}
and it outputs the following:
04-08 15:33:48.778: I/Unity(21332): AAUNITY/SOOMLA Item Name: Shield Potion 0
04-08 15:33:48.788: I/Unity(21332): AAUNITY/SOOMLA Item Name: Energy Potion 0
04-08 15:33:48.788: I/Unity(21332): AAUNITY/SOOMLA Item Name: Super Seed 0
The when I go to insert it into the GUI content
public void Powerup Window() {
...
Debug.Log ("AAUNITY/SOOMLA Filling Powerup list");
foreach (Item item in a_powerups) {
Debug.Log("AAUNITY/SOOMLA Powerup Item name: " + item.getItemName());
itemContent.Add(new GUIContent(item.getItemName(), item.icon, item.desc));
costContent.Add(new GUIContent(item.cost.ToString(), item.priceIcon));
}
Debug.Log("AAUNITY/SOOMLA Done Filling Powerup List");
...
}
Yet when I get to that section I get the following:
04-08 15:41:26.568: I/Unity(21707): AAUNITY/SOOMLA Filling Powerup list
04-08 15:41:26.568: I/Unity(21707): AAUNITY/SOOMLA Powerup Item name:
04-08 15:41:26.578: I/Unity(21707): AAUNITY/SOOMLA Powerup Item name:
04-08 15:41:26.578: I/Unity(21707): AAUNITY/SOOMLA Powerup Item name:
04-08 15:41:26.578: I/Unity(21707): AAUNITY/SOOMLA Done Filling Powerup List
The icon and tooltip text appear fine. I would like to know why there is suddenly no info when nothing has been changed and it displayed it previously.
Update 4/9/13:
Someone asked me to post the getItemName function:
public string getItemName ()
{
return itemName;
}
It is definitely having to do with Unity GUI. Since to check I placed the following function in the very beginning of the OnGUI() funcvtion.
Debug.Log("Start OnGUI Listing");
foreach (Item item in a_powerups) {
Debug.Log("AAUNITY/SOOMLA OnGUI() | Item Name: " + item.getItemName());
}
Debug.Log("Finish OnGUI Listing");
And results in the same as has been posted above.
Below is the entire code as requested.
using com.soomla.unity;
using com.soomla.unity.example;
using System;
using System.Collections.Generic;
using UnityEngine;
public class StoreWindow : MonoBehaviour
{
public enum GUIState
{
STORE,
PURCHASE,
POWERUP,
UPGRADE,
UNLOCKABLE
}
private static StoreWindow instance;
public static bool isVisible;
public GUIState guiState = GUIState.STORE;
public GUISkin customSkin;
public Texture t_pageNameBox;
public Texture t_descBox;
public Texture t_balBox;
public Texture t_priceIcon;
private int in_toolbar;
private Rect r_window = new Rect (0, 0, 1280, 720);
private Rect r_balBox = new Rect (80, 0, 458, 150);
private Rect r_balText = new Rect (203, 35, 262, 79);
private Rect r_pageNameBox = new Rect (770, 0, 320, 100);
private Rect r_itemBox = new Rect (620, 105, 638, 375);
private Rect r_descBox = new Rect (620, 555, 638, 150);
private Rect r_costBox = new Rect (620, 510, 150, 45);
private Rect r_backButton = new Rect (0, 640, 169, 78);
private Rect r_powerupButton = new Rect (135, 410, 320, 100);
private Rect r_purchaseButton = new Rect (135, 165, 320, 100);
private Rect r_unlockableButton = new Rect (135, 540, 320, 100);
private Rect r_upgradeButton = new Rect (135, 285, 320, 100);
private Rect r_buyButton = new Rect (1171, 489, 64, 66);
private Vector2 scrollPosition = Vector2.zero;
private Vector2 scrollPosition2 = Vector2.zero;
private static AndyEventHandler handler;
/*--- Powerup Fields ---*/
public List<Item> a_powerups = new List<Item> ();
public Texture[] a_powerupIcons;
private int in_toolItems;
private Rect powerupGroupRect = new Rect (642, 122, 592, 357);
/*--- Upgrade Fields ---*/
public List<Item> a_upgrades = new List<Item> ();
public Texture[] a_upgradeIcons;
private Rect upgradeGroupRect = new Rect (642, 122, 592, 357);
/*--- Purchase Fields ---*/
public List<Item> a_packs = new List<Item> ();
public Texture packIcon;
private Rect purchaseGroupRect = new Rect (642, 122, 592, 357);
/*--- Unlockable Fields ---*/
public List<Item> a_unlockables = new List<Item> ();
public Texture[] a_unlockableIcons;
private Rect unlockableGroupRect = new Rect (642, 122, 592, 357);
public int currentShield;
public int currentEnergy;
public int currentSeed;
private Item currentSkin;
private GUIContent gui_powerupCon;
private void Awake ()
{
if (StoreWindow.instance == null) {
StoreWindow.instance = this;
GameObject.DontDestroyOnLoad (this.gameObject);
} else {
GameObject.Destroy (this);
}
}
public void Start ()
{
isVisible = false;
StoreController.Initialize (new AndysApplesAssets ());
handler = new AndyEventHandler ();
Debug.Log ("AAUNITY/SOOMLA LocalStoreInfo Initializing");
LocalStoreInfo.Init ();
Debug.Log ("AAUNITY/SOOMLA LocalStoreInfo Initialed");
setupPowerups ();
foreach (Item item in a_powerups) {
item.setUpItemName ();
Debug.Log ("AAUNITY/SOOMLA Item Name: " + item.getItemName ());
}
setupPacks ();
foreach (Item item in a_packs) {
item.setUpPackName ();
Debug.Log ("AAUNITY/SOOMLA Item Name: " + item.getItemName ());
}
setupUnlockables ();
foreach (Item item in a_unlockables) {
item.setUpItemName ();
Debug.Log ("AAUNITY/SOOMLA Item Name: " + item.getItemName ());
}
setupUpgrades ();
foreach (Item item in a_upgrades) {
item.setUpItemName ();
Debug.Log ("AAUNITY/SOOMLA Item Name: " + item.getItemName ());
}
}
public static void StoreOpening ()
{
StoreWindow.instance.guiState = StoreWindow.GUIState.STORE;
StoreController.StoreOpening ();
}
public static void StorePurchaseOpening ()
{
StoreWindow.instance.guiState = StoreWindow.GUIState.PURCHASE;
StoreController.StoreOpening ();
}
public static void StoreClosing ()
{
StoreController.StoreClosing ();
}
public static void OpenWindow ()
{
StoreWindow.isVisible = true;
}
public static void OpenPurchase ()
{
StoreWindow.isVisible = true;
StorePurchaseOpening ();
}
public static void CloseWindow ()
{
StoreWindow.isVisible = false;
}
public void Update ()
{
if (Input.GetKey (KeyCode.S) && !isVisible) {
isVisible = true;
}
}
public void OnGUI ()
{
Debug.Log ("Start OnGUI Listing");
foreach (Item item in a_powerups) {
Debug.Log ("AAUNITY/SOOMLA OnGUI() | Item Name: " + item.getItemName ());
}
Debug.Log ("Finish OnGUI Listing");
GUI.skin = customSkin;
GUI.skin.horizontalScrollbar = GUIStyle.none;
GUI.skin.verticalScrollbar = GUIStyle.none;
if (isVisible) {
if (this.guiState == GUIState.STORE) {
this.r_window = GUI.Window (0, this.r_window, new GUI.WindowFunction (this.DoMyWindow), string.Empty);
this.r_window.x = Mathf.Clamp (this.r_window.x, 0, Screen.width - this.r_window.width);
this.r_window.y = Mathf.Clamp (this.r_window.y, 0, Screen.height - this.r_window.height);
} else if (this.guiState == GUIState.PURCHASE) {
GUI.skin = customSkin;
this.r_window = GUI.Window (0, this.r_window, new GUI.WindowFunction (this.PurchaseWindow), string.Empty);
this.r_window.x = Mathf.Clamp (this.r_window.x, 0, Screen.width - this.r_window.width);
this.r_window.y = Mathf.Clamp (this.r_window.y, 0, Screen.height - this.r_window.height);
} else if (this.guiState == GUIState.UPGRADE) {
GUI.skin = customSkin;
this.r_window = GUI.Window (0, this.r_window, new GUI.WindowFunction (this.UpgradeWindow), string.Empty);
this.r_window.x = Mathf.Clamp (this.r_window.x, 0, Screen.width - this.r_window.width);
this.r_window.y = Mathf.Clamp (this.r_window.y, 0, Screen.height - this.r_window.height);
} else if (this.guiState == GUIState.POWERUP) {
GUI.skin = customSkin;
this.r_window = GUI.Window (0, this.r_window, new GUI.WindowFunction (this.PowerupWindow), string.Empty);
this.r_window.x = Mathf.Clamp (this.r_window.x, 0, Screen.width - this.r_window.width);
this.r_window.y = Mathf.Clamp (this.r_window.y, 0, Screen.height - this.r_window.height);
} else if (this.guiState == GUIState.UNLOCKABLE) {
GUI.skin = customSkin;
this.r_window = GUI.Window (0, this.r_window, new GUI.WindowFunction (this.UnlockableWindow), string.Empty);
this.r_window.x = Mathf.Clamp (this.r_window.x, 0, Screen.width - this.r_window.width);
this.r_window.y = Mathf.Clamp (this.r_window.y, 0, Screen.height - this.r_window.height);
}
}
}
private void DoMyWindow (int windowID)
{
foreach (Item item in a_powerups) {
Debug.Log ("AAUNITY/SOOMLA DoMyWindow() | Item Name: " + item.getItemName ());
}
GUI.DrawTexture (this.r_balBox, this.t_balBox);
GUI.Label (r_balText, LocalStoreInfo.CurrencyBalance.ToString (), GUI.skin.GetStyle ("Text Balance"));
GUI.DrawTexture (this.r_pageNameBox, this.t_pageNameBox);
if (GUI.Button (this.r_purchaseButton, string.Empty, GUI.skin.GetStyle ("Purchase Button"))) {
this.guiState = GUIState.PURCHASE;
}
if (GUI.Button (this.r_upgradeButton, string.Empty, GUI.skin.GetStyle ("Upgrade Button"))) {
this.guiState = GUIState.UPGRADE;
}
if (GUI.Button (this.r_powerupButton, string.Empty, GUI.skin.GetStyle ("Powerup Button"))) {
this.guiState = GUIState.POWERUP;
}
if (GUI.Button (this.r_unlockableButton, string.Empty, GUI.skin.GetStyle ("Unlockable Button"))) {
this.guiState = GUIState.UNLOCKABLE;
}
if (GUI.Button (this.r_backButton, string.Empty, GUI.skin.GetStyle ("Back Button"))) {
isVisible = false;
}
}
private void PowerupWindow (int windowID)
{
GUI.DrawTexture (this.r_balBox, this.t_balBox);
GUI.Label (r_balText, LocalStoreInfo.CurrencyBalance.ToString (), GUI.skin.GetStyle ("Text Balance"));
GUI.DrawTexture (this.r_pageNameBox, this.t_pageNameBox);
if (GUI.Button (this.r_purchaseButton, string.Empty, GUI.skin.GetStyle ("Purchase Button"))) {
this.guiState = GUIState.PURCHASE;
}
if (GUI.Button (this.r_upgradeButton, string.Empty, GUI.skin.GetStyle ("Upgrade Button"))) {
this.guiState = GUIState.UPGRADE;
}
GUI.Box (this.r_powerupButton, string.Empty, GUI.skin.GetStyle ("Powerup Button"));
if (GUI.Button (this.r_unlockableButton, string.Empty, GUI.skin.GetStyle ("Unlockable Button"))) {
this.guiState = GUIState.UNLOCKABLE;
}
if (GUI.Button (this.r_backButton, string.Empty, GUI.skin.GetStyle ("Back Button"))) {
this.guiState = GUIState.STORE;
isVisible = false;
}
// int length = this.a_powerups.Count;
// GUIContent[] array = new GUIContent[length];
// GUIContent[] costContent = new GUIContent[length];
// for (int i = 0; i < length; i++) {
// if (this.a_powerups.Count > 0) {
// array <em>= new GUIContent (this.a_powerups <em>.getItemName (), this.a_powerups <em>.icon, this.a_powerups *.desc);*</em></em></em>
// costContent = new GUIContent(this.a_powerups*.cost.ToString(), t_priceIcon);
_// } else {
// array = new GUIContent (“NONE”, string.Empty);_
// costContent _= array;
// }
// }_
GUI.Box (this.r_pageNameBox, string.Empty, GUI.skin.GetStyle (“Powerup Button”));
GUI.Box (this.r_itemBox, string.Empty, GUI.skin.GetStyle (“Description Background”));
GUI.Box (this.r_descBox, string.Empty, GUI.skin.GetStyle (“Description Background”));*
_ this.scrollPosition = GUI.BeginScrollView (this.powerupGroupRect, this.scrollPosition, new Rect (642, 122, 592, (121 * length)));_
* List itemContent = new List ();*
* List costContent = new List ();*
* Debug.Log (“AAUNITY/SOOMLA Filling Powerup list”);*
* foreach (Item item in a_powerups) {
_ Debug.Log ("AAUNITY/SOOMLA Powerup Item name: " + item.getItemName ());
itemContent.Add (new GUIContent (item.getItemName (), item.icon, item.desc));
costContent.Add (new GUIContent (item.cost.ToString (), item.priceIcon));
}
Debug.Log (“AAUNITY/SOOMLA Done Filling Powerup List”);*_
this.in_toolItems = GUI.SelectionGrid (new Rect (642, 122, 592, (121 * length)), this.in_toolItems, itemContent.ToArray (), 1, GUI.skin.GetStyle (“Selected Item”));
* GUI.EndScrollView ();*
* // For cost and purchasing*
* GUI.Box (r_costBox, costContent [in_toolItems], GUI.skin.GetStyle (“Text Description”));
if (GUI.Button (r_buyButton, “”, GUI.skin.GetStyle (“Buy Button”))) {
_ }*_
* string text = itemContent [in_toolItems].tooltip;
_ if (text == string.Empty) {
text = “Show items information here”;
}
GUIStyle style = GUI.skin.GetStyle (“Text Description”);
if (GUI.tooltip != string.Empty) {
float num = style.CalcHeight (new GUIContent (GUI.tooltip), 330f);
this.scrollPosition2 = GUI.BeginScrollView (new Rect (687, 600, 469, 150), this.scrollPosition2, new Rect (687, 600, 469, num));
GUI.Label (new Rect (687, 600, 469, num), GUI.tooltip);
} else {
float num = style.CalcHeight (new GUIContent (text), 330f);
this.scrollPosition2 = GUI.BeginScrollView (new Rect (687, 600, 469, 150), this.scrollPosition2, new Rect (687, 600, 469, num));
GUI.Label (new Rect (687, 600, 469, num), text);
}
GUI.EndScrollView ();
}*_
* private void PurchaseWindow (int windowID)*
* {*
* GUI.DrawTexture (this.r_balBox, this.t_balBox);
GUI.Label (r_balText, LocalStoreInfo.CurrencyBalance.ToString (), GUI.skin.GetStyle (“Text Balance”));
GUI.DrawTexture (this.r_pageNameBox, this.t_pageNameBox);
GUI.Box (this.r_purchaseButton, string.Empty, GUI.skin.GetStyle (“Purchase Button”));
if (GUI.Button (this.r_upgradeButton, string.Empty, GUI.skin.GetStyle (“Upgrade Button”))) {
_ this.guiState = GUIState.UPGRADE;
}_
if (GUI.Button (this.r_powerupButton, string.Empty, GUI.skin.GetStyle (“Powerup Button”))) {
_ this.guiState = GUIState.POWERUP;
}_
if (GUI.Button (this.r_unlockableButton, string.Empty, GUI.skin.GetStyle (“Unlockable Button”))) {
_ this.guiState = GUIState.UNLOCKABLE;
}_
if (GUI.Button (this.r_backButton, string.Empty, GUI.skin.GetStyle (“Back Button”))) {
_ this.guiState = GUIState.STORE;
// isVisible = false;
}_
int length = this.a_packs.Count;
GUI.Box (this.r_pageNameBox, string.Empty, GUI.skin.GetStyle (“Purchase Button”));
GUI.Box (this.r_itemBox, string.Empty, GUI.skin.GetStyle (“Description Background”));
GUI.Box (this.r_descBox, string.Empty, GUI.skin.GetStyle (“Description Background”));*
_ this.scrollPosition = GUI.BeginScrollView (this.purchaseGroupRect, this.scrollPosition, new Rect (642, 122, 592, (121 * length)));_
* GUIContent[] array = new GUIContent[length];*
* GUIContent[] costContent = new GUIContent[length];*
* for (int i = 0; i < length; i++) {*
* if (this.a_packs.Count > 0) {
array = new GUIContent (this.a_packs .getItemName (), this.a_packs .icon, this.a_packs .desc);
costContent = new GUIContent (this.a_packs .cost.ToString (), t_priceIcon);
_ } else {
array = new GUIContent (“NONE”, string.Empty);
}
}
this.in_toolItems = GUI.SelectionGrid (new Rect (642, 122, 592, (121 * length)), this.in_toolItems, array, 1, GUI.skin.GetStyle (“Selected Item”));
GUI.EndScrollView ();*_
* // For cost and purchasing*
* GUI.Box (r_costBox, costContent [in_toolItems], GUI.skin.GetStyle (“Text Description”));
if (GUI.Button (r_buyButton, “”, GUI.skin.GetStyle (“Buy Button”))) {
_ }*_
* string text = array [this.in_toolItems].tooltip;
_ if (text == string.Empty) {
text = “Show items information here”;
}
GUIStyle style = GUI.skin.GetStyle (“Text Description”);
if (GUI.tooltip != string.Empty) {
float num = style.CalcHeight (new GUIContent (GUI.tooltip), 330f);
this.scrollPosition2 = GUI.BeginScrollView (new Rect (687, 600, 469, 150), this.scrollPosition2, new Rect (687, 600, 469, num));
GUI.Label (new Rect (687, 600, 469, num), GUI.tooltip);
} else {
float num = style.CalcHeight (new GUIContent (text), 330f);
this.scrollPosition2 = GUI.BeginScrollView (new Rect (687, 600, 469, 150), this.scrollPosition2, new Rect (687, 600, 469, num));
GUI.Label (new Rect (687, 600, 469, num), text);
}
GUI.EndScrollView ();
}*_
* private void UpgradeWindow (int windowID)*
* {*
* GUI.DrawTexture (this.r_balBox, this.t_balBox);
GUI.Label (r_balText, StoreInventory.GetCurrencyBalance (“”).ToString (), GUI.skin.GetStyle (“Text Balance”));
GUI.DrawTexture (this.r_pageNameBox, this.t_pageNameBox);*
* if (GUI.Button (this.r_purchaseButton, string.Empty, GUI.skin.GetStyle (“Purchase Button”))) {
_ this.guiState = GUIState.PURCHASE;
}_
GUI.Box (this.r_upgradeButton, string.Empty, GUI.skin.GetStyle (“Upgrade Button”));
if (GUI.Button (this.r_powerupButton, string.Empty, GUI.skin.GetStyle (“Powerup Button”))) {
_ this.guiState = GUIState.POWERUP;
}_
if (GUI.Button (this.r_unlockableButton, string.Empty, GUI.skin.GetStyle (“Unlockable Button”))) {
_ this.guiState = GUIState.UNLOCKABLE;
}_
if (GUI.Button (this.r_backButton, string.Empty, GUI.skin.GetStyle (“Back Button”))) {
_ this.guiState = GUIState.STORE;
isVisible = false;
}_
int length = this.a_upgrades.Count;
GUI.Box (this.r_pageNameBox, string.Empty, GUI.skin.GetStyle (“Upgrade Button”));
GUI.Box (this.r_itemBox, string.Empty, GUI.skin.GetStyle (“Description Background”));
GUI.Box (this.r_descBox, string.Empty, GUI.skin.GetStyle (“Description Background”));*
_ this.scrollPosition = GUI.BeginScrollView (this.upgradeGroupRect, this.scrollPosition, new Rect (642, 122, 592, (121 * length)));_
* GUIContent[] array = new GUIContent[length];*
* GUIContent[] costContent = new GUIContent[length];*
* for (int i = 0; i < length; i++) {*
* if (this.a_upgrades.Count > 0) {
array = new GUIContent (this.a_upgrades .getItemName (), this.a_upgrades .icon, this.a_upgrades .desc);
costContent = new GUIContent (this.a_upgrades .cost.ToString (), t_priceIcon);
_ } else {
array = new GUIContent (“NONE”, string.Empty);
}
}
this.in_toolItems = GUI.SelectionGrid (new Rect (642, 122, 592, (121 * length)), this.in_toolItems, array, 1, GUI.skin.GetStyle (“Selected Item”));
GUI.EndScrollView ();*_
* // For cost and purchasing*
* GUI.Box (r_costBox, costContent [in_toolItems], GUI.skin.GetStyle (“Text Description”));
if (GUI.Button (r_buyButton, “”, GUI.skin.GetStyle (“Buy Button”))) {
_ }*_
* string text = array [this.in_toolItems].tooltip;
_ if (text == string.Empty) {
text = “Show items information here”;
}
GUIStyle style = GUI.skin.GetStyle (“Text Description”);
if (GUI.tooltip != string.Empty) {
float num = style.CalcHeight (new GUIContent (GUI.tooltip), 330f);
this.scrollPosition2 = GUI.BeginScrollView (new Rect (687, 600, 469, 150), this.scrollPosition2, new Rect (687, 600, 469, num));
GUI.Label (new Rect (687, 600, 469, num), GUI.tooltip);
} else {
float num = style.CalcHeight (new GUIContent (text), 330f);
this.scrollPosition2 = GUI.BeginScrollView (new Rect (687, 600, 469, 150), this.scrollPosition2, new Rect (687, 600, 469, num));
GUI.Label (new Rect (687, 600, 469, num), text);
}
GUI.EndScrollView ();
}*_
* private void UnlockableWindow (int windowID)*
* {*
* GUI.DrawTexture (this.r_balBox, this.t_balBox);
GUI.Label (r_balText, LocalStoreInfo.CurrencyBalance.ToString (), GUI.skin.GetStyle (“Text Balance”));
GUI.DrawTexture (this.r_pageNameBox, this.t_pageNameBox);
if (GUI.Button (this.r_purchaseButton, string.Empty, GUI.skin.GetStyle (“Purchase Button”))) {
_ this.guiState = GUIState.PURCHASE;
}_
if (GUI.Button (this.r_upgradeButton, string.Empty, GUI.skin.GetStyle (“Upgrade Button”))) {
_ this.guiState = GUIState.UPGRADE;
}_
if (GUI.Button (this.r_powerupButton, string.Empty, GUI.skin.GetStyle (“Powerup Button”))) {
_ this.guiState = GUIState.POWERUP;
}_
GUI.Box (this.r_unlockableButton, string.Empty, GUI.skin.GetStyle (“Unlockable Button”));
if (GUI.Button (this.r_backButton, string.Empty, GUI.skin.GetStyle (“Back Button”))) {
_ this.guiState = GUIState.STORE;
isVisible = false;
}_
int length = this.a_unlockables.Count;
GUI.Box (this.r_pageNameBox, string.Empty, GUI.skin.GetStyle (“Unlockable Button”));
GUI.Box (this.r_itemBox, string.Empty, GUI.skin.GetStyle (“Description Background”));
GUI.Box (this.r_descBox, string.Empty, GUI.skin.GetStyle (“Description Background”));*
_ this.scrollPosition = GUI.BeginScrollView (this.unlockableGroupRect, this.scrollPosition, new Rect (642, 122, 592, (121 * length)));_
* GUIContent[] array = new GUIContent[length];*
* GUIContent[] costContent = new GUIContent[length];*
* for (int i = 0; i < length; i++) {*
* if (this.a_unlockables.Count > 0) {
array = new GUIContent (this.a_unlockables .getItemName (), this.a_unlockables .icon, this.a_unlockables .desc);
costContent = new GUIContent (this.a_unlockables .cost.ToString (), t_priceIcon);
_ } else {
array = new GUIContent (“NONE”, string.Empty);
}
}
this.in_toolItems = GUI.SelectionGrid (new Rect (642, 122, 592, (121 * length)), this.in_toolItems, array, 1, GUI.skin.GetStyle (“Selected Item”));
GUI.EndScrollView ();*_
* // For cost and purchasing*
* GUI.Box (r_costBox, costContent [in_toolItems], GUI.skin.GetStyle (“Text Description”));
if (GUI.Button (r_buyButton, “”, GUI.skin.GetStyle (“Buy Button”))) {
_ }*_
* string text = array [this.in_toolItems].tooltip;
_ if (text == string.Empty) {
text = “Show items information here”;
}
GUIStyle style = GUI.skin.GetStyle (“Text Description”);
if (GUI.tooltip != string.Empty) {
float num = style.CalcHeight (new GUIContent (GUI.tooltip), 330f);
this.scrollPosition2 = GUI.BeginScrollView (new Rect (687, 600, 469, 150), this.scrollPosition2, new Rect (687, 600, 469, num));
GUI.Label (new Rect (687, 600, 469, num), GUI.tooltip);
} else {
float num = style.CalcHeight (new GUIContent (text), 330f);
this.scrollPosition2 = GUI.BeginScrollView (new Rect (687, 600, 469, 150), this.scrollPosition2, new Rect (687, 600, 469, num));
GUI.Label (new Rect (687, 600, 469, num), text);
}
GUI.EndScrollView ();
}*_
* private void setupPowerups ()*
* {*
* List goods = LocalStoreInfo.VirtualGoodPowerups;*
* Item item = new Item ();*
* int i = 0;*
* foreach (var good in goods) {*
* Debug.Log ("AAUNITY/SOOMLA Id: " + good.ItemId + ", Name: " + good.Name + ", Cost: " + good.PriceModel.GetCurrenctPrice (good).ToString ());*
* item.name = good.Name;*
* item.desc = good.Description;*
* item.cost = good.PriceModel.GetCurrenctPrice (good) [AndysApplesAssets.COMBO_CURRENCY_ITEM_ID];
item.icon = a_powerupIcons ;
a_powerups.Add (item);
_ i++;
}
}*_
* private void setupPacks ()*
* {*
* List packs = LocalStoreInfo.VirtualCurrencyPacks;*
* Item item = new Item ();*
* int i = 0;*
* foreach (var pack in packs) {*
* item.name = pack.Name;*
* item.desc = pack.Description;*
* item.price = (float)pack.MarketItem.Price;*
* item.icon = packIcon;*
* Debug.Log ("AAUNITY/SOOMLA Item: " + item.name + ", Cost: " + item.price);*
* a_packs.Add (item);
_ i++;
}
}*_
* private void setupUnlockables ()*
* {*
* List goods = LocalStoreInfo.VirtualGoodUnlockables;*
* Item item = new Item ();*
* int i = 0;*
* foreach (var good in goods) {*
* Debug.Log ("AAUNITY/SOOMLA Id: " + good.ItemId + ", Name: " + good.Name);*
* item.name = good.Name;*
* item.desc = good.Description;*
* item.cost = good.PriceModel.GetCurrenctPrice (good) [AndysApplesAssets.COMBO_CURRENCY_ITEM_ID];
item.icon = a_unlockableIcons ;
a_unlockables.Add (item);
_ i++;
}
}*_
* private void setupUpgrades ()*
* {*
* List goods = LocalStoreInfo.VirtualGoodUpgrades;*
* Item item = new Item ();*
* int i = 0;*
* foreach (var good in goods) {*
* Debug.Log ("AAUNITY/SOOMLA Id: " + good.ItemId + ", Name: " + good.Name);*
* item.name = good.Name;*
* item.desc = good.Description;*
* item.cost = good.PriceModel.GetCurrenctPrice (good) [AndysApplesAssets.COMBO_CURRENCY_ITEM_ID];
item.icon = a_upgradeIcons ;
a_upgrades.Add (item);
_ i++;
}
}
}*_
This doesn't look like an issue with Unity GUI to me, but rather something about your Items. Something is either clearing out their names, or your getItemName method isn't returning them properly. This is evidenced by the fact that you're printing a debug log and the text isn't there either. Check what's happening to your Item names; I bet you'll find a bug somewhere.
– iwaldropYeah and post the code for getItemName perhaps?
– whydoidoitYou most likely have a scoping problem. Can you please post the entire content of the classes involved. Also, there's no reason to check for
– Dracorat.Count > 0if you're going to do a for-each since it will be skipped when there're no items anyway.That would be interesting if not for the fact that a_powerups is in fact a global variable for the class and that it all functions before initiating the OnGUI call.
– CoderBearYou really should post the entire code content and let us read through it. You'll be amazed at what people can spot when they can see the whole picture.
– Dracorat