示例#1
0
    static public UIZone GetInstance()
    {
        UIZone self = UIManager.Singleton.GetUIWithoutLoad <UIZone>();

        if (self == null)
        {
            self = UIManager.Singleton.LoadUI <UIZone>("UI/UIZone", UIManager.Anchor.Center);
        }
        return(self);
    }
        public void ValidateZoneIdAndName()
        {
            // If the list is empty, may mean that UIZones haven't initialized
            UIZone.GetAllInScene();

            if (UIZone.list.Count == 0)
            {
                zoneSelector.ZoneId   = 0;
                zoneSelector.ZoneName = "";
                return;
            }

            // If zoneId is out of range, use zero
            if (zoneSelector.ZoneId >= UIZone.list.Count)
            {
                zoneSelector.ZoneId = 0;
            }
            // If the selected name and id don't match, try to guess which one is correct
            if (UIZone.list[zoneSelector.ZoneId].itemName != zoneSelector.ZoneName)
            {
                // First try to find the itemName, if it exists we want that
                if (zoneSelector.ZoneName != "" && UIZone.lookup.ContainsKey(zoneSelector.ZoneName))
                {
                    XDebug.LogWarning(!XDebug.logWarnings ? null :
                                      ("Component '" + parent.GetType() + "' references UIZone named '" + zoneSelector.ZoneName + "'. the index doesn't match though. Will use the new index for that zone name."));

                    zoneSelector.ZoneId = UIZone.lookup[zoneSelector.ZoneName].index;
                }
                else
                {
                    XDebug.LogWarning(!XDebug.logWarnings ? null :
                                      ("Component '" + parent.GetType() + "' references UIZone named '" + zoneSelector.ZoneName + "', but it no longer exists. '" + UIZone.list[zoneSelector.ZoneId].itemName + "' will be used instead"), zoneSelector.ZoneName != "");

                    zoneSelector.ZoneName = UIZone.list[zoneSelector.ZoneId].itemName;
                }
            }
        }