コード例 #1
0
    public UINode GenerateRPGMenuNode(string menuName)
    {
        var node = new UINode()
        {
            title = menuName, IsEntryPoint = false, NodeGUID = Guid.NewGuid().ToString()
        };

        node.SetPosition(new Rect(StartPositionX, StartPositionY, 480, 180));
        node.AddInputPort("Input");

        RPGMenuData thisNodeData = new RPGMenuData(menuName);

        node.MenuData = thisNodeData;

        EnumField interactTypeField = new EnumField(RPGMenuActionType.NewWindow);

        node.Type = (RPGMenuActionType)interactTypeField.value;
        interactTypeField.RegisterValueChangedCallback((ev) => { node.Type = (RPGMenuActionType)ev.newValue; });
        if (numberOfRPGMenus > 0)
        {
            //Allow user to select what kind of menu it is
            node.titleContainer.Add(interactTypeField);
        }

        //Create button
        Button CreateMenuInEditorButton = new Button(() => { CreateMenuInEditor(node); });

        CreateMenuInEditorButton.text = "Build RPG Menu";
        node.titleButtonContainer.Add(CreateMenuInEditorButton);

        //Content Container
        var entryName = new TextField("Menu iten name");
        var helpText  = new TextField("Help text");

        node.contentContainer.Add(entryName);
        node.contentContainer.Add(helpText);

        var mpCost = new IntegerField(120);

        mpCost.label = "MP cost";
        var apCost = new IntegerField(6);

        apCost.label = "AP cost";
        node.contentContainer.Add(apCost);
        node.contentContainer.Add(mpCost);

        var actionParam = new TextField("Action Parameter");

        node.contentContainer.Add(actionParam);

        //Add output connectors
        Button addButton = new Button(() => { AddRPGMenuItemToNode(node, entryName.text, helpText.text, mpCost.value, apCost.value, actionParam.text); });

        addButton.text = "Add menu item";
        node.contentContainer.Add(addButton);

        node.RefreshExpandedState();
        node.RefreshPorts();

        StartPositionX += 40;

        return(node);
    }