public void Init() { component.text = string.Empty; component.tooltipAnchor = UITooltipAnchor.Anchored; component.tabStrip = true; component.horizontalAlignment = UIHorizontalAlignment.Center; component.verticalAlignment = UIVerticalAlignment.Middle; component.pivot = UIPivotPoint.TopCenter; component.foregroundSpriteMode = UIForegroundSpriteMode.Fill; component.group = component.parent; component.eventTooltipShow += (c, p) => { if (m_tooltipBox != null && m_tooltipBox.isVisible && m_tooltipBox != p.tooltip) { m_tooltipBox.Hide(); } m_tooltipBox = p.tooltip; }; component.eventMouseLeave += (c, p) => { if (m_tooltipBox != null && m_tooltipBox.isVisible) { m_tooltipBox.Hide(); } }; UIComponent uIComponent = (component.childCount <= 0) ? null : component.components[0]; if (uIComponent != null) { uIComponent.isVisible = false; } m_tagSprite = component.AddUIComponent <UISprite>(); m_tagSprite.size = new Vector2(20, 16); m_tagSprite.atlas = FindIt.atlas; m_tagSprite.spriteName = "Tag"; m_tagSprite.opacity = 0.5f; m_tagSprite.tooltipBox = UIView.GetAView().defaultTooltipBox; m_tagSprite.relativePosition = new Vector3(component.width - m_tagSprite.width - 5, 5); m_tagSprite.isVisible = false; m_tagSprite.eventMouseEnter += (c, p) => { m_tagSprite.opacity = 1f; }; m_tagSprite.eventMouseLeave += (c, p) => { m_tagSprite.opacity = 0.5f; }; m_tagSprite.eventClick += (c, p) => { p.Use(); UITagsWindow.ShowAt(currentData.asset, m_tagSprite); }; // batch action check box m_batchCheckBox = SamsamTS.UIUtils.CreateCheckBox(component); m_batchCheckBox.isChecked = false; m_batchCheckBox.isVisible = false; m_batchCheckBox.width = 20; m_batchCheckBox.transform.localScale = new Vector3(1.2f, 1.2f, 1.0f); m_batchCheckBox.relativePosition = new Vector3(5, component.height - m_batchCheckBox.height - 5); m_batchCheckBox.eventClicked += (c, i) => { if (currentData != null && currentData.asset != null && m_batchCheckBox) { if (m_batchCheckBox.isChecked) { UIFilterTag.instance.batchAssetSet.Add(currentData.asset); // Debugging.Message("Batch - Add to batch set: " + currentData.asset.name); } else { UIFilterTag.instance.batchAssetSet.Remove(currentData.asset); // Debugging.Message("Batch - Remove from batch set: " + currentData.asset.name); } } }; m_instanceCountLabel = component.AddUIComponent <UILabel>(); m_instanceCountLabel.textScale = 0.8f; //m_instanceCountLabel.padding = new RectOffset(0, 0, 8, 0); m_instanceCountLabel.atlas = SamsamTS.UIUtils.GetAtlas("Ingame"); m_instanceCountLabel.backgroundSprite = "GenericTabDisabled"; m_instanceCountLabel.relativePosition = new Vector3(5, 5); component.eventMouseEnter += (c, p) => { if (currentData != null && currentData.asset != null && AssetTagList.instance.assets.ContainsValue(currentData.asset)) { m_tagSprite.isVisible = true; } }; component.eventMouseLeave += (c, p) => { if (m_tagSprite.isVisible && currentData != null && currentData.asset != null && currentData.asset.tagsCustom.Count == 0) { m_tagSprite.isVisible = false; } }; m_dlcSprite = component.AddUIComponent <UISprite>(); m_dlcSprite.size = new Vector2(18, 18); m_dlcSprite.atlas = SamsamTS.UIUtils.GetAtlas("Ingame"); m_dlcSprite.opacity = 0.55f; m_dlcSprite.tooltipBox = UIView.GetAView().defaultTooltipBox; m_dlcSprite.relativePosition = new Vector3(component.width - m_dlcSprite.width - 3, component.height - m_dlcSprite.height - 3); m_dlcSprite.isVisible = false; m_dlcSprite.eventMouseLeave += (c, p) => { m_dlcSprite.tooltipBox.Hide(); }; if (PlatformService.IsOverlayEnabled()) { m_dlcSprite.eventMouseUp += OnTooltipClicked; } }
public void Init() { component.text = string.Empty; component.tooltipAnchor = UITooltipAnchor.Anchored; component.tabStrip = true; component.horizontalAlignment = UIHorizontalAlignment.Center; component.verticalAlignment = UIVerticalAlignment.Middle; component.pivot = UIPivotPoint.TopCenter; component.foregroundSpriteMode = UIForegroundSpriteMode.Fill; component.group = component.parent; component.eventTooltipShow += (c, p) => { if (m_tooltipBox != null && m_tooltipBox.isVisible && m_tooltipBox != p.tooltip) { m_tooltipBox.Hide(); } m_tooltipBox = p.tooltip; }; UIComponent uIComponent = (component.childCount <= 0) ? null : component.components[0]; if (uIComponent != null) { uIComponent.isVisible = false; } m_tagSprite = component.AddUIComponent <UISprite>(); m_tagSprite.size = new Vector2(20, 16); m_tagSprite.atlas = FindIt.atlas; m_tagSprite.spriteName = "Tag"; m_tagSprite.opacity = 0.5f; m_tagSprite.tooltipBox = UIView.GetAView().defaultTooltipBox; m_tagSprite.relativePosition = new Vector3(component.width - m_tagSprite.width - 5, 5); m_tagSprite.isVisible = false; m_tagSprite.eventMouseEnter += (c, p) => { m_tagSprite.opacity = 1f; }; m_tagSprite.eventMouseLeave += (c, p) => { m_tagSprite.opacity = 0.5f; }; m_tagSprite.eventClick += (c, p) => { p.Use(); UITagsWindow.ShowAt(currentData.asset, m_tagSprite); }; component.eventMouseEnter += (c, p) => { if (currentData != null && currentData.asset != null && AssetTagList.instance.assets.ContainsValue(currentData.asset)) { m_tagSprite.isVisible = true; } }; component.eventMouseLeave += (c, p) => { if (m_tagSprite.isVisible && currentData != null && currentData.asset != null && currentData.asset.tagsCustom.Count == 0) { m_tagSprite.isVisible = false; } }; m_steamSprite = component.AddUIComponent <UISprite>(); m_steamSprite.size = new Vector2(26, 16); m_steamSprite.atlas = SamsamTS.UIUtils.GetAtlas("Ingame"); m_steamSprite.spriteName = "SteamWorkshop"; m_steamSprite.opacity = 0.05f; m_steamSprite.tooltipBox = UIView.GetAView().defaultTooltipBox; m_steamSprite.relativePosition = new Vector3(component.width - m_steamSprite.width - 5, component.height - m_steamSprite.height - 5); m_steamSprite.isVisible = false; if (PlatformService.IsOverlayEnabled()) { m_steamSprite.eventMouseUp += OnTooltipClicked; } }