예제 #1
0
    private static void InitiateAudio()
    {
        string audioSourceUid = Torch.CreateObject(null);

        Torch.SetPrefab(audioSourceUid, audioPrefabPath);
        soundSourceUID = audioSourceUid;
    }
예제 #2
0
    public static void CreateSoundEffect(string url, Vector3 playPos)
    {
        string uid = Torch.CreateObject(null);

        Torch.SetPrefab(uid, "Prefabs/SoundEffect");
        GameObject audioPlayer = Torch.GetTransform(uid).gameObject;

        Torch.SetTransformPosition(uid, playPos);
        AudioClip clip = (AudioClip)Resources.Load(url, typeof(AudioClip));

        if (clip == null)
        {
            return;
        }

        AudioSource source = (AudioSource)audioPlayer.GetComponent("AudioSource");

        if (source == null)
        {
            source = (AudioSource)audioPlayer.AddComponent <AudioSource>();
        }
        source.clip   = clip;
        source.loop   = false;
        source.volume = 1.0f;
        source.Play();
        source.DOFade(0f, 1f).OnComplete(() => Torch.DestroyObject(uid));
    }
예제 #3
0
    public static void GameEnter()
    {
        Debug.Log("We have Entered the game");
        string[] scriptChain = { "ExampleChain" };
        for (int i = 0; i < 100; i++)
        {
            string uid = Torch.CreateObject(null, scriptChain);
            Torch.SetPrefab(uid, "Cube");
            Torch.SetTransformPosition(uid, new Vector3(Random.value * 10, Random.value * 10, Random.value * 10));
        }

        string textUID = Torch.CreateObject(null);

        Torch.SetPrefab(textUID, "Text", true);
        Torch.SetUIPosition(textUID, new Vector2(Screen.width / 2, Screen.height / 2));



        Torch.SwitchSceneAsych("ExampleScene", SceneLoadCompleteCallback);
    }