Пример #1
0
    private void SetComponentForParameter()
    {
        List <SubNodeParameter> subNodeParameters = new List <SubNodeParameter>();

        foreach (Parameter p in this.node.parameters)
        {
            //Number
            if (p.type == ParameterType.number)
            {
                NumberParameter pram  = p as NumberParameter;
                var             compo = NumberComponent.Instantiate(MainViweModel.instance.NumberComponentPrefab, contentsObject, pram);
                componentList.Add(compo);
            }

            //sentence
            if (p.type == ParameterType.sentence)
            {
                SentenceParameter pram = p as SentenceParameter;
                var compo = SentenceComponent.Instantiate(MainViweModel.instance.SentenceComponentPrefab, contentsObject, pram);
                componentList.Add(compo);
            }

            //dropdown
            if (p.type == ParameterType.dropdown)
            {
                DropdownParameter pram = p as DropdownParameter;
                var compo = DropdownComponent.Instantiate(MainViweModel.instance.DropdownComponentPrefab, contentsObject, pram);
                componentList.Add(compo);
            }

            //nodes
            if (p.type == ParameterType.nodes)
            {
                NodesParameter pram  = p as NodesParameter;
                var            compo = SubNodeListComponent.Instantiate(MainViweModel.instance.SubNodeListComponentPrefab, contentsObject, pram.list, this);
                componentList.Add(compo);
                if (pram.Title != null)
                {
                    compo.title.text = pram.Title;
                }
            }

            //subNodeList
            if (p.type == ParameterType.subNode)
            {
                subNodeParameters.Add(p as SubNodeParameter);
            }
        }

        if (subNodeParameters.Count != 0)
        {
            var compo = SubNodeListComponent.Instantiate(MainViweModel.instance.SubNodeListComponentPrefab, contentsObject, subNodeParameters, this);
            componentList.Add(compo);
        }
    }
Пример #2
0
    public static SentenceComponent Instantiate(GameObject prefab, GameObject parent, SentenceParameter parameter)
    {
        SentenceComponent obj = Instantiate(prefab, parent.transform).GetComponent <SentenceComponent>();

        obj.parameter = parameter;
        if (parameter.Title == null)
        {
            obj.title.gameObject.SetActive(false);
        }
        else
        {
            obj.title.text = parameter.Title;
        }

        if (parameter.Text == null)
        {
            obj.dscriptionObj.SetActive(false);
        }
        else
        {
            obj.dscription.text = parameter.Text;
        }
        if (parameter.Value != null)
        {
            obj.inputField.text = parameter.Value;
        }
        return(obj);
    }