Exemplo n.º 1
0
        public override void Awake()
        {
            base.Awake();

            m_simpleStream = gameObject.AddComponent <MvxSimpleDataStream>();
            m_simpleStream.onStreamOpen.AddListener(OnNestedStreamOpenedStream);
            m_simpleStream.onNextFrameReceived.AddListener(OnNestedStreamReceivedNextFrame);
            m_audioStream = gameObject.AddComponent <MvxAudioPlayerStream>();
            m_audioStream.onStreamOpen.AddListener(OnNestedStreamOpenedStream);
            m_audioStream.onNextFrameReceived.AddListener(OnNestedStreamReceivedNextFrame);
        }
Exemplo n.º 2
0
        public override void OnDestroy()
        {
            if (m_simpleStream != null)
            {
                m_simpleStream.onStreamOpen.RemoveListener(OnNestedStreamOpenedStream);
                m_simpleStream.onNextFrameReceived.RemoveListener(OnNestedStreamReceivedNextFrame);
                Destroy(m_simpleStream);
                m_simpleStream = null;
            }

            if (m_audioStream != null)
            {
                m_audioStream.onStreamOpen.RemoveListener(OnNestedStreamOpenedStream);
                m_audioStream.onNextFrameReceived.RemoveListener(OnNestedStreamReceivedNextFrame);
                Destroy(m_audioStream);
                m_audioStream = null;
            }

            base.OnDestroy();
        }
Exemplo n.º 3
0
        private static void CreateFileSourceStreamWithThumbnail <RendererType>() where RendererType : MvxMeshRenderer
        {
            GameObject wrapGO = new GameObject("FileSimpleStream");

            wrapGO.transform.SetParent(null);
            wrapGO.transform.localPosition = Vector3.zero;
            wrapGO.transform.localRotation = Quaternion.identity;
            wrapGO.transform.localScale    = Vector3.one;

            GameObject streamGO = new GameObject("RuntimeStream");

            streamGO.transform.SetParent(wrapGO.transform);
            streamGO.transform.localPosition = Vector3.zero;
            streamGO.transform.localRotation = Quaternion.identity;
            streamGO.transform.localScale    = new Vector3(0.01f, 0.01f, 0.01f);

            MvxFileDataStreamDefinition streamDefinition = ScriptableObject.CreateInstance <MvxFileDataStreamDefinition>();
            MvxSimpleDataStream         streamGOStream   = streamGO.AddComponent <MvxSimpleDataStream>();

            streamGOStream.dataStreamDefinition = streamDefinition;
            MvxMeshRenderer renderer = streamGO.AddComponent <RendererType>();

            renderer.mvxStream = streamGOStream;

            GameObject thumbnailGO = new GameObject("StreamThumbnail");

            thumbnailGO.transform.SetParent(wrapGO.transform);
            thumbnailGO.transform.localPosition = Vector3.zero;
            thumbnailGO.transform.localRotation = Quaternion.identity;
            thumbnailGO.transform.localScale    = new Vector3(0.01f, 0.01f, 0.01f);

            MvxDataStreamThumbnail thumbnailGOStream = thumbnailGO.AddComponent <MvxDataStreamThumbnail>();

            thumbnailGOStream.dataStreamDefinition = streamDefinition;
            renderer           = thumbnailGO.AddComponent <RendererType>();
            renderer.mvxStream = thumbnailGOStream;

            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }