Пример #1
0
    public void FillInteractionPanel(Interactable interactableElement)
    {
        ClearInteractionContainer();

        switch (interactableElement.interactionType)
        {
        case InteractionType.ChangeColor:
            foreach (Color c in interactableElement.availableColors)
            {
                InteractableOption io = Instantiate(optionPrefab, optionContainer).GetComponent <InteractableOption>();
                io.optionButton.onClick.AddListener(() => interactableElement.ChangeColor(c));
                io.optionImage.color = c;
            }
            break;

        case InteractionType.ChangeMaterial:
            foreach (Material m in interactableElement.availableMaterials)
            {
                InteractableOption io = Instantiate(optionPrefab, optionContainer).GetComponent <InteractableOption>();
                Sprite             s  = Sprite.Create((Texture2D)m.GetTexture("_MainTex"), io.optionImage.sprite.rect, io.optionImage.sprite.pivot);
                io.optionButton.onClick.AddListener(() => interactableElement.ChangeMaterial(interactableElement.availableMaterials.IndexOf(m)));
                io.optionImage.sprite = s;
                io.optionImage.color  = m.GetColor("_Color");
            }
            break;

        case InteractionType.ChangeModel:
            break;
        }
    }