コード例 #1
0
    private void Start()
    {
        // make sure current index is 0
        currMenuIndex = 0;

        // we disable all the colliders on the menu objects
        foreach (RubeObject o in objects)
        {
            ControllerGrabObject.ToggleColliders(o.menuPlaceholder, false);
        }

        // set the text
        SetUIText(objects[currMenuIndex].name, objects[currMenuIndex].count);

        // make sure the object menu spawns a little forward of the controller
        objectMenuUI.transform.localPosition = new Vector3(0f, 0f, 0.65f);
    }
コード例 #2
0
    // this function is used to spawn the object that is being shown on the menu (if active)
    private void SpawnCurrentMenuObject()
    {
        // check that we can spawn specific item
        if (objects[currMenuIndex].count > 0)
        {
            // Instantiate the prefab
            GameObject go = Instantiate(objects[currMenuIndex].prefab, objectMenuUI.transform.position, objectMenuUI.transform.rotation);

            // turn on the colliders
            ControllerGrabObject.ToggleColliders(go, true);

            // decrement the count
            objects[currMenuIndex].count--;

            // set the text
            SetUIText(objects[currMenuIndex].name, objects[currMenuIndex].count);
        }
    }