Ejemplo n.º 1
0
    public AttachmentWheel(Carousel <Attachment> attachments)
    {
        ATTACHMENTS = attachments;
        CANVAS      = GameObject.Find(CANVAS_NAME);
        wheel       = new Wheel();
        int numberOfNonPassiveAttachments = 0;

        foreach (Attachment attachment in ATTACHMENTS)
        {
            if (!attachment.isPassive())
            {
                ++numberOfNonPassiveAttachments;
            }
        }
        wheel.wheelElements = new WheelElement[numberOfNonPassiveAttachments];
        int attachmentIndex = 0;

        foreach (Attachment attachment in ATTACHMENTS)
        {
            if (!attachment.isPassive())
            {
                wheel.wheelElements[attachmentIndex]        = new WheelElement();
                wheel.wheelElements[attachmentIndex++].Icon = Sprite.Create(attachment.getImage().getTexture(), new Rect(0, 0, attachment.getImage().getTexture().width, attachment.getImage().getTexture().height), new Vector2(0.5f, 0.5f), 100);
            }
        }
        if (GameObject.FindObjectOfType <Canvas>() != null)
        {
            MAIN_MENU = GameObject.Find(MAIN_MENU_NAME).GetComponent <WheelMenu>();
            MAIN_MENU.transform.SetParent(CANVAS.transform);
            MAIN_MENU.transform.localPosition = new Vector3(CANVAS.GetComponent <RectTransform>().sizeDelta.x / 2 + MAIN_MENU.GetComponent <RectTransform>().sizeDelta.x / 6, 0, 0);
            MAIN_MENU.initialize(wheel);
        }
    }