Ejemplo n.º 1
0
    public void Play(float volume, float pitch, GameObject target, string endCallback)
    {
        if (target != null && !string.IsNullOrEmpty(endCallback))
        {
            targets.Add(new ObjectCallback(target, endCallback));
        }
        else
        {
            targets.Add(new ObjectCallback(null, string.Empty));
        }

        CancelInvoke("UnloadClip");
        LoadClip();

        if (audioClip != null)
        {
            if (Debug.isDebugBuild)
            {
                Debug.Log("[Play Clip] [OK] " + path);
            }
            SoundTool.PlaySound(audioClip, volume, pitch);

            if (freq == UsedFrequent.Low)
            {
                Invoke("UnloadClip", audioClip.length + END_SOUND_CALLBACK_DELAY);
            }
            else if (freq == UsedFrequent.High)
            {
                Invoke("CallBack", audioClip.length + END_SOUND_CALLBACK_DELAY);
            }
        }
    }
Ejemplo n.º 2
0
    static void Init()
    {
        soundData = ScriptableObject.CreateInstance <SoundData>();
        soundData.LoadData();
        SoundTool window = (SoundTool)EditorWindow.GetWindow <SoundTool>(false, "Sound Tool");

        window.Show();
    }
Ejemplo n.º 3
0
    static void Int()
    {
        soundData = CreateInstance <SoundData>();
        soundData.LoadData();

        SoundTool window = GetWindow <SoundTool>(false, "Sound Tool");

        window.Show();
    }
    static void init()
    {
        soundData = ScriptableObject.CreateInstance <SoundData>();
        soundData.LoadData();

        //EffectTool 클래스를 생성하여 보여줌
        SoundTool window = GetWindow <SoundTool>(false, "Sound Tool");

        window.Show();
    }
Ejemplo n.º 5
0
    public void Awake()
    {
#if UNITY_EDITOR
        Editor = true;
#endif

        if (Inst == null)
        {
            Inst = this;
        }
        else if (Inst != null)
        {
            Destroy(this.gameObject);   //防止重复创建
            return;
        }

        _mainThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId;
        DontDestroyOnLoad(gameObject);

        //Application.targetFrameRate = GlobalData.FRAME_RATE;
        UIConfig.defaultFont = "Microsoft YaHei";

        //GamePath.Init(Editor);
        //AssetManager.Init(Editor);
        //UIObjectFactory.SetLoaderExtension(typeof(MyGLoader));

        SoundTool soundTool = SoundTool.inst;   //提前初始化

        TemplateManager templateMgr = new TemplateManager(new TemplateList());
        templateMgr.LoadAllXml();

        WinTool.RegisteWindows();                      // 注册窗口

        EnemyActionReg.InitAction();

        CoreDebug();
    }
Ejemplo n.º 6
0
    public void OnGUI()
    {
        float w      = BUTTON_WIDTH;
        float h      = BUTTON_HEIGHT;
        float x      = 2;
        float y      = Screen.height * 0.75f;
        float fieldH = 30;

        // Log
        GUI.Label(new Rect(0, 0, Screen.width, y), mLogString.ToString());
        y += 5;


        x = 2;
        GUI.Label(new Rect(x, y, w, h), "RoomId:"); x += 100;
        mRoomId = GUI.TextField(new Rect(x, y, 100, fieldH), mRoomId);
        y      += fieldH + 5;

        x = 2;
        GUI.Label(new Rect(x, y, w, h), "Message:"); x += 100;
        mMsg = GUI.TextField(new Rect(x, y, Screen.width - x - 2, fieldH), mMsg);
        y   += fieldH + 5;


        x = 2;
        y = Screen.height - BUTTON_HEIGHT - 5;
        if (GUI.Button(new Rect(x, y, w, h), "Init"))
        {
            Log("Init");
            if (!WebRtcSDK.Instance.SdkInited)
            {
                WebRtcSDK.Instance.InitSDK(this, host, port, iceServers);
            }
        }
        x += w + 5;

        if (GUI.Button(new Rect(x, y, w, h), "Join"))
        {
            Log("Join room: " + mRoomId);
            if (!WebRtcSDK.Instance.IsChating)
            {
                WebRtcSDK.Instance.JoinRoom(mRoomId);
            }
        }
        x += w + 5;

        if (GUI.Button(new Rect(x, y, w, h), "Leave"))
        {
            Log("Leave room: " + mRoomId);
            WebRtcSDK.Instance.LeaveRoom(mRoomId);
        }
        x += w + 5;

        if (GUI.Button(new Rect(x, y, w, h), "SendMsg"))
        {
            Log("Send message to " + mRoomId + " : " + mMsg);
            WebRtcSDK.Instance.SendMsg(mRoomId, mMsg);
        }
        x += w + 5;

        if (GUI.Button(new Rect(x, y, w, h), (mMPMute ? "MPMute" : "MPActive")))
        {
            mMPMute = !mMPMute;
            Log("MPMute: " + (mMPMute ? "1" : "0"));
            WebRtcSDK.Instance.MuteMicrophone(mRoomId, mMPMute ? 1 : 0);
        }
        x += w + 5;

        if (GUI.Button(new Rect(x, y, w, h), (mEPMute ? "EPMute" : "EPActive")))
        {
            mEPMute = !mEPMute;
            Log("mEPMute: " + (mEPMute ? "1" : "0"));
            WebRtcSDK.Instance.MuteEarPhone(mRoomId, mEPMute ? 1 : 0);
        }
        x += w + 5;

        if (GUI.Button(new Rect(x, y, w, h), (mSpeakerMute ? "SpeakerMute" : "SpeakerActive")))
        {
            mSpeakerMute = !mSpeakerMute;
            Log("mSpeakerMute: " + (mSpeakerMute ? "1" : "0"));
            WebRtcSDK.Instance.MuteSpeaker(mRoomId, mSpeakerMute ? 1 : 0);
        }
        x += w + 5;

        //背景音效
        if (GUI.Button(new Rect(Screen.width - BUTTON_WIDTH, 0, w, h), "PlaySound"))
        {
            Log("PlaySound... ");
            bgSound = SoundTool.Play("test_bgm", 1, 1, 0, true, SoundDef.BGM);
        }
        if (GUI.Button(new Rect(Screen.width - BUTTON_WIDTH, h + 5, w, h), "IsPlaying"))
        {
            bool isPlaying = false;
            if (bgSound != null)
            {
                isPlaying = bgSound.IsPlaying();
            }
            Log("IsPlaying:" + isPlaying);
        }
        if (GUI.Button(new Rect(Screen.width - BUTTON_WIDTH, 2 * h + 5, w, h), "SetVolume"))
        {
            Log("SetVolume... " + sliderValue);
            SoundTool.SetVolume(SoundDef.BGM, sliderValue);
        }

        sliderValue = GUI.HorizontalSlider(new Rect(Screen.width - BUTTON_WIDTH - 200, 2 * h + 20, 200, 50), sliderValue, 0.0f, 1.0f);
    }
Ejemplo n.º 7
0
 public void StopAllSound()
 {
     SoundTool.StopSound();
 }