示例#1
0
    public InputElements CreateInputCanvas(object value, int id, WorldSpaceUI worldSpaceUI, bool isVariable, string name = "constant")
    {
        GameObject obj = GameObject.Instantiate(this.constantAndVariablePanelPrefab);
        Canvas     can = obj.GetComponent <Canvas>();

        can.worldCamera = this.camera;
        GameObject buttonGo = obj.transform.Find("Button").gameObject;
        Button     button   = buttonGo.GetComponent <Button>();
        GameObject textGO   = buttonGo.transform.Find("Text").gameObject;
        TMP_Text   text     = textGO.GetComponent <TMP_Text>();

        if (isVariable)
        {
            text.text = name;
        }
        else
        {
            text.text = value.ToString();
        }

        DirectInputNode nodeBe = buttonGo.AddComponent <DirectInputNode>();
        RectTransform   rt     = obj.GetComponent <RectTransform>();
        InputElements   result = new InputElements(obj, text, nodeBe, rt, button, id);

        obj.transform.SetParent(this.localParent);
        ///element scaling!
        rt.localScale *= this.constantsScale;
        nodeBe.Setup(value, id, worldSpaceUI, result, isVariable, name);
        this.inputs.Add(result);
        return(result);
    }
示例#2
0
 public InputElements(GameObject canvas, TMP_Text text, DirectInputNode node, RectTransform rectTransform, Button button, int id)
 {
     this.RectTransform = rectTransform;
     this.Object        = canvas;
     this.text          = text;
     this.Node          = node;
     this.Button        = button;
     this.Id            = id;
 }
示例#3
0
    public void TrackParameterAssignConstant(ParameterNode node, DirectInputNode constant, string name = null)
    {
        name = name == null ? workBundleName : name;


        var existing = this.bundles.Single(x => x.Name == name)?.ParaDirectInputConnections
                       .SingleOrDefault(x => x.Parameter == node);

        if (existing != null)
        {
            /// Assigning new constant to paramater, marking the previous constant as not used!
            existing.DirectInput.SetUsed(false, null);

            existing.DirectInput = constant;
            Debug.Log("replaced constatnt");
        }
        else
        {
            this.bundles.Single(x => x.Name == name)?.ParaDirectInputConnections
            .Add(new ParameterDirectInput(node, constant));
        }
    }
    public void RegisterDirectInputClick(DirectInputNode node, ParameterNode paraNodeIn = null)
    {
        var paraNode = this.lastClickedParameter;

        if (paraNodeIn != null)
        {
            paraNode = paraNodeIn;
        }

        if (paraNode != null)
        {
            if (node.elements.Used)
            {
                Debug.Log("constant already used");
                return;
            }

            this.connTracker.TrackParameterAssignConstant(paraNode, node);

            this.inputCanvas.InputsHide();

            paraNode.RegisterAssignment();

            InputCanvas.InputElements n = this.inputCanvas.GetInputs().Single(x => x.Node == node);

            n.Used = true;
            n.Node.SetUsed(true, paraNode);

            return;
        }

        if (this.lastClickedProperty != null)
        {
            // TODO:
        }
    }
示例#5
0
 public ParameterDirectInput(ParameterNode parameter, DirectInputNode constant)
 {
     Parameter   = parameter;
     DirectInput = constant;
 }