protected override void Awake() { HUDBackpack.s_Instance = this; this.m_IsHovered = false; RawImage[] componentsInChildren = base.transform.FindDeepChild("Pockets").gameObject.GetComponentsInChildren <RawImage>(); this.m_PocketImages = new List <PocketImageData>(); foreach (RawImage rawImage in componentsInChildren) { if (!(rawImage.name != BackpackPocket.Front.ToString()) || !(rawImage.name != BackpackPocket.Main.ToString()) || !(rawImage.name != BackpackPocket.Left.ToString()) || !(rawImage.name != BackpackPocket.Right.ToString()) || !(rawImage.name != BackpackPocket.Top.ToString())) { PocketImageData pocketImageData = new PocketImageData(); pocketImageData.pocket = (BackpackPocket)Enum.Parse(typeof(BackpackPocket), rawImage.name); pocketImageData.icon = rawImage; pocketImageData.selection = rawImage.transform.Find("Selection").gameObject; pocketImageData.selection.SetActive(false); pocketImageData.new_count_bg = rawImage.transform.Find("BG").GetComponent <Image>(); pocketImageData.new_count_text = rawImage.transform.GetComponentInChildren <Text>(); this.m_PocketImages.Add(pocketImageData); } } GameObject gameObject = new GameObject("EquippedIcon"); this.m_EquippedIcon = gameObject.AddComponent <Image>(); Sprite sprite = null; ItemsManager.Get().m_ItemIconsSprites.TryGetValue("Default_Pickup", out sprite); DebugUtils.Assert(sprite, true); this.m_EquippedIcon.sprite = sprite; this.m_EquippedIcon.rectTransform.sizeDelta = new Vector2(20f, 20f); gameObject.GetComponent <RectTransform>().SetParent(base.transform); gameObject.SetActive(true); this.m_BG = base.transform.Find("BG").gameObject.GetComponent <RawImage>(); this.InitializeSounds(); for (int j = 0; j < base.transform.childCount; j++) { base.transform.GetChild(j).gameObject.SetActive(false); } base.enabled = false; if (this.m_PADChangeTabs.Count > 0) { this.m_PADChangeTabDefaultAlpha = this.m_PADChangeTabs[0].color.a; } }
protected override void Update() { base.Update(); this.UpdateAnimations(); this.UpdateColor(); this.UpdateEquippedIcon(); this.m_PadQuitHint.SetActive(GreenHellGame.IsPadControllerActive() && !BodyInspectionController.Get().IsActive()); this.m_PadSortHint.SetActive(GreenHellGame.IsPadControllerActive() && !BodyInspectionController.Get().IsActive()); this.m_IsHovered = RectTransformUtility.RectangleContainsScreenPoint(this.m_BG.rectTransform, Input.mousePosition); if (this.m_IsHovered) { PocketImageData pocketImageData = null; foreach (PocketImageData pocketImageData2 in this.m_PocketImages) { if (pocketImageData2.selection.gameObject.activeSelf) { pocketImageData = pocketImageData2; break; } } CursorManager.Get().SetCursor((pocketImageData != null) ? CursorManager.TYPE.MouseOver : CursorManager.TYPE.Normal); if (pocketImageData != null && Input.GetKeyDown(InputHelpers.PadButton.Button_X.KeyFromPad())) { this.OnPocketClick(pocketImageData.pocket.ToString()); } } foreach (Image image in this.m_PADChangeTabs) { if (image.gameObject.activeSelf) { Color color = image.color; color.a = (Inventory3DManager.Get().m_CarriedItem ? (this.m_PADChangeTabDefaultAlpha * 0.5f) : this.m_PADChangeTabDefaultAlpha); image.color = color; } } }