Пример #1
0
    public void MoveObject()
    {
        TapToPlaceOnce tapToPlace = this.GetComponent <TapToPlaceOnce>();

        //set needed properties
        tapToPlace.HasBeenPlaced = false;
        tapToPlace.IsBeingPlaced = true;
    }
Пример #2
0
    // move object, doesn't work
    public void MoveAudioObject()
    {
        Debug.Log("clicked moveAudioObject");

        TapToPlaceOnce tapToPlace = audioObject.GetComponent <TapToPlaceOnce>();

        //find volumeSlider
        slider.SetActive(false);

        //set needed properties
        tapToPlace.HasBeenPlaced = false;
        tapToPlace.IsBeingPlaced = true;
    }
    public void SpawnAudioObject(GameObject audioObject)
    {
        //Spawns the selected Audio Object via the button in the menu at the position of the mouse/menu
        //and afterwards plays the Menu-close animation, and disables the menu.
        Debug.Log("Clicked audio button");
        Debug.Log("MENU pos = " + this.gameObject.transform.position);
        Debug.Log("BUTTON pos = " + Input.mousePosition);

        Vector3 newPos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, Input.mousePosition.z);

        Instantiate(audioObject, newPos, Quaternion.identity);

        //set audioObject settings
        AudioSource attachedAudio = audioObject.GetComponentInChildren <AudioSource>();

        attachedAudio.spatialize = true;
        attachedAudio.spread     = 0;
        //spatialBlend allows to hear spatialized sounds
        attachedAudio.spatialBlend = 1;
        //optional: set space size, see enum ROOMSIZES
        //attachedAudio.SetSpatializerFloat(1, (float)room);

        //search for present TapToPlace component
        if (!audioObject.GetComponent <TapToPlaceOnce>())
        {
            audioObject.AddComponent <TapToPlaceOnce>();
        }
        TapToPlaceOnce tapToPlace = audioObject.GetComponent <TapToPlaceOnce>();

        //set needed properties
        tapToPlace.IsBeingPlaced = true;
        tapToPlace.AllowMeshVisualizationControl = true;
        tapToPlace.HasBeenPlaced = false;

        if (GameObject.FindGameObjectWithTag("Menu").GetComponent <TapToPlace>() == true)
        {
            //GameObject.FindGameObjectWithTag("Menu").GetComponent<TapToPlace>().enabled = false;
            //GameObject.FindGameObjectWithTag("Menu").GetComponentInChildren<TapToPlace>().enabled = true;
            //Destroy(GameObject.FindGameObjectWithTag("Menu").GetComponent<TapToPlace>());
        }
    }
 void Start()
 {
     _tapToPlace = gameObject.GetComponent <TapToPlaceOnce>();
 }