当前位置: 首页>>代码示例>>C#>>正文


C# AudioSource.PlayScheduled方法代码示例

本文整理汇总了C#中UnityEngine.AudioSource.PlayScheduled方法的典型用法代码示例。如果您正苦于以下问题:C# AudioSource.PlayScheduled方法的具体用法?C# AudioSource.PlayScheduled怎么用?C# AudioSource.PlayScheduled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.AudioSource的用法示例。


在下文中一共展示了AudioSource.PlayScheduled方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetupLoop

	void SetupLoop() {
		sourceTwo = gameObject.AddComponent<AudioSource> ();
		sourceTwo.playOnAwake = false;
		sourceTwo.clip = songClip;
		sourceTwo.timeSamples = introEndInSamples;
		sourceTwo.PlayScheduled (introEndTime);
		sourceTwo.SetScheduledEndTime (nextLoopSwap);
		InvokeRepeating ("SwapLoop", (float) ((introEndInSamples * oneSampleInSeconds) + 1.0f), (float) loopTime);
	}
开发者ID:rbibler,项目名称:Super-Zombie-Skater-Invasion,代码行数:9,代码来源:Song.cs

示例2: Awake

	// Use this for initialization
	void Awake() {
		sourceOne = gameObject.AddComponent<AudioSource> ();
		sourceOne.clip = songClip;
		oneSampleInSeconds = 1.0 / songClip.frequency;
		loopTime = loopInSamples * oneSampleInSeconds;
		introEndTime = AudioSettings.dspTime + (introEndInSamples * oneSampleInSeconds);
		nextLoopSwap = introEndTime + loopTime;
		sourceOne.PlayScheduled(AudioSettings.dspTime);
		sourceOne.SetScheduledEndTime (introEndTime);
		Invoke ("SetupLoop", 2.0f);
	}
开发者ID:rbibler,项目名称:Super-Zombie-Skater-Invasion,代码行数:12,代码来源:Song.cs

示例3: OnLevelWasLoaded

    void OnLevelWasLoaded()
    {
        GameObject.Find("Canica").GetComponent<Rigidbody>().useGravity = false;
        time = 4;
        count = true;
        var match = Regex.Match(Application.loadedLevelName, @"^([^0-9]+)([0-9]+)$");
        levelNum = int.Parse(match.Groups[2].Value);

        music = GameObject.Find("music").GetComponent<AudioSource>();
        music.Stop();
        music.volume = 0f;
        music.PlayScheduled(time);  // This gives time for the AudioSource to load properly.
    }
开发者ID:gcpmendez,项目名称:II_UnityGameProject,代码行数:13,代码来源:StartCountdown.cs

示例4: Play

    public void Play(int songID, int difficultyLevel)
    {
        Debug.Log ("PLAYING THE SOOOONG");
        initializeDifficulty (difficultyLevel);
        TrackManager.loadMidi (Songs [songID]);
        if(OnLoadTrack != null) {
            trackStartTime = GetTime() + 1.0f;
            OnLoadTrack(this, new OnLoadTrackEventArgs(trackStartTime + magicNumberfix));
            //Debug.Log("TrackManager: "+trackManager);
            //Debug.Log("Track: "+trackManager.Track);

            audioSource = gameObject.AddComponent<AudioSource>();
            audioSource.clip = BackgroundAudio [songID];
            audioSource.clip.LoadAudioData();
            audioSource.PlayScheduled(trackStartTime);

            Invoke("SendPlayEvent",1.0f);
        }
    }
开发者ID:simphax,项目名称:ar-drum-coach,代码行数:19,代码来源:GameController.cs

示例5: Start

    void Start()
    {
        Random.seed = 123;

        filejson = (TextAsset)Resources.Load (fileNamejson + songName);
        testData = JSON.Parse (filejson.text);

        Debug.Log ("there are " + testData.Count + " tracks for this song - you need params for each!");

        // make an index for each track (for incrementing through the notes while playing the song)
        for (int i = 0; i < testData.Count; i++) {
            track_idxs.Add (0);
        }

        // let's figure out the max and min world coords currently visible with our screen dimensions
        //Debug.Log (Screen.height + " " + Screen.width);
        float camera_distance = main_camera.transform.position.z;
        Vector3 upper_right = main_camera.ScreenToWorldPoint (new Vector3 (0f, 0f, camera_distance));
        //Vector3 bottom_left = main_camera.ScreenToWorldPoint(new Vector3(Screen.width,Screen.height,camera_distance));

        bounds = new Vector2 (upper_right.x, upper_right.y);
        Debug.Log ("world coordinates boundaries " + bounds);

        audio_source = gameObject.AddComponent<AudioSource> ();
        audio_source.clip = song_audio;
        audio_source.volume = 0.1f;
        audio_source.PlayScheduled (AudioSettings.dspTime + initial_delay); // 2 second delay

        bg_container.transform.localScale = new Vector3 (bounds.x / 5.6f, bounds.y / 5.6f, 1.0f); // set background size to fill screen

        current_enemy_color = enemy_colors [0];
    }
开发者ID:ryanmp,项目名称:MusicDodgerOld,代码行数:32,代码来源:LevelSettings.cs

示例6: Start

    // Use this for initialization
    void Start()
    {
        Random.seed = 123;

        QualitySettings.antiAliasing = 2;
        Application.targetFrameRate = 120;

        int num_outlines = 7;
        float max_alpha = 0.2f;
        float zoom_factor = 1.1f;
        for (int i = 0; i < num_outlines; i++) {
            GameObject level_clone = Instantiate (level_outline, new Vector3 (0f, 0f, i * zoom_factor), Quaternion.identity) as GameObject;
            //GameObject obstacle_clone = Instantiate (level_obstacle, new Vector3 (-1.5f, -1.5f, i * zoom_factor), Quaternion.identity) as GameObject;

            Color c = level_color;
            if (i == 0) {
                level_clone.GetComponent<SpriteRenderer> ().color = new Color (c.r, c.g, c.b, 1f);
                //obstacle_clone.GetComponent<SpriteRenderer> ().color = new Color (c.r, c.g, c.b, 1f);
            } else {
                level_clone.GetComponent<SpriteRenderer> ().color = new Color (c.r, c.g, c.b, max_alpha * (1f - (i * 1.0f / num_outlines * 1.0f)));
                //obstacle_clone.GetComponent<SpriteRenderer> ().color = new Color (c.r, c.g, c.b, max_alpha * (1f - (i * 1.0f / num_outlines * 1.0f)));
            }
        }

        // read in level from file
        TextAsset l = Resources.Load ("2") as TextAsset;
        string[] lines = l.text.Split ("\n" [0]);
        grid_dimensions = lines.Length;
        int[] block_types = { 0,1,2 };
        for (int i = 0; i < lines.Length; i++) {
            for (int j = 0; j < lines[0].Length; j++) {
                double this_block = char.GetNumericValue (lines [i] [j]);
                int x = j - grid_dimensions / 2;
                int y = (i - grid_dimensions / 2) * -1;
                if (this_block >= 0f) {
                    blocks.Add (new Vector3 (x, y, (float)this_block));
                }
            }
        }

        // create init blocks
        foreach (Vector3 b_position in blocks) {
            int z = (int)b_position.z;
            if (z == 0) { // fixed block type
                GameObject clone = Instantiate (fixed_block, new Vector2 (b_position.x, b_position.y), Quaternion.identity) as GameObject;
            } else { //moveable block type
                GameObject clone = Instantiate (block, new Vector2 (b_position.x, b_position.y), Quaternion.identity) as GameObject;
                clone.GetComponent<SpriteRenderer> ().color = block_colors [z - 1];
                clone.transform.parent = c_holder.transform;
                //blocks_obs.Add (clone);
            }
        }

        // build level bounding box
        string[] names = new string[]{"bottom","top","left","right"};

        float wall_w = 1f;
        float line_w = 0.3f;

        Vector3[] positions = new Vector3[]{
            new Vector3 (0f, (-1f * grid_dimensions - wall_w + line_w) / 2f, 0f),
            new Vector3 (0f, (grid_dimensions + wall_w - line_w) / 2f, 0f),
            new Vector3 ((-1f * grid_dimensions - wall_w + line_w) / 2f, 0f, 0f),
            new Vector3 ((grid_dimensions + wall_w - line_w) / 2f, 0f, 0f)
        };
        Vector3[] scales = new Vector3[]{
            new Vector3 (grid_dimensions + wall_w * 2, wall_w, 0f),
            new Vector3 (grid_dimensions + wall_w * 2, wall_w, 0f),
            new Vector3 (wall_w, grid_dimensions, 0f),
            new Vector3 (wall_w, grid_dimensions, 0f)
        };

        for (int i = 0; i < names.Length; i++) {
            GameObject o = new GameObject (names [i]);
            o.transform.localScale = scales [i];
            o.transform.parent = gameObject.transform;
            o.AddComponent<BoxCollider2D> ();
            o.GetComponent<BoxCollider2D> ().sharedMaterial = default_physics_mat;
            o.transform.position = positions [i];
        }

        Physics2D.gravity = new Vector2 (0f, 0f);
        Physics.gravity = new Vector3 (0f, 0f, 0f);

        //InvokeRepeating ("ChangeGravity", 3f, 3f);
        //Invoke ("CreateEnemy", 2f);

        file_json = (TextAsset)Resources.Load (file_path + song_name);
        testData = JSON.Parse (file_json.text);
        Debug.Log ("there are " + testData.Count + " tracks for this song - you need params for each!");

        /// starts song!
        audio_source = gameObject.AddComponent<AudioSource> ();
        audio_source.clip = song_audio;
        audio_source.volume = 1f;
        audio_source.PlayScheduled (AudioSettings.dspTime + init_song_delay); // 2 second delay

        // make an index for each track (for incrementing through the notes while playing the song)
        for (int i = 0; i < testData.Count; i++) {
//.........这里部分代码省略.........
开发者ID:ryanmp,项目名称:SlideBlockPuzzle,代码行数:101,代码来源:GenerateLevel.cs


注:本文中的UnityEngine.AudioSource.PlayScheduled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。