private void Update() { if (this._version != InputMappingIcons.Version) { this._texture.height = this._startHeight; if (!InputMappingIcons.UsesText(this._action)) { this._texture.mainTexture = InputMappingIcons.GetTextureFor(this._action); this._label.enabled = false; float num = (float)this._texture.mainTexture.width / (float)this._texture.mainTexture.height; if (num > 1.2f) { this._texture.height = Mathf.RoundToInt((float)this._texture.height * 0.666f); } this._texture.width = Mathf.RoundToInt(num * (float)this._texture.height); } else { this._texture.mainTexture = InputMappingIcons.GetTextureFor(this._action); this._label.text = InputMappingIcons.GetMappingFor(this._action); this._label.enabled = true; float num2 = (float)this._label.width / (float)this._label.height; if (num2 > 1.5f) { this._texture.width = Mathf.RoundToInt((float)this._startHeight * num2); } else { this._texture.width = this._startHeight; } } this._version = InputMappingIcons.Version; } }
public static UISprite RegisterIcon(Transform target, InputMappingIcons.Actions action, ActionIconSystem.CurrentViewOptions currentViewOption = ActionIconSystem.CurrentViewOptions.AllowInWorld) { if (ActionIconSystem.Instance && !ActionIconSystem.Instance._activeIcons.ContainsKey(target)) { ActionIcon actionIcon; if (!InputMappingIcons.UsesText(action)) { if (ActionIconSystem.Instance._spriteIconPool.Count > 0) { actionIcon = ActionIconSystem.Instance._spriteIconPool.Dequeue(); actionIcon.gameObject.SetActive(true); ActionIconSystem.Instance.SetIconHolderTr(actionIcon.transform, currentViewOption); } else { actionIcon = UnityEngine.Object.Instantiate <ActionIcon>(ActionIconSystem.Instance._spriteIconPrefab); ActionIconSystem.Instance.SetIconHolderTr(actionIcon.transform, currentViewOption); actionIcon.transform.localScale = ActionIconSystem.Instance._spriteIconPrefab.transform.localScale; } actionIcon._sprite.spriteName = InputMappingIcons.GetMappingFor(action); UISpriteData atlasSprite = actionIcon._sprite.GetAtlasSprite(); if (atlasSprite == null) { ActionIconSystem.Instance.DisableActionIcon(actionIcon); return(null); } actionIcon._sprite.width = Mathf.RoundToInt((float)atlasSprite.width / (float)atlasSprite.height * (float)actionIcon._sprite.height); } else { if (ActionIconSystem.Instance._textIconPool.Count > 0) { actionIcon = ActionIconSystem.Instance._textIconPool.Dequeue(); actionIcon.gameObject.SetActive(true); ActionIconSystem.Instance.SetIconHolderTr(actionIcon.transform, currentViewOption); } else { actionIcon = UnityEngine.Object.Instantiate <ActionIcon>(ActionIconSystem.Instance._textIconPrefab); ActionIconSystem.Instance.SetIconHolderTr(actionIcon.transform, currentViewOption); actionIcon.transform.localScale = ActionIconSystem.Instance._textIconPrefab.transform.localScale; } actionIcon._label.text = InputMappingIcons.GetMappingFor(action); } actionIcon._follow._target = target; actionIcon._fillSprite.gameObject.SetActive(false); actionIcon._follow._inBook = (currentViewOption == ActionIconSystem.CurrentViewOptions.AllowInBook); ActionIconSystem.Instance._activeIcons.Add(target, actionIcon); return(actionIcon._fillSprite); } return(null); }
private void Update() { if (this._version != InputMappingIcons.Version) { this._sprite.height = this._startHeight; if (!InputMappingIcons.UsesText(this._action)) { this._sprite.spriteName = InputMappingIcons.GetMappingFor(this._action); this._label.enabled = false; UISpriteData atlasSprite = this._sprite.GetAtlasSprite(); if (atlasSprite != null) { float num = (float)atlasSprite.width / (float)atlasSprite.height; if (num > 1.2f) { this._sprite.height = Mathf.RoundToInt((float)this._sprite.height * 0.666f); } this._sprite.width = Mathf.RoundToInt(num * (float)this._sprite.height); } else { Debug.LogError("Missing sprite: " + this._sprite.spriteName); } } else { this._sprite.spriteName = InputMappingIcons.TextIconBacking.name; this._label.text = InputMappingIcons.GetMappingFor(this._action); this._label.enabled = true; float num2; if (this._invertScale) { num2 = (float)this._label.width * 1f / this._label.transform.localScale.x / (float)this._startHeight; } else { num2 = (float)this._label.width * 1f * this._label.transform.localScale.x / (float)this._startHeight; } if (num2 > 1.5f) { this._sprite.width = Mathf.RoundToInt((float)this._startHeight * num2); } else { this._sprite.width = this._startHeight; } } this._version = InputMappingIcons.Version; } }
private void Update() { if (this._version != InputMappingIcons.Version) { this._texture.texture = InputMappingIcons.GetTextureFor(this._action); if (!InputMappingIcons.UsesText(this._action)) { this._text.enabled = false; this._texture.enabled = true; } else { this._text.text = InputMappingIcons.GetMappingFor(this._action); this._text.enabled = true; this._texture.enabled = this._useTextBacking; } this._version = InputMappingIcons.Version; } }
private static ActionIcon InitializeActionIcon(Transform target, InputMappingIcons.Actions action, ActionIcon.SideIconTypes sideIcon, ActionIconSystem.CurrentViewOptions currentViewOption, bool useAltTextIcon, bool useBigIcon) { ActionIcon actionIcon = null; if (ActionIconSystem.Instance && !ActionIconSystem.Instance._activeIcons.ContainsKey(target)) { if (!InputMappingIcons.UsesText(action)) { actionIcon = ActionIconSystem.Instance.GetActionIconSprite(useBigIcon); if (!ForestVR.Enabled) { actionIcon._sprite.spriteName = InputMappingIcons.GetMappingFor(action); UISpriteData atlasSprite = actionIcon._sprite.GetAtlasSprite(); if (atlasSprite == null) { ActionIconSystem.Instance.DisableActionIcon(actionIcon, useAltTextIcon, useBigIcon); return(null); } actionIcon._sprite.width = Mathf.RoundToInt((float)atlasSprite.width / (float)atlasSprite.height * (float)actionIcon._sprite.height); } else { actionIcon._sprite.enabled = false; } } else { actionIcon = ActionIconSystem.Instance.GetActionIconLabel(useAltTextIcon, useBigIcon); actionIcon._label.text = InputMappingIcons.GetMappingFor(action); if (!useAltTextIcon) { if (actionIcon._sprite == null) { Debug.LogError(string.Concat(new object[] { "[ActionIcon] Invalid sprite for \"", action, "\" on ", actionIcon.gameObject.GetFullName() })); return(null); } actionIcon._sprite.spriteName = InputMappingIcons.GetBackingFor(action); actionIcon._sprite.enabled = true; float num = (float)actionIcon._label.width * actionIcon._label.transform.localScale.x / (float)actionIcon.StartHeight; if (num > 1.5f) { actionIcon._sprite.width = Mathf.RoundToInt((float)actionIcon.StartHeight * (num * 1.2f)); } else { actionIcon._sprite.width = actionIcon.StartHeight; } } } actionIcon._action = action; actionIcon._follow._target = target; actionIcon._fillSprite.gameObject.SetActive(false); actionIcon._follow._inHud = (currentViewOption == ActionIconSystem.CurrentViewOptions.HudIcon || currentViewOption == ActionIconSystem.CurrentViewOptions.DeathScreen); actionIcon._follow._inBook = (currentViewOption == ActionIconSystem.CurrentViewOptions.AllowInBook); actionIcon._follow._inInventory = (currentViewOption == ActionIconSystem.CurrentViewOptions.AllowInInventory); actionIcon._follow._inPlane = (currentViewOption == ActionIconSystem.CurrentViewOptions.AllowInPlane); if (actionIcon._sideUpArrowIcon) { actionIcon._sideUpArrowIcon.enabled = (sideIcon == ActionIcon.SideIconTypes.UpArrow); } if (actionIcon._middleUpArrowIcon) { actionIcon._middleUpArrowIcon.enabled = (sideIcon == ActionIcon.SideIconTypes.MiddleUpArrow); } ActionIconSystem.Instance.SetIconHolderTr(actionIcon.transform, currentViewOption); ActionIconSystem.Instance._activeIcons.Add(target, actionIcon); } return(actionIcon); }