Exemple #1
0
    public YarnEntity Clone()
    {
        var clonedEntity = new YarnEntity(this.clusterOriginalColor, this.clusterId, this.yarnPanel, this.geometryIndex);

        return(clonedEntity);
    }
    private void OnEnable()
    {
        WizardController.instance.yarnTabManager = this;
        generateSVG.interactable = generate3DButton.interactable = false;

        backgroundYarns.Clear();
        pictorialYarns.Clear();
        yarnsReady = false;
        foreach (RectTransform child in parentBackground)
        {
            if (child.GetComponent <YarnPanel>().yarnZone != YarnPanel.YarnZone.Warp)
            {
                GameObject.Destroy(child.gameObject);
            }
            else
            {
                child.GetComponent <YarnPanel>().parentManager = this;
                backgroundYarns.Add(child.GetComponent <YarnPanel>());
                if (WizardController.instance._generalTechnique == GeneralTechnique.Freestyle)
                {
                    child.GetComponent <YarnPanel>().yarnTypeDropdown.interactable = true;
                    child.GetComponent <YarnPanel>().outputColorImage.GetComponent <Button>().interactable = true;
                }

                child.GetComponent <YarnPanel>().UpdateYarnTypes();
            }
        }
        foreach (RectTransform child in parentPictorical)
        {
            GameObject.Destroy(child.gameObject);
        }

        // Jesús: set the labels matrix texture
        setLabelsMatrix();

        WizardController.instance.yarnPanels.Clear();
        WizardController.instance.yarnEntities.Clear();

        for (int i = 0; i < WizardController.instance.clusterList.Count; i++)
        {
            var panel = GameObject.Instantiate(prefabYarnPanel, parentPictorical).GetComponent <YarnPanel>();
            panel.parentManager  = this;
            panel.inputColor     = WizardController.instance.clusterList[i];
            panel.outputColor    = WizardController.instance.clusterList[i];
            panel.yarnNumber     = "" + (i + 1);
            panel.isBackground   = false;
            panel.backgroundZone = parentBackground;
            panel.pictoricalZone = parentPictorical;

            panel.GetComponent <YarnPanel>().yarnZone = YarnPanel.YarnZone.Pictorial;
            pictorialYarns.Add(panel.GetComponent <YarnPanel>());
            WizardController.instance.yarnPanels.Add(panel);
            panel.GetComponent <YarnPanel>().UpdateYarnTypes();

            var yarnEntity = new YarnEntity(WizardController.instance.clusterList[i], i, panel);
            WizardController.instance.yarnEntities.Add(yarnEntity);
        }


        /*for (int i = 0; i < WizardController.instance.clusterList.Count; i++)
         * {
         *  var panel = GameObject.Instantiate(prefabYarnPanel, parentPictorical).GetComponent<YarnPanel>();
         *  panel.parentManager = this;
         *  panel.inputColor = WizardController.instance.clusterList[i];
         *  panel.outputColor = WizardController.instance.clusterList[i];
         *  panel.yarnNumber =""+ (i + 1);
         *  panel.isBackground = false;
         *  panel.backgroundZone = parentBackground;
         *  panel.pictoricalZone = parentPictorical;
         *  //if (WizardController.instance.selectedTechniqueRestrictions.pictorialZone)
         *  //{
         *      panel.GetComponent<YarnPanel>().yarnZone = YarnPanel.YarnZone.Pictorial;
         *      pictorialYarns.Add(panel.GetComponent<YarnPanel>());
         *  /*}
         *  else
         *  {
         *
         *      panel.GetComponent<YarnPanel>().isBackground = true;
         *      panel.GetComponent<YarnPanel>().yarnZone = YarnPanel.YarnZone.Weft;
         *      panel.GetComponent<YarnPanel>().ActiveToggle(false);
         *      backgroundYarns.Add(panel.GetComponent<YarnPanel>());
         *  } #1#
         *
         *  WizardController.instance.yarnPanels.Add(panel);
         *  panel.GetComponent<YarnPanel>().UpdateYarnTypes();
         * }*/

        yarnsReady = true;
        Activate3DButton();

        bindingWarpToggle.GetComponent <Toggle>().isOn = false;
        bindingWarpToggle.SetActive(WizardController.instance.selectedTechniqueRestrictions.allowedBindingWarp);


        //Pablo: Prueba pa siempre
        updateYarnColors();
    }