Ejemplo n.º 1
0
    void SlicerEvent(Slice2D slice)
    {
        if (timer.GetMillisecs() < 15)
        {
            return;
        }

        if (clip == null)
        {
            return;
        }

        timer.Reset();

        GameObject sound = new GameObject();

        sound.name = "Audio Clip '" + clip.name + "'";

        sound.transform.parent = Slicer2DSoundManager.Get().transform;

        AudioSource audio = sound.AddComponent <AudioSource>();

        audio.clip    = clip;
        audio.enabled = false;
        audio.enabled = true;

        sound.AddComponent <DestroyTimer>();
    }
    static public Slicer2DSoundManager Get()
    {
        if (instance != null)
        {
            return(instance);
        }

        foreach (Slicer2DSoundManager manager in Object.FindObjectsOfType(typeof(Slicer2DSoundManager)))
        {
            instance = manager;
            return(instance);
        }

        // Create New Light Manager
        GameObject gameObject = new GameObject();

        gameObject.name = "Slicer2D Sound Manager";

        instance = gameObject.AddComponent <Slicer2DSoundManager>();

        return(instance);
    }