Exemplo n.º 1
0
        // create api instance
        static public AudioReader CreateAudioReader(int apiKey)
        {
            AudioReader instance = new AudioReader(apiKey);

            if (instance.ApiKey == -1)
            {
                return(null);
            }

            return(instance);
        }
        public void Uninitialize()
        {
            if (isPlaying)
            {
                Pause();
            }

            if (!isInitialized)
            {
                return;
            }

            ReaderAPIPRM.UnityPluginUnload();
            meshReader = null;

            audioReader   = null;
            isOpened      = false;
            isInitialized = false;
        }
        //-----------------------------//
        //- Functions                 -//
        //-----------------------------//

        public void Initialize()
        {
            if (isInitialized && meshReader != null)
            {
                return;
            }

            if (debugInfo)
            {
                DebugDelegate callback_delegate = new DebugDelegate(CallbackDebug);
                System.IntPtr intptr_delegate   = Marshal.GetFunctionPointerForDelegate(callback_delegate);
                ReaderAPIPRM.SetDebugFunction(intptr_delegate);
            }

            //initial mesh reader
            if (meshReader == null)
            {
                meshReader = MeshReaderPRM.CreateMeshReader(ref apiKey);
                if (meshReader == null)
                {
                    Debug.Log("[MeshPlayerPlugin][WARNING] Create Reader Instance Failed");
                    return;
                }
            }

            //initial audio reader
            if (audioReader == null)
            {
                audioReader = AudioReader.CreateAudioReader(meshReader.GetMeshApiKey());
                if (audioReader == null)
                {
                    Debug.Log("[MeshPlayerPlugin][WARNING] Create Reader Instance Failed");
                    return;
                }
            }
            meshComponent     = GetComponent <MeshFilter>();
            rendererComponent = GetComponent <Renderer>();

            isFirstMeshDataArrived  = false;
            isFirstAudioDataArrived = false;
            isFirstAudioPtsRecord   = false;
            isInitialized           = true;
        }