Пример #1
0
    /*
     *      Spawns a soundblock with specific values
     */
    public void SpawnSoundBlock(Vector3 position, int blockID, int clipId, bool isLooping)
    {
        Debug.Log("Spawning Soundblock " + blockID + " with " + clipId);
        GameObject blockGO = GameObject.Instantiate(SoundBlockPrefab, Vector3.zero, Quaternion.identity);

        blockGO.transform.SetParent(AppManager.Instance.GUIManager.scenarioOrigin, false);
        blockGO.transform.localPosition = position;

        // Set the audio on the soundblock
        SoundBlock soundBlock = blockGO.GetComponent <SoundBlock>();

        soundBlock.UpdateSoundlist();
        soundBlock.soundblockId = blockID;

        AudioSource source = soundBlock.GetComponent <AudioSource>();

        source.loop = isLooping;

        if (clipId != -1)
        {
            soundBlock.SetClip(AppManager.Instance.ResourcesManager.GetResource(clipId).Name);
        }

        // check if soundblock is the first, if so it is the entry point of the scenario
        if (blocks.Count == 0)
        {
            firstBlock = soundBlock;
            firstBlock.GetComponent <Image>().color = Color.green;
            firstBlock.rear.gameObject.SetActive(false);
        }

        blocks.Add(soundBlock);
        Debug.Log("Spawned Soundblock " + blockID);
    }