Exemple #1
0
    public Button SetData(ParamInfos p)
    {
        paramName.text = p.Name;

        if (p.Direction == ParamInfos.ParamDirection.ParamIn)
        {
            outputButton.gameObject.SetActive(false);
            inputButton.gameObject.SetActive(true);
            return(inputButton);
        }
        else
        {
            outputButton.gameObject.SetActive(true);
            inputButton.gameObject.SetActive(false);
            return(outputButton);
        }
    }
Exemple #2
0
 private void Update()
 {
     if (null != _currentLink)
     {
         _currentLink.SetOutputPosition(Input.mousePosition);
     }
     if (Input.GetKeyDown(KeyCode.Escape))
     {
         if (null != _currentLink)
         {
             Destroy(_currentLink.gameObject);
             _currentLink      = null;
             _currentFromParam = null;
             _currentFromNode  = null;
         }
     }
 }
Exemple #3
0
    public void EditTargetLink(NodeLink l)
    {
        _currentLink = l;

        Node target = _nodes[l.infos.ToID];

        target.RemoveLink(l);

        _currentFromNode = _nodes[l.infos.FromID];
        foreach (ParamInfos p in _currentFromNode.NodePrefabInfos.outputs)
        {
            if (p.Name == l.infos.FromParam)
            {
                _currentFromParam = p;
                break;
            }
        }

        SetActiveLink(null);
        SetActiveNode(null);
    }
Exemple #4
0
    public void ParamClic(Node node, ParamInfos infos, Vector2 attachPoint)
    {
        switch (infos.Direction)
        {
        case ParamInfos.ParamDirection.ParamOut:
            if (_currentFromNode == null && node.IsParamFree(infos.Name))
            {
                _currentFromNode    = node;
                _currentFromParam   = infos;
                _currentLink        = Instantiate(nodeLinkPrefab, modelZone.transform);
                _currentLink.Editor = this;
                _currentLink.transform.SetAsFirstSibling();
                _currentLink.SetInputPosition(attachPoint);
                _currentLink.SetOutputPosition(Input.mousePosition);
                _currentLink.SetColor(ColorFromType(infos.Type));
            }
            break;

        case ParamInfos.ParamDirection.ParamIn:
            if (_currentLink != null && node != _currentFromNode &&
                node.IsParamFree(infos.Name) &&
                _currentFromParam.Type == infos.Type)
            {
                LinkInfo linkInfo = new LinkInfo(_currentFromNode.NodeInfos.id, _currentFromParam.Name,
                                                 node.NodeInfos.id, infos.Name, infos.Type);
                _currentLink.infos = linkInfo;

                _currentFromNode.SetLinkToParam(_currentLink);
                node.SetLinkToParam(_currentLink);

                _currentFromNode  = null;
                _currentLink      = null;
                _currentFromParam = null;
            }
            break;
        }
    }
Exemple #5
0
 public Vector2 GetParamAttachPoint(ParamInfos p)
 {
     return(_buttons[p.Name].transform.position);
 }