Показать сообщение отдельно
Старый 01.02.2013, 19:13   #131
mepihin
ПроЭктировщик
 
Регистрация: 31.12.2012
Сообщений: 165
Написано 5 полезных сообщений
(для 7 пользователей)
Ответ: Вотпросы от mepihin!

Сообщение от Lestar Посмотреть сообщение
AudioSource[] AOAS = FindObjectsOfType(typeof(AudioSource)) as AudioSource[];
      for (int i = 0; i < AOAS.Length; i++)
	    {
	        AOAS[i].Pause();
	    }
Спасибо, но вот как теперь продолжать то звук???
using UnityEngine;
using System.Collections;

public class 
Pause MonoBehaviour {
    
    public 
bool IsPause false;
    private 
CharacterController controller;
    
void Start()
    {
        
controller transform.GetComponent<CharacterController>();    
    }
    
    
void Update()
    {
        
AudioSource[] AOAS FindObjectsOfType(typeof(AudioSource)) as AudioSource[];
        if(
Input.GetKeyDown(KeyCode.Escape) && IsPause == false && controller.isGrounded)
        {
            
Time.timeScale 0;
            
transform.GetComponent<MouseLook>().enabled false;
            
transform.FindChild("Main Camera").GetComponent<MouseLook>().enabled false;
                  for (
int i 0AOAS.Lengthi++)
                    {
                        
AOAS[i].Pause();
                    }
            
IsPause true;
        }
        else
        {
            if(
Input.GetKeyDown(KeyCode.Escape) && IsPause == true)
            {
                
Time.timeScale 1;
                
transform.GetComponent<MouseLook>().enabled true;
                
transform.FindChild("Main Camera").GetComponent<MouseLook>().enabled true;
                  for (
int i 0AOAS.Lengthi--)
                    {
                        
AOAS[i].Play();
                    }                
                
IsPause false;
            }                
        }
    }
    

(Offline)
 
Ответить с цитированием