private void Init(TechType techType, bool first, bool last)
        {
            this.techType = techType;

            var quickSlots = GameObject.FindObjectOfType <uGUI_QuickSlots>();
            var bgSprite   = first ? quickSlots.spriteLeft : last ? quickSlots.spriteRight : quickSlots.spriteCenter;

            (transform as RectTransform).SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, bgSprite.rect.width);
            (transform as RectTransform).SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, bgSprite.rect.height);

            layout           = gameObject.AddComponent <LayoutElement>();
            layout.minWidth  = bgSprite.rect.width;
            layout.minHeight = bgSprite.rect.height;

            background               = gameObject.AddComponent <Image>();
            background.color         = new Color(1, 1, 1, 0.5f);
            background.raycastTarget = false;
            background.material      = quickSlots.materialBackground;
            background.sprite        = bgSprite;

            button = new GameObject(name, typeof(RectTransform)).AddComponent <PinButton>();
            var brt = button.transform as RectTransform;

            RectTransformExtensions.SetParams(brt, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), transform);
            brt.anchoredPosition = new Vector2(0, 0);
            RectTransformExtensions.SetSize(brt, 30, 30);

            button.SetMode(PinButton.Mode.Cross);
            button.onClick += OnButtonClick;
        }
Пример #2
0
        public void Awake()
        {
            addPinButton    = CreateButton("AddPin", PinButton.Mode.Add, OnAddPinButtonClicked);
            removePinButton = CreateButton("RemovePin", PinButton.Mode.Remove, OnRemovePinButtonClicked);

            BlueprintTracker.onTrackingChanged += Refresh;

            Refresh();
        }