Ejemplo n.º 1
0
    public void ShowNodeDetailPanel(btInterfaceNode _node)
    {
        if (_node == null)
        {
            return;
        }

        this.nodeDetailPanel.SetActive(true);
        this.currentNode = _node;

        string nodeName = _node.GetDisplayLabel();

        this.nodeDetailNameLabel.text = nodeName + " Node";

        string nodeDescription = _node.GetDescription();

        this.nodeDetailDescriptionLabel.text = nodeDescription;

        bool hasVariable = _node.UsesVariable();

        this.nodeVariableSlider.gameObject.SetActive(hasVariable);

        if (hasVariable == true)
        {
            this.nodeVariableSlider.ShowVariableDetails(_node);
        }

        this.TogglePlayPauseButtons(false);
    }
Ejemplo n.º 2
0
    public GameObject CreateInterfaceNode(INODE_TYPE _nodeType)
    {
        GameObject nodeTemplate = GameObject.Instantiate(this.nodeTemplatePrefab) as GameObject;

        nodeTemplate.transform.parent = this.gameObject.transform;

        nodeTemplate.transform.localScale    = new Vector3(1, 1, 1);
        nodeTemplate.transform.localPosition = new Vector3(0, 0, 0);

        btInterfaceNodeTemplate templateScript = nodeTemplate.GetComponent <btInterfaceNodeTemplate>();

        btInterfaceNode nodeScript = nodeTemplate.AddComponent(btInterfaceTreeManager.GetInterfaceNodeType(_nodeType)) as btInterfaceNode;

        this.nodeList.Add(nodeScript);
        nodeScript.nodeType   = _nodeType;
        nodeScript.dragScript = nodeScript.GetComponent <UIDragObject>();

        btAreaLimiter areaLimiter = nodeTemplate.GetComponent <btAreaLimiter>();

        areaLimiter.limitTransform = this.edittingArea;

        btInterfaceInnerNode innerNodeScript = nodeScript as btInterfaceInnerNode;
        btInterfaceRootNode  rootNodeScript  = nodeScript as btInterfaceRootNode;

        GameObject          infoButton = this.AddComponentToNode(nodeTemplate, this.infoButtonPrefab, templateScript.infoButtonPlaceholder);
        btInterfaceNodeInfo infoScript = infoButton.GetComponent <btInterfaceNodeInfo>();

        infoScript.attachedNode = nodeScript;

        nodeScript.glowTexture = templateScript.glowTexture;
        nodeScript.dotTexture  = templateScript.dotTexture;

        if (innerNodeScript != null)
        {
            GameObject connectorObj = this.AddComponentToNode(nodeTemplate, this.connectorPrefab, templateScript.connectorPlaceholder);

            btInterfaceConnector connectorScript = connectorObj.GetComponent <btInterfaceConnector>();
            connectorScript.attachedNode = innerNodeScript;
            btAreaLimiter dragLimiter = connectorScript.dragWidget.GetComponent <btAreaLimiter>();
            dragLimiter.limitTransform = this.edittingArea;

            innerNodeScript.Connector = connectorScript;
        }

        if (nodeScript.CanHaveParent())
        {
            GameObject receiverObj = this.AddComponentToNode(nodeTemplate, this.receiverPrefab, templateScript.receiverPlaceholder);

            btInterfaceReceiver receiverScript = receiverObj.GetComponent <btInterfaceReceiver>();
            receiverScript.attachedNode = nodeScript;
            nodeScript.receiver         = receiverScript;
        }

        if (rootNodeScript == null)
        {
            GameObject deleteButtonObj = this.AddComponentToNode(nodeTemplate, this.deleteButtonPrefab, templateScript.deleteButtonPlaceholder);

            btInterfaceDeleteNode deleteScript = deleteButtonObj.GetComponent <btInterfaceDeleteNode>();
            deleteScript.attachedNode = nodeScript;
            nodeScript.deleteButton   = deleteScript;

            GameObject indexDisplayObj = this.AddComponentToNode(nodeTemplate, this.indexDisplayPrefab, templateScript.indexDisplayPlaceholder);
            nodeScript.indexDisplay = indexDisplayObj.GetComponent <btInterfaceIndexDisplay>();
        }
        else
        {
            areaLimiter.enabled = false;
        }

        string materialPath = nodeScript.GetIconMaterialPath();
        Object iconResource = Resources.Load(materialPath);

        if (iconResource == null)
        {
            Debug.LogError("Cannot find material with path \"" + materialPath + "\"");
            return(nodeTemplate);
        }
        Material iconMaterial = iconResource as Material;

        if (iconMaterial == null)
        {
            Debug.LogError("Resource \"" + iconResource.name
                           + "\" at path \"" + materialPath
                           + "\" cannot be converted into a meterial.");
            return(nodeTemplate);
        }

        Material backgroundMaterial = null;

        if (nodeScript as btInterfaceInnerNode != null)
        {
            backgroundMaterial = this.innerNodeMaterial;
        }
        else if (nodeScript as btInterfaceActionNode != null)
        {
            backgroundMaterial = this.actionNodeMaterial;
        }
        else if (nodeScript as btInterfaceTestNode != null)
        {
            backgroundMaterial = this.testNodeMaterial;
        }

        templateScript.iconTexture.material = iconMaterial;
        string nodeLabel = nodeScript.GetDisplayLabel();

        nodeTemplate.name = nodeLabel + "InterfaceNode" + this.nodeList.Count;

        templateScript.backgroundTexture.material = backgroundMaterial;

        // Clean up template object placeholders
        GameObject.Destroy(templateScript.connectorPlaceholder.gameObject);
        GameObject.Destroy(templateScript.deleteButtonPlaceholder.gameObject);
        GameObject.Destroy(templateScript.indexDisplayPlaceholder.gameObject);
        GameObject.Destroy(templateScript.receiverPlaceholder.gameObject);

        return(nodeTemplate);
    }
Ejemplo n.º 3
0
    public btNodeSelectTile CreateNewTile(btInterfaceTreeManager.INODE_TYPE _nodeType)
    {
        if (this.nodeTilePrefab == null)
        {
            Debug.LogError("No node tile prefab defined", this);
            return(null);
        }

        GameObject tileObj = GameObject.Instantiate(this.nodeTilePrefab) as GameObject;

        tileObj.transform.parent     = this.gridTransform;
        tileObj.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
        btNodeSelectTile tileScript = tileObj.GetComponent <btNodeSelectTile>();

        if (tileScript == null)
        {
            Debug.LogError("Could not find tile script on node tile prefab.", tileObj);
            return(null);
        }
        tileScript.nodeType = _nodeType;

        UIDragCamera dragCameraScript = tileObj.GetComponent <UIDragCamera>();

        if (dragCameraScript == null)
        {
            Debug.LogError("No UIDragCamera script found on tile prefab.", tileObj);
            return(tileScript);
        }
        dragCameraScript.draggableCamera = this.draggableCamera;

        tileScript.buttonScript.nodeType = _nodeType;
        GameObject tempObj = new GameObject();

        tempObj.SetActive(false);
        System.Type type = btInterfaceTreeManager.GetInterfaceNodeType(_nodeType);
        if (type == null)
        {
            Debug.LogError("Could not find matching type for " + _nodeType);
        }
        else
        {
            btInterfaceNode nodeScript   = tempObj.AddComponent(type) as btInterfaceNode;
            string          materialPath = nodeScript.GetIconMaterialPath();
            Object          iconResource = Resources.Load(materialPath);
            if (iconResource == null)
            {
                Debug.LogError("Cannot find material with path \"" + materialPath + "\"");
            }
            else
            {
                Material iconMaterial = iconResource as Material;
                if (iconMaterial == null)
                {
                    Debug.LogError("Resource \"" + iconResource.name
                                   + "\" at path \"" + materialPath
                                   + "\" cannot be converted into a meterial.");
                }
                else
                {
                    tileScript.texture.material = iconMaterial;
                }
            }

            tileScript.label.text = nodeScript.GetDisplayLabel();
        }

        Destroy(tempObj);
        return(tileScript);
    }