add CRIWARE support.
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "CriMw.CriWare.Runtime",
|
||||
"references": [
|
||||
"Unity.Timeline"
|
||||
],
|
||||
"optionalUnityReferences": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [
|
||||
{
|
||||
"name": "com.unity.timeline",
|
||||
"expression": "1.0.0",
|
||||
"define": "CRIWARE_TIMELINE_1_OR_NEWER"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 800597811bcc5d848b15e12807d6de45
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2aec2f381367b8e4897166bdbe92fb9b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0513e446cdd53d344b6394b88cec50fb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3c1f75350d960914cb70909e86065ca3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 497dbcc8f29bc4f4491b76ffb68daeca
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b4f3b826ae7019f4cbc0122e140dda20
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+356
@@ -0,0 +1,356 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2018 CRI Middleware Co., Ltd.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if !UNITY_EDITOR && UNITY_ANDROID
|
||||
|
||||
using UnityEngine;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace CriWare {
|
||||
|
||||
namespace CriMana.Detail
|
||||
{
|
||||
public static partial class AutoResisterRendererResourceFactories
|
||||
{
|
||||
[RendererResourceFactoryPriority(7000)]
|
||||
public class RendererResourceFactoryAndroidH264Rgb : RendererResourceFactory
|
||||
{
|
||||
public override RendererResource CreateRendererResource(int playerId, MovieInfo movieInfo, bool additive, Shader userShader)
|
||||
{
|
||||
bool isCodecSuitable = movieInfo.codecType == CodecType.H264 && !CriManaPlugin.criManaUnity_IsBufferOutputForH264Enabled_ANDROID();
|
||||
bool isGraphicsApiSuitable = (UnityEngine.SystemInfo.graphicsDeviceType != UnityEngine.Rendering.GraphicsDeviceType.Vulkan);
|
||||
bool isSuitable = isCodecSuitable && isGraphicsApiSuitable;
|
||||
return isSuitable
|
||||
? new RendererResourceAndroidH264Rgb(playerId, movieInfo, additive, userShader)
|
||||
: null;
|
||||
}
|
||||
|
||||
protected override void OnDisposeManaged()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisposeUnmanaged()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public class RendererResourceAndroidH264Rgb : RendererResource
|
||||
{
|
||||
private const int RenderEventAction_ATTACH = (int)Player.CriManaUnityPlayer_RenderEventAction.DESTROY + 1;
|
||||
|
||||
private int playerId;
|
||||
|
||||
private int width;
|
||||
private int height;
|
||||
private int dispWidth;
|
||||
private int dispHeight;
|
||||
private int alphaWidth;
|
||||
private int alphaHeight;
|
||||
private bool useUserShader;
|
||||
|
||||
private Vector4 movieTextureST = new Vector4(1, -1, 0, 1);
|
||||
private Vector4 alphaTextureST = Vector4.zero;
|
||||
private Texture2D[] textures;
|
||||
private System.IntPtr[] nativePtrs = new System.IntPtr[1];
|
||||
|
||||
private bool needsUpdateTexture = false;
|
||||
private bool needsToDetachInitTexture = false;
|
||||
private bool areTexturesUpdated = false;
|
||||
|
||||
private bool isStoppingForSeek = false;
|
||||
private bool isStartTriggered = true;
|
||||
private System.UInt32 nativeTextureId;
|
||||
|
||||
public RendererResourceAndroidH264Rgb(int playerId, MovieInfo movieInfo, bool additive, Shader userShader)
|
||||
{
|
||||
this.playerId = playerId;
|
||||
width = (int)movieInfo.width;
|
||||
height = (int)movieInfo.height;
|
||||
dispWidth = (int)movieInfo.dispWidth;
|
||||
dispHeight = (int)movieInfo.dispHeight;
|
||||
|
||||
hasAlpha = movieInfo.hasAlpha;
|
||||
if (hasAlpha) {
|
||||
alphaWidth = Ceiling32(Ceiling16(CeilingWith(width, 8)));
|
||||
alphaHeight = CeilingWith(height, 16);
|
||||
}
|
||||
this.additive = additive;
|
||||
useUserShader = userShader != null;
|
||||
|
||||
if (userShader != null) {
|
||||
shader = userShader;
|
||||
} else {
|
||||
string shaderName = "CriMana/AndroidH264Rgb";
|
||||
shader = Shader.Find(shaderName);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDisposeManaged()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisposeUnmanaged()
|
||||
{
|
||||
DisposeTextures(textures);
|
||||
textures = null;
|
||||
}
|
||||
|
||||
public override bool IsPrepared()
|
||||
{ return true; }
|
||||
|
||||
public override bool ContinuePreparing()
|
||||
{ return true; }
|
||||
|
||||
public override bool IsSuitable(int playerId, MovieInfo movieInfo, bool additive, Shader userShader)
|
||||
{
|
||||
bool isPlayerSuitable = playerId == this.playerId;
|
||||
bool isCodecSuitable = movieInfo.codecType == CodecType.H264;
|
||||
bool isSizeSuitable = (width == (int)movieInfo.width) && (height == (int)movieInfo.height);
|
||||
bool isAlphaSuitable = hasAlpha == movieInfo.hasAlpha;
|
||||
bool isAdditiveSuitable = this.additive == additive;
|
||||
bool isShaderSuitable = this.useUserShader ? (userShader == shader) : true;
|
||||
return isPlayerSuitable && isCodecSuitable && isSizeSuitable && isAlphaSuitable && isAdditiveSuitable && isShaderSuitable;
|
||||
}
|
||||
|
||||
public override bool OnPlayerStopForSeek()
|
||||
{
|
||||
if (textures == null) {
|
||||
return true;
|
||||
}
|
||||
isStoppingForSeek = true;
|
||||
isStartTriggered = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnPlayerStart()
|
||||
{
|
||||
isStartTriggered = true;
|
||||
}
|
||||
|
||||
public override bool ShouldSkipDestroyOnStopForSeek()
|
||||
{ return true; }
|
||||
|
||||
private void forceUpdateMaterialTextures(Texture[] newTextures)
|
||||
{
|
||||
if (currentMaterial != null) {
|
||||
currentMaterial.mainTexture = newTextures[0];
|
||||
currentMaterial.SetTexture("_TextureRGB", newTextures[0]);
|
||||
if (hasAlpha) {
|
||||
currentMaterial.SetTexture("_TextureA", newTextures[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void AttachToPlayer(int playerId)
|
||||
{
|
||||
if (!isStoppingForSeek) {
|
||||
nativeTextureId = 0xffffffff;
|
||||
}
|
||||
criManaUnityPlayer_MediaCodecAttachTexture_ANDROID(playerId, nativeTextureId);
|
||||
needsToDetachInitTexture = true;
|
||||
}
|
||||
|
||||
|
||||
public override bool UpdateFrame(int playerId, FrameInfo frameInfo, ref bool frameDrop)
|
||||
{
|
||||
if (needsToDetachInitTexture) { // only once
|
||||
needsToDetachInitTexture = false;
|
||||
criManaUnityPlayer_MediaCodecDetachTexture_ANDROID(playerId, 0xffffffff);
|
||||
}
|
||||
|
||||
bool isFrameUpdated = CRIWARE9061FF01(playerId, 0, null, frameInfo, ref frameDrop);
|
||||
if (isFrameUpdated && !frameDrop) {
|
||||
needsUpdateTexture = true;
|
||||
}
|
||||
|
||||
return isFrameUpdated;
|
||||
}
|
||||
|
||||
|
||||
public override bool UpdateMaterial(Material material)
|
||||
{
|
||||
if (!areTexturesUpdated) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (currentMaterial != material) {
|
||||
currentMaterial = material;
|
||||
SetupStaticMaterialProperties();
|
||||
}
|
||||
if (textures != null) {
|
||||
material.mainTexture = textures[0];
|
||||
material.SetTexture("_TextureRGB", textures[0]);
|
||||
if (hasAlpha && textures[1] != null) {
|
||||
material.SetTexture("_TextureA", textures[1]);
|
||||
}
|
||||
}
|
||||
material.SetVector("_MovieTexture_ST", movieTextureST);
|
||||
if (hasAlpha) {
|
||||
material.SetVector("_AlphaTexture_ST", alphaTextureST);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void UpdateMovieTextureST(float[] texCoords, float dispWidth, float dispHeight)
|
||||
{
|
||||
movieTextureST.x = texCoords[0];
|
||||
movieTextureST.y = texCoords[1];
|
||||
movieTextureST.z = texCoords[2];
|
||||
movieTextureST.w = texCoords[3];
|
||||
|
||||
float uScale = (dispWidth != alphaWidth) ? ((float)dispWidth - 0.5f) / (float)alphaWidth : 1.0f;
|
||||
float vScale = (dispHeight != alphaHeight) ? ((float)dispHeight - 0.5f) / (float)alphaHeight : 1.0f;
|
||||
alphaTextureST.x = uScale;
|
||||
alphaTextureST.y = -vScale;
|
||||
alphaTextureST.z = 0.0f;
|
||||
alphaTextureST.w = vScale;
|
||||
}
|
||||
|
||||
public override void UpdateTextures()
|
||||
{
|
||||
if (needsUpdateTexture) { // only once by frame (updates texture may be called multiple time because it is by object an camera
|
||||
int numTextures = hasAlpha ? 2 : 1;
|
||||
nativePtrs[0] = System.IntPtr.Zero;
|
||||
bool isTextureUpdated = CRIWAREDA63C3D7(playerId, numTextures, nativePtrs);
|
||||
areTexturesUpdated |= isTextureUpdated;
|
||||
|
||||
if (isTextureUpdated && nativePtrs[0] != System.IntPtr.Zero && isStartTriggered) {
|
||||
needsUpdateTexture = false;
|
||||
var nativeTexture = (NativeTexture)Marshal.PtrToStructure(nativePtrs[0], typeof(NativeTexture));
|
||||
|
||||
if (textures == null) {
|
||||
textures = new Texture2D[2];
|
||||
textures[0] = Texture2D.CreateExternalTexture(width, height, TextureFormat.ARGB32, false, false, new System.IntPtr(nativeTexture.nativePtrRGB));
|
||||
textures[0].wrapMode = TextureWrapMode.Clamp;
|
||||
if (hasAlpha) {
|
||||
#if !UNITY_5_6_OR_NEWER || UNITY_5_6_0 || UNITY_5_6_1
|
||||
TextureFormat format = TextureFormat.Alpha8;
|
||||
#else
|
||||
TextureFormat format = TextureFormat.R8;
|
||||
#endif
|
||||
textures[1] = Texture2D.CreateExternalTexture(alphaWidth, alphaHeight, format, false, false, new System.IntPtr(nativeTexture.nativePtrA));
|
||||
textures[1].wrapMode = TextureWrapMode.Clamp;
|
||||
}
|
||||
if (currentMaterial != null) {
|
||||
forceUpdateMaterialTextures(textures);
|
||||
}
|
||||
nativeTextureId = nativeTexture.nativePtrRGB;
|
||||
} else {
|
||||
textures[0].UpdateExternalTexture(new System.IntPtr(nativeTexture.nativePtrRGB));
|
||||
if (hasAlpha) {
|
||||
textures[1].UpdateExternalTexture(new System.IntPtr(nativeTexture.nativePtrA));
|
||||
}
|
||||
}
|
||||
|
||||
UpdateMovieTextureST(nativeTexture.texCoords, dispWidth, dispHeight);
|
||||
isStoppingForSeek = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
struct NativeTexture
|
||||
{
|
||||
public System.UInt32 nativePtrRGB; // opengl GLuint texture name
|
||||
public System.UInt32 nativePtrA; // opengl GLuint texture name
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public float[] texCoords; // texture coordinates
|
||||
}
|
||||
|
||||
public static bool IsSupported()
|
||||
{
|
||||
if (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Vulkan) {
|
||||
Debug.Log("[CRIWARE] Another RendererResource will be used for Vulkan. Please use CriManaPlugin.IsCodecSupported instead.");
|
||||
return true;
|
||||
}
|
||||
|
||||
/* check if native code for Android MediaCodec is supported by device */
|
||||
if (!criManaUnity_IsMediaCodecSupported_ANDROID((int)SystemInfo.graphicsDeviceType)) {
|
||||
Debug.Log("[CRIWARE] criManaUnity_IsMediaCodecSupported_ANDROID returned false.");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* If OpenGLES2, all devices can render h.264 videos */
|
||||
if (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.OpenGLES2) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Load a shader for rendering test */
|
||||
Shader shader = Shader.Find("CriMana/AndroidH264DummySupportCheck");
|
||||
|
||||
/* Check the compiled shader is supported(only works on old Unity) */
|
||||
if (!shader.isSupported) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Save current active RenderTexture */
|
||||
var current = RenderTexture.active;
|
||||
|
||||
/* Create textures for shader rendering test */
|
||||
Texture2D texture = new Texture2D(1, 1, TextureFormat.ARGB32, false);
|
||||
RenderTexture renderTexture = new RenderTexture(1, 1, 0);
|
||||
renderTexture.Create();
|
||||
/* Create material with the shader */
|
||||
Material material = new Material(shader);
|
||||
/* Render on RenderTexture */
|
||||
Graphics.Blit(texture, renderTexture, material, 0);
|
||||
|
||||
/* Copy pixels of RenderTexture to Texture */
|
||||
RenderTexture.active = renderTexture;
|
||||
texture.ReadPixels(new Rect(0, 0, renderTexture.width, renderTexture.height), 0, 0);
|
||||
texture.Apply();
|
||||
/* Check pixel color */
|
||||
var color = texture.GetPixel(0, 0);
|
||||
bool ret = (color.r == 1.0f) && (color.g == 1.0f) && (color.b == 1.0f);
|
||||
|
||||
/* Reset current active RenderTexture */
|
||||
RenderTexture.active = current;
|
||||
|
||||
/* Cleaning */
|
||||
Material.Destroy(material);
|
||||
Texture2D.Destroy(texture);
|
||||
Texture2D.Destroy(renderTexture);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#region DLL Import
|
||||
#if !CRIWARE_ENABLE_HEADLESS_MODE
|
||||
[DllImport(CriWare.Common.pluginName, CallingConvention = CriWare.Common.pluginCallingConvention)]
|
||||
private static extern bool criManaUnity_IsMediaCodecSupported_ANDROID(int device_type);
|
||||
|
||||
[DllImport(CriWare.Common.pluginName, CallingConvention = CriWare.Common.pluginCallingConvention)]
|
||||
private static extern System.UInt32 criManaUnity_MediaCodecCreateTexture_ANDROID();
|
||||
|
||||
[DllImport(CriWare.Common.pluginName, CallingConvention = CriWare.Common.pluginCallingConvention)]
|
||||
private static extern void criManaUnity_MediaCodecDeleteTexture_ANDROID(System.UInt32 oes_texture);
|
||||
|
||||
[DllImport(CriWare.Common.pluginName, CallingConvention = CriWare.Common.pluginCallingConvention)]
|
||||
private static extern bool criManaUnityPlayer_MediaCodecAttachTexture_ANDROID(int player_id, System.UInt32 oes_texture);
|
||||
|
||||
[DllImport(CriWare.Common.pluginName, CallingConvention = CriWare.Common.pluginCallingConvention)]
|
||||
private static extern void criManaUnityPlayer_MediaCodecDetachTexture_ANDROID(int player_id, System.UInt32 oes_texture);
|
||||
#else
|
||||
private static bool criManaUnity_IsMediaCodecSupported_ANDROID(int device_type) { return true; }
|
||||
private static System.UInt32 criManaUnity_MediaCodecCreateTexture_ANDROID() { return 0x0; }
|
||||
private static void criManaUnity_MediaCodecDeleteTexture_ANDROID(System.UInt32 oes_texture) { }
|
||||
private static bool criManaUnityPlayer_MediaCodecAttachTexture_ANDROID(int player_id, System.UInt32 oes_texture) { return true; }
|
||||
private static void criManaUnityPlayer_MediaCodecDetachTexture_ANDROID(int player_id, System.UInt32 oes_texture) { }
|
||||
#endif
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace CriWare
|
||||
|
||||
#endif
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4d3185896891e4109a5d1e0802757b9e
|
||||
timeCreated: 1445063317
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+341
@@ -0,0 +1,341 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2015-2018 CRI Middleware Co., Ltd.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if !UNITY_EDITOR && UNITY_ANDROID
|
||||
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace CriWare {
|
||||
|
||||
namespace CriMana.Detail
|
||||
{
|
||||
public static partial class AutoResisterRendererResourceFactories
|
||||
{
|
||||
[RendererResourceFactoryPriority(5050)]
|
||||
public class RendererResourceFactoryAndroidSofdecPrimeYuv : RendererResourceFactory
|
||||
{
|
||||
public override RendererResource CreateRendererResource(int playerId, MovieInfo movieInfo, bool additive, Shader userShader)
|
||||
{
|
||||
bool isCodecSuitable = movieInfo.codecType == CodecType.SofdecPrime ||
|
||||
movieInfo.codecType == CodecType.VP9 ||
|
||||
(CriManaPlugin.criManaUnity_IsBufferOutputForH264Enabled_ANDROID() && movieInfo.codecType == CodecType.H264);
|
||||
bool isGraphicsApiSuitable = (UnityEngine.SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.OpenGLES3);
|
||||
bool isSuitable = isCodecSuitable && isGraphicsApiSuitable;
|
||||
return isSuitable
|
||||
? new RendererResourceAndroidSofdecPrimeYuv(playerId, movieInfo, additive, userShader)
|
||||
: null;
|
||||
}
|
||||
|
||||
protected override void OnDisposeManaged()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisposeUnmanaged()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public class RendererResourceAndroidSofdecPrimeYuv : RendererResource
|
||||
{
|
||||
private int width, height;
|
||||
private int chromaWidth, chromaHeight;
|
||||
private int alphaWidth, alphaHeight;
|
||||
private bool useUserShader;
|
||||
private CodecType codecType;
|
||||
|
||||
private const TextureFormat format = TextureFormat.R8;
|
||||
private const TextureFormat formatUV = TextureFormat.RG16;
|
||||
|
||||
private Vector4 movieTextureST = Vector4.zero;
|
||||
private Vector4 movieChromaTextureST = Vector4.zero;
|
||||
private Vector4 movieAlphaTextureST = Vector4.zero;
|
||||
|
||||
private Texture2D[] textures;
|
||||
private int numImages = -1;
|
||||
private int numImagesForYUV = -1;
|
||||
System.IntPtr[] nativePtrs = new System.IntPtr[4];
|
||||
private RenderTexture[] renderTextures;
|
||||
|
||||
private Int32 playerID;
|
||||
private bool areTexturesUpdated = false;
|
||||
private bool isFrameUpdated = false;
|
||||
private bool isStoppingForSeek = false;
|
||||
private bool isStartTriggered = true;
|
||||
|
||||
|
||||
public RendererResourceAndroidSofdecPrimeYuv(int playerId, MovieInfo movieInfo, bool additive, Shader userShader)
|
||||
{
|
||||
CalculateTextureSize(ref width, ref height, (int)movieInfo.width, (int)movieInfo.height, movieInfo.codecType, false);
|
||||
CalculateTextureSize(ref chromaWidth, ref chromaHeight, (int)movieInfo.width, (int)movieInfo.height, movieInfo.codecType, true);
|
||||
|
||||
this.additive = additive;
|
||||
hasAlpha = movieInfo.hasAlpha;
|
||||
useUserShader = userShader != null;
|
||||
codecType = movieInfo.codecType;
|
||||
|
||||
if (userShader != null) {
|
||||
shader = userShader;
|
||||
} else {
|
||||
string shaderName = "CriMana/AndroidSofdecPrimeYuv";
|
||||
shader = Shader.Find(shaderName);
|
||||
}
|
||||
|
||||
if (hasAlpha) {
|
||||
CalculateTextureSize(ref alphaWidth, ref alphaHeight, (int)movieInfo.width, (int)movieInfo.height, movieInfo.alphaCodecType, false);
|
||||
}
|
||||
|
||||
UpdateMovieTextureST(movieInfo.dispWidth, movieInfo.dispHeight);
|
||||
|
||||
nativePtrs = new IntPtr[4];
|
||||
playerID = playerId;
|
||||
}
|
||||
|
||||
|
||||
protected override void OnDisposeManaged()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
protected override void OnDisposeUnmanaged()
|
||||
{
|
||||
DisposeTextures(textures);
|
||||
DisposeTextures(renderTextures);
|
||||
|
||||
textures = null;
|
||||
renderTextures = null;
|
||||
}
|
||||
|
||||
|
||||
public override bool IsPrepared()
|
||||
{
|
||||
return areTexturesUpdated && isFrameUpdated;
|
||||
}
|
||||
|
||||
|
||||
public override bool ContinuePreparing()
|
||||
{ return true; }
|
||||
|
||||
|
||||
public override bool IsSuitable(int playerId, MovieInfo movieInfo, bool additive, Shader userShader)
|
||||
{
|
||||
int w = 0, h = 0;
|
||||
CalculateTextureSize(ref w, ref h, (int)movieInfo.width, (int)movieInfo.height, movieInfo.codecType, false);
|
||||
bool isCodecSuitable = movieInfo.codecType == codecType;
|
||||
bool isSizeSuitable = (width == w) && (height == h);
|
||||
bool isAlphaSuitable = hasAlpha == movieInfo.hasAlpha;
|
||||
bool isAdditiveSuitable = this.additive == additive;
|
||||
bool isShaderSuitable = this.useUserShader ? (userShader == shader) : true;
|
||||
return isCodecSuitable && isSizeSuitable && isAlphaSuitable && isAdditiveSuitable && isShaderSuitable;
|
||||
}
|
||||
|
||||
|
||||
public override bool OnPlayerStopForSeek()
|
||||
{
|
||||
isStoppingForSeek = true;
|
||||
isStartTriggered = false;
|
||||
|
||||
if (renderTextures != null || textures == null || textures[0] == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
renderTextures = new RenderTexture[hasAlpha ? 4 : 3];
|
||||
|
||||
for (int i = 0; i < renderTextures.Length; i++) {
|
||||
Texture2D baseTexture = textures[i];
|
||||
RenderTexture texture = new RenderTexture(baseTexture.width, baseTexture.height, 0, RenderTextureFormat.R8);
|
||||
texture.Create();
|
||||
|
||||
Graphics.Blit(baseTexture, texture);
|
||||
renderTextures[i] = texture;
|
||||
}
|
||||
|
||||
forceUpdateMaterialTextures(renderTextures);
|
||||
|
||||
DisposeTextures(textures);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public override void OnPlayerStart() {
|
||||
isStartTriggered = true;
|
||||
}
|
||||
|
||||
|
||||
private void forceUpdateMaterialTextures(Texture[] newTextures) {
|
||||
if (currentMaterial != null) {
|
||||
currentMaterial.SetTexture("_TextureY", newTextures[0]);
|
||||
currentMaterial.SetTexture("_TextureU", newTextures[1]);
|
||||
currentMaterial.SetTexture("_TextureV", newTextures[2]);
|
||||
if (hasAlpha) {
|
||||
currentMaterial.SetTexture("_TextureA", newTextures[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void AttachToPlayer(int playerId)
|
||||
{
|
||||
DisposeTextures(textures);
|
||||
areTexturesUpdated = false;
|
||||
isFrameUpdated = false;
|
||||
}
|
||||
|
||||
|
||||
public override bool UpdateFrame(int playerId, FrameInfo frameInfo, ref bool frameDrop)
|
||||
{
|
||||
bool updated = CRIWARE9061FF01(playerId, 4, null, frameInfo, ref frameDrop);
|
||||
if (updated && !frameDrop) {
|
||||
UpdateMovieTextureST(frameInfo.dispWidth, frameInfo.dispHeight);
|
||||
}
|
||||
isFrameUpdated |= updated;
|
||||
if (isFrameUpdated) {
|
||||
numImages = (int)frameInfo.numImages;
|
||||
numImagesForYUV = hasAlpha ? numImages - 1 : numImages;
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
|
||||
|
||||
public override bool UpdateMaterial(Material material)
|
||||
{
|
||||
if (areTexturesUpdated) {
|
||||
if (textures != null && textures[0] != null) {
|
||||
if (currentMaterial != material) {
|
||||
currentMaterial = material;
|
||||
SetupStaticMaterialProperties();
|
||||
|
||||
if (numImagesForYUV == 3) {
|
||||
material.DisableKeyword("CRI_UV_FORMAT");
|
||||
} else {
|
||||
material.EnableKeyword("CRI_UV_FORMAT");
|
||||
}
|
||||
}
|
||||
material.SetVector("_MovieTexture_ST", movieTextureST);
|
||||
material.SetVector("_MovieChromaTexture_ST", movieChromaTextureST);
|
||||
|
||||
if (!isStoppingForSeek) {
|
||||
material.SetTexture("_TextureY", textures[0]);
|
||||
if (numImagesForYUV == 3) {
|
||||
material.SetTexture("_TextureU", textures[1]);
|
||||
material.SetTexture("_TextureV", textures[2]);
|
||||
} else {
|
||||
material.SetTexture("_TextureUV", textures[1]);
|
||||
}
|
||||
if (hasAlpha) {
|
||||
material.SetVector("_MovieAlphaTexture_ST", movieAlphaTextureST);
|
||||
material.SetTexture("_TextureA", textures[numImages - 1]);
|
||||
}
|
||||
DisposeTextures(renderTextures);
|
||||
renderTextures = null;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return renderTextures != null;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateMovieTextureST(System.UInt32 dispWidth, System.UInt32 dispHeight)
|
||||
{
|
||||
float uScale = (dispWidth != width) ? (float)(dispWidth - 1) / width : 1.0f;
|
||||
float vScale = (dispHeight != height) ? (float)(dispHeight - 1) / height : 1.0f;
|
||||
movieTextureST.x = uScale;
|
||||
movieTextureST.y = -vScale;
|
||||
movieTextureST.z = 0.0f;
|
||||
movieTextureST.w = vScale;
|
||||
|
||||
uScale = (dispWidth != chromaWidth * 2) ? (float)(dispWidth / 2 - 1) / (chromaWidth * 2) * 2 : 1.0f;
|
||||
vScale = (dispHeight != chromaHeight * 2) ? (float)(dispHeight / 2 - 1) / (chromaHeight * 2) * 2 : 1.0f;
|
||||
movieChromaTextureST.x = uScale;
|
||||
movieChromaTextureST.y = -vScale;
|
||||
movieChromaTextureST.z = 0.0f;
|
||||
movieChromaTextureST.w = vScale;
|
||||
|
||||
if (hasAlpha) {
|
||||
uScale = (dispWidth != alphaWidth) ? (float)(dispWidth - 1) / alphaWidth : 1.0f;
|
||||
vScale = (dispHeight != alphaHeight) ? (float)(dispHeight - 1) / alphaHeight : 1.0f;
|
||||
movieAlphaTextureST.x = uScale;
|
||||
movieAlphaTextureST.y = -vScale;
|
||||
movieAlphaTextureST.z = 0.0f;
|
||||
movieAlphaTextureST.w = vScale;
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateTextures()
|
||||
{
|
||||
nativePtrs[0] = System.IntPtr.Zero;
|
||||
bool updated = CRIWAREDA63C3D7(playerID, numImages, nativePtrs);
|
||||
areTexturesUpdated |= updated;
|
||||
|
||||
if (updated && nativePtrs[0] != System.IntPtr.Zero && isStartTriggered) {
|
||||
if (textures == null || textures[0] == null) {
|
||||
textures = new Texture2D[numImages];
|
||||
textures[0] = Texture2D.CreateExternalTexture(width, height, format, false, false, nativePtrs[0]);
|
||||
textures[0].wrapMode = TextureWrapMode.Clamp;
|
||||
if (numImagesForYUV == 3) { /* Y/U/V */
|
||||
textures[1] = Texture2D.CreateExternalTexture(chromaWidth, chromaHeight, format, false, false, nativePtrs[1]);
|
||||
textures[1].wrapMode = TextureWrapMode.Clamp;
|
||||
textures[2] = Texture2D.CreateExternalTexture(chromaWidth, chromaHeight, format, false, false, nativePtrs[2]);
|
||||
textures[2].wrapMode = TextureWrapMode.Clamp;
|
||||
} else { /* Y/UV */
|
||||
textures[1] = Texture2D.CreateExternalTexture(chromaWidth, chromaHeight, formatUV, false, false, nativePtrs[1]);
|
||||
textures[1].wrapMode = TextureWrapMode.Clamp;
|
||||
}
|
||||
if (hasAlpha) {
|
||||
textures[numImages - 1] = Texture2D.CreateExternalTexture(alphaWidth, alphaHeight, format, false, false, nativePtrs[numImages - 1]);
|
||||
textures[numImages - 1].wrapMode = TextureWrapMode.Clamp;
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < numImages; i++) {
|
||||
textures[i].UpdateExternalTexture(nativePtrs[i]);
|
||||
}
|
||||
}
|
||||
isStoppingForSeek = false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void CalculateTextureSize(ref int w, ref int h, int videoWidth, int videoHeight, CodecType type, bool isChroma)
|
||||
{
|
||||
if (type == CodecType.SofdecPrime) {
|
||||
if (!isChroma) {
|
||||
w = Ceiling32(Ceiling16(CeilingWith(videoWidth, 8)));
|
||||
h = CeilingWith(videoHeight, 8);
|
||||
} else {
|
||||
w = Ceiling32(Ceiling16(CeilingWith(videoWidth, 8)) / 2);
|
||||
h = CeilingWith(videoHeight, 8) / 2;
|
||||
}
|
||||
|
||||
} else if (type == CodecType.VP9) {
|
||||
if (!isChroma) {
|
||||
w = CeilingWith(CeilingWith(videoWidth, 2), 8);
|
||||
h = CeilingWith(videoHeight, 2);
|
||||
} else {
|
||||
w = CeilingWith(CeilingWith(videoWidth, 2) / 2, 8);
|
||||
h = CeilingWith(videoHeight, 2) / 2;
|
||||
}
|
||||
} else if (type == CodecType.H264) {
|
||||
if (!isChroma) {
|
||||
w = Ceiling16(Ceiling16(CeilingWith(videoWidth, 8)));
|
||||
h = CeilingWith(videoHeight, 8);
|
||||
} else {
|
||||
w = Ceiling16(Ceiling16(CeilingWith(videoWidth, 8)) / 2);
|
||||
h = CeilingWith(videoHeight, 8) / 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // class
|
||||
} // namespace
|
||||
|
||||
} //namespace CriWare
|
||||
|
||||
#endif
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c1b5bfeca611e446ad85bec1af765ec
|
||||
timeCreated: 1504693376
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+303
@@ -0,0 +1,303 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2015 CRI Middleware Co., Ltd.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if !UNITY_EDITOR && UNITY_ANDROID
|
||||
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace CriWare {
|
||||
|
||||
namespace CriMana.Detail
|
||||
{
|
||||
public static partial class AutoResisterRendererResourceFactories
|
||||
{
|
||||
[RendererResourceFactoryPriority(5060)]
|
||||
public class RendererResourceFactoryAndroidSofdecPrimeYuvLegacyGles2 : RendererResourceFactory
|
||||
{
|
||||
public override RendererResource CreateRendererResource(int playerId, MovieInfo movieInfo, bool additive, Shader userShader)
|
||||
{
|
||||
bool isCodecSuitable = movieInfo.codecType == CodecType.SofdecPrime || movieInfo.codecType == CodecType.VP9 ||
|
||||
(CriManaPlugin.criManaUnity_IsBufferOutputForH264Enabled_ANDROID() && movieInfo.codecType == CodecType.H264);
|
||||
bool isGraphicsApiSuitable = (UnityEngine.SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.OpenGLES2 ||
|
||||
UnityEngine.SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Vulkan);
|
||||
bool isSuitable = isCodecSuitable && isGraphicsApiSuitable;
|
||||
return isSuitable
|
||||
? new RendererResourceAndroidSofdecPrimeYuvLegacyGles2(playerId, movieInfo, additive, userShader)
|
||||
: null;
|
||||
}
|
||||
|
||||
protected override void OnDisposeManaged()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisposeUnmanaged()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class RendererResourceAndroidSofdecPrimeYuvLegacyGles2 : RendererResource
|
||||
{
|
||||
private int width, height;
|
||||
private int chromaWidth, chromaHeight;
|
||||
private int alphaWidth, alphaHeight;
|
||||
private bool useUserShader;
|
||||
CodecType codecType;
|
||||
|
||||
private int movieWidth, movieHeight;
|
||||
|
||||
private const TextureFormat format = TextureFormat.Alpha8;
|
||||
private const TextureFormat formatUV = TextureFormat.RG16;
|
||||
|
||||
private Vector4 movieTextureST = Vector4.zero;
|
||||
private Vector4 movieChromaTextureST = Vector4.zero;
|
||||
private Vector4 movieAlphaTextureST = Vector4.zero;
|
||||
|
||||
private Texture2D[][] textures;
|
||||
private RenderTexture[] renderTextures;
|
||||
private IntPtr[][] nativeTextures;
|
||||
private int numImages = -1;
|
||||
private int numImagesForYUV = -1;
|
||||
|
||||
private Int32 numTextureSets = 2;
|
||||
private Int32 currentTextureSet = 0;
|
||||
private Int32 drawTextureSet = -1;
|
||||
private Int32 playerID;
|
||||
private bool isStoppingForSeek = false;
|
||||
|
||||
public RendererResourceAndroidSofdecPrimeYuvLegacyGles2(int playerId, MovieInfo movieInfo, bool additive, Shader userShader)
|
||||
{
|
||||
hasAlpha = movieInfo.hasAlpha;
|
||||
this.additive = additive;
|
||||
useUserShader = userShader != null;
|
||||
|
||||
movieWidth = (int)movieInfo.width;
|
||||
movieHeight = (int)movieInfo.height;
|
||||
|
||||
if (userShader != null) {
|
||||
shader = userShader;
|
||||
} else {
|
||||
string shaderName = "CriMana/AndroidSofdecPrimeYuvLegacy";
|
||||
shader = Shader.Find(shaderName);
|
||||
}
|
||||
|
||||
textures = new Texture2D[numTextureSets][];
|
||||
for (int i = 0; i < numTextureSets; i++) {
|
||||
textures[i] = new Texture2D[4];
|
||||
for (int j = 0; j < 4; j++) {
|
||||
textures[i][j] = null;
|
||||
}
|
||||
}
|
||||
nativeTextures = new IntPtr[numTextureSets][];
|
||||
|
||||
for (int i = 0; i < numTextureSets; i++) {
|
||||
nativeTextures[i] = new IntPtr[4];
|
||||
for (int j = 0; j < 4; j++) {
|
||||
nativeTextures[i][j] = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
codecType = movieInfo.codecType;
|
||||
playerID = playerId;
|
||||
}
|
||||
|
||||
|
||||
protected override void OnDisposeManaged()
|
||||
{}
|
||||
|
||||
|
||||
protected override void OnDisposeUnmanaged()
|
||||
{
|
||||
CRIWARE2676F2A5(playerID, 0 ,null);
|
||||
|
||||
for (int i = 0; i < numTextureSets; i++) {
|
||||
DisposeTextures(textures[i]);
|
||||
}
|
||||
textures = null;
|
||||
nativeTextures = null;
|
||||
}
|
||||
|
||||
public override bool IsPrepared()
|
||||
{ return true; }
|
||||
|
||||
|
||||
public override bool ContinuePreparing()
|
||||
{ return true; }
|
||||
|
||||
|
||||
public override bool IsSuitable(int playerId, MovieInfo movieInfo, bool additive, Shader userShader) {
|
||||
bool isCodecSuitable = movieInfo.codecType == codecType;
|
||||
bool isSizeSuitable = (movieWidth == (int)movieInfo.width) && (movieHeight == (int)movieInfo.height);
|
||||
bool isAlphaSuitable = hasAlpha == movieInfo.hasAlpha;
|
||||
bool isAdditiveSuitable = this.additive == additive;
|
||||
bool isShaderSuitable = this.useUserShader ? (userShader == shader) : true;
|
||||
return isCodecSuitable && isSizeSuitable && isAlphaSuitable && isAdditiveSuitable && isShaderSuitable;
|
||||
}
|
||||
|
||||
|
||||
public override bool OnPlayerStopForSeek() {
|
||||
isStoppingForSeek = (drawTextureSet >= 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void AttachToPlayer(int playerId) {
|
||||
CRIWARE71A23DE1(playerID, 0, new IntPtr[1]);
|
||||
drawTextureSet = -1;
|
||||
}
|
||||
|
||||
public override bool UpdateFrame(int playerId, FrameInfo frameInfo, ref bool frameDrop) {
|
||||
bool isFrameUpdated = CRIWARE9061FF01(playerId, 0, null, frameInfo, ref frameDrop);
|
||||
if (isFrameUpdated && !frameDrop) {
|
||||
drawTextureSet = currentTextureSet;
|
||||
currentTextureSet = (currentTextureSet + 1) % numTextureSets;
|
||||
isStoppingForSeek = false;
|
||||
}
|
||||
|
||||
if (isFrameUpdated && textures[0][0] == null) {
|
||||
numImages = (int)frameInfo.numImages;
|
||||
numImagesForYUV = hasAlpha ? numImages - 1 : numImages;
|
||||
|
||||
CalculateTextureSize(ref width, ref height, (int)frameInfo.width, (int)frameInfo.height, codecType, false);
|
||||
CalculateTextureSize(ref chromaWidth, ref chromaHeight, (int)frameInfo.width, (int)frameInfo.height, codecType, true);
|
||||
if (hasAlpha) {
|
||||
CalculateTextureSize(ref alphaWidth, ref alphaHeight, (int)frameInfo.width, (int)frameInfo.height, CodecType.SofdecPrime, false);
|
||||
}
|
||||
UpdateMovieTextureST(frameInfo.dispWidth, frameInfo.dispHeight);
|
||||
|
||||
for (int i = 0; i < numTextureSets; i++) {
|
||||
textures[i][0] = new Texture2D(width, height, format, false, true);
|
||||
textures[i][0].wrapMode = TextureWrapMode.Clamp;
|
||||
if (numImagesForYUV == 3) {
|
||||
textures[i][1] = new Texture2D(chromaWidth, chromaHeight, format, false, true);
|
||||
textures[i][1].wrapMode = TextureWrapMode.Clamp;
|
||||
textures[i][2] = new Texture2D(chromaWidth, chromaHeight, format, false, true);
|
||||
textures[i][2].wrapMode = TextureWrapMode.Clamp;
|
||||
} else {
|
||||
textures[i][1] = new Texture2D(chromaWidth, chromaHeight, formatUV, false, true);
|
||||
textures[i][1].wrapMode = TextureWrapMode.Clamp;
|
||||
}
|
||||
for (int j = 0; j < numImagesForYUV; j++) {
|
||||
nativeTextures[i][j] = textures[i][j].GetNativeTexturePtr();
|
||||
}
|
||||
if (hasAlpha) {
|
||||
textures[i][numImages - 1] = new Texture2D(alphaWidth, alphaHeight, format, false, true);
|
||||
textures[i][numImages - 1].wrapMode = TextureWrapMode.Clamp;
|
||||
nativeTextures[i][numImages - 1] = textures[i][numImages - 1].GetNativeTexturePtr();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return isFrameUpdated;
|
||||
}
|
||||
|
||||
public override bool UpdateMaterial(Material material) {
|
||||
if (isStoppingForSeek)
|
||||
return true;
|
||||
|
||||
if (drawTextureSet < 0)
|
||||
return false;
|
||||
|
||||
if (currentMaterial != material) {
|
||||
currentMaterial = material;
|
||||
SetupStaticMaterialProperties();
|
||||
|
||||
if (numImagesForYUV == 3) {
|
||||
material.DisableKeyword("CRI_UV_FORMAT");
|
||||
} else {
|
||||
material.EnableKeyword("CRI_UV_FORMAT");
|
||||
}
|
||||
}
|
||||
material.SetVector("_MovieTexture_ST", movieTextureST);
|
||||
material.SetVector("_MovieChromaTexture_ST", movieChromaTextureST);
|
||||
|
||||
material.SetTexture("_TextureY", textures[drawTextureSet][0]);
|
||||
if (numImagesForYUV == 3) {
|
||||
material.SetTexture("_TextureU", textures[drawTextureSet][1]);
|
||||
material.SetTexture("_TextureV", textures[drawTextureSet][2]);
|
||||
} else {
|
||||
material.SetTexture("_TextureUV", textures[drawTextureSet][1]);
|
||||
}
|
||||
if (hasAlpha) {
|
||||
material.SetVector("_MovieAlphaTexture_ST", movieAlphaTextureST);
|
||||
material.SetTexture("_TextureA", textures[drawTextureSet][numImages - 1]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void UpdateMovieTextureST(System.UInt32 dispWidth, System.UInt32 dispHeight) {
|
||||
float uScale = (dispWidth != width) ? (float)(dispWidth - 1) / width : 1.0f;
|
||||
float vScale = (dispHeight != height) ? (float)(dispHeight - 1) / height : 1.0f;
|
||||
movieTextureST.x = uScale;
|
||||
movieTextureST.y = -vScale;
|
||||
movieTextureST.z = 0.0f;
|
||||
movieTextureST.w = vScale;
|
||||
|
||||
uScale = (dispWidth != chromaWidth * 2) ?
|
||||
(float)(dispWidth / 2 - 1) / (chromaWidth * 2) * 2 :
|
||||
1.0f;
|
||||
vScale = (dispHeight != chromaHeight * 2) ?
|
||||
(float)(dispHeight / 2 - 1) / (chromaHeight * 2) * 2 :
|
||||
1.0f;
|
||||
movieChromaTextureST.x = uScale;
|
||||
movieChromaTextureST.y = -vScale;
|
||||
movieChromaTextureST.z = 0.0f;
|
||||
movieChromaTextureST.w = vScale;
|
||||
|
||||
if (hasAlpha) {
|
||||
uScale = (dispWidth != alphaWidth) ? (float)(dispWidth - 1) / alphaWidth : 1.0f;
|
||||
vScale = (dispHeight != alphaHeight) ? (float)(dispHeight - 1) / alphaHeight : 1.0f;
|
||||
movieAlphaTextureST.x = uScale;
|
||||
movieAlphaTextureST.y = -vScale;
|
||||
movieAlphaTextureST.z = 0.0f;
|
||||
movieAlphaTextureST.w = vScale;
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateTextures()
|
||||
{
|
||||
if (drawTextureSet < 0)
|
||||
return;
|
||||
|
||||
CRIWAREDA63C3D7(playerID, numImages, nativeTextures[drawTextureSet]);
|
||||
}
|
||||
|
||||
private static void CalculateTextureSize(ref int w, ref int h, int videoWidth, int videoHeight, CodecType type, bool isChroma) {
|
||||
if (type == CodecType.SofdecPrime) {
|
||||
if (!isChroma) {
|
||||
w = Ceiling32(Ceiling16(CeilingWith(videoWidth, 8)));
|
||||
h = CeilingWith(videoHeight, 8);
|
||||
} else {
|
||||
w = Ceiling32(Ceiling16(CeilingWith(videoWidth, 8)) / 2);
|
||||
h = CeilingWith(videoHeight, 8) / 2;
|
||||
}
|
||||
|
||||
} else if (type == CodecType.VP9) {
|
||||
if (!isChroma) {
|
||||
w = CeilingWith(CeilingWith(videoWidth, 2), 8);
|
||||
h = CeilingWith(CeilingWith(videoHeight, 2), 8);
|
||||
} else {
|
||||
w = CeilingWith(CeilingWith(videoWidth, 2) / 2, 8);
|
||||
h = CeilingWith(CeilingWith(videoHeight, 2) / 2, 8);
|
||||
}
|
||||
} else if (type == CodecType.H264) {
|
||||
if (!isChroma) {
|
||||
w = videoWidth;
|
||||
h = videoHeight;
|
||||
} else {
|
||||
w = videoWidth / 2;
|
||||
h = videoHeight / 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace CriWare
|
||||
|
||||
#endif
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0278ee25c85693943bd37be41852fa52
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c4a7bb2022b729345931dc907d6ab8a5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6ecbb7559c822d94e9e5864caa40b65f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc89c6c3bcab4e148b1f6396cb7fd89f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
Shader "CriMana/AndroidH264Rgb"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
[HideInInspector] _MovieTexture_ST ("MovieTexture_ST", Vector) = (1.0, 1.0, 0, 0)
|
||||
[HideInInspector] _AlphaTexture_ST("AlphaTexture_ST", Vector) = (1.0, 1.0, 0, 0)
|
||||
[HideInInspector] _TextureRGB ("TextureRGB", 2D) = "white" {}
|
||||
[HideInInspector] _TextureA ("TextureA", 2D) = "white" {}
|
||||
[HideInInspector] _SrcBlendMode ("SrcBlendMode", Int) = 0
|
||||
[HideInInspector] _DstBlendMode ("DstBlendMode", Int) = 0
|
||||
[HideInInspector] _CullMode("CullMode", Int) = 2
|
||||
[HideInInspector] _ZWriteMode("ZWriteMode", Int) = 1
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"Queue" = "Transparent"
|
||||
"PreviewType"="Plane"
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Blend [_SrcBlendMode] [_DstBlendMode]
|
||||
Cull [_CullMode]
|
||||
ZWrite [_ZWriteMode]
|
||||
ZTest [unity_GUIZTestMode]
|
||||
|
||||
GLSLPROGRAM
|
||||
#version 100 // this will be converted to 300 es when using OpenGLES3
|
||||
#pragma multi_compile _ CRI_ALPHA_MOVIE
|
||||
#pragma multi_compile _ CRI_APPLY_TARGET_ALPHA
|
||||
#pragma multi_compile _ CRI_LINEAR_COLORSPACE
|
||||
#ifdef VERTEX
|
||||
attribute vec4 _glesVertex;
|
||||
attribute vec4 _glesMultiTexCoord0;
|
||||
#ifdef CRI_APPLY_TARGET_ALPHA
|
||||
attribute vec4 _glesColor;
|
||||
varying lowp float alpha;
|
||||
#endif
|
||||
uniform highp vec4 _MainTex_ST;
|
||||
uniform highp vec4 _MovieTexture_ST;
|
||||
varying mediump vec2 xlv_TEXCOORD0;
|
||||
#ifdef CRI_ALPHA_MOVIE
|
||||
uniform highp vec4 _AlphaTexture_ST;
|
||||
varying mediump vec2 xlv_TEXCOORD1;
|
||||
#endif
|
||||
void main ()
|
||||
{
|
||||
highp vec4 tmpvar;
|
||||
tmpvar.w = 1.0;
|
||||
tmpvar.xyz = _glesVertex.xyz;
|
||||
gl_Position = (unity_MatrixVP * (unity_ObjectToWorld * tmpvar)); // UnityObjectToClipPos(*)
|
||||
xlv_TEXCOORD0 = (((_glesMultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw) * _MovieTexture_ST.xy) + _MovieTexture_ST.zw;
|
||||
#ifdef CRI_ALPHA_MOVIE
|
||||
xlv_TEXCOORD1 = (((_glesMultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw) * _AlphaTexture_ST.xy) + _AlphaTexture_ST.zw;
|
||||
#endif
|
||||
#ifdef CRI_APPLY_TARGET_ALPHA
|
||||
alpha = _glesColor.w;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#ifdef FRAGMENT
|
||||
#extension GL_OES_EGL_image_external : enable
|
||||
#extension GL_OES_EGL_image_external_essl3 : enable
|
||||
#if (defined(SHADER_API_GLES3) && defined(GL_OES_EGL_image_external_essl3)) || defined(GL_OES_EGL_image_external) && !defined(SHADER_API_GLCORE)
|
||||
uniform samplerExternalOES _TextureRGB;
|
||||
#else
|
||||
uniform sampler2D _TextureRGB;
|
||||
#endif
|
||||
varying mediump vec2 xlv_TEXCOORD0;
|
||||
uniform lowp float _Transparency;
|
||||
#ifdef CRI_ALPHA_MOVIE
|
||||
uniform sampler2D _TextureA;
|
||||
varying mediump vec2 xlv_TEXCOORD1;
|
||||
#endif
|
||||
#ifdef CRI_APPLY_TARGET_ALPHA
|
||||
varying lowp float alpha;
|
||||
#endif
|
||||
void main ()
|
||||
{
|
||||
#if (defined(SHADER_API_GLES3) && defined(GL_OES_EGL_image_external_essl3)) || defined(GL_OES_EGL_image_external) && !defined(SHADER_API_GLCORE)
|
||||
gl_FragData[0] = texture2D(_TextureRGB, xlv_TEXCOORD0);
|
||||
#else
|
||||
gl_FragData[0].x = gl_FragData[0].y = gl_FragData[0].z = 0.0f;
|
||||
#endif
|
||||
#ifdef CRI_LINEAR_COLORSPACE
|
||||
gl_FragData[0].x = pow(max(gl_FragData[0].x, 0.001), 2.2);
|
||||
gl_FragData[0].y = pow(max(gl_FragData[0].y, 0.001), 2.2);
|
||||
gl_FragData[0].z = pow(max(gl_FragData[0].z, 0.001), 2.2);
|
||||
#endif
|
||||
#ifdef CRI_ALPHA_MOVIE
|
||||
gl_FragData[0].w = texture2D(_TextureA, xlv_TEXCOORD1).x;
|
||||
#endif
|
||||
#ifdef CRI_APPLY_TARGET_ALPHA
|
||||
gl_FragData[0].w *= alpha;
|
||||
#endif
|
||||
gl_FragData[0].w *= 1.0 - _Transparency;
|
||||
}
|
||||
#endif
|
||||
ENDGLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 01205c74879764ae9b7e3fe90473f53f
|
||||
timeCreated: 1445063687
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
Shader "CriMana/AndroidH264DummySupportCheck"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex("Texture", 2D) = "white" {}
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
ZTest Always
|
||||
Cull Off
|
||||
Zwrite Off
|
||||
Blend One Zero
|
||||
|
||||
GLSLPROGRAM
|
||||
#version 100 // this will be converted to 300 es when using OpenGLES3
|
||||
#ifdef VERTEX
|
||||
attribute vec4 _glesVertex;
|
||||
void main()
|
||||
{
|
||||
highp vec4 tmpvar;
|
||||
tmpvar.w = 1.0;
|
||||
tmpvar.xyz = _glesVertex.xyz;
|
||||
gl_Position = (unity_MatrixVP * (unity_ObjectToWorld * tmpvar)); // UnityObjectToClipPos(*)
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef FRAGMENT
|
||||
#extension GL_OES_EGL_image_external : enable
|
||||
#extension GL_OES_EGL_image_external_essl3 : enable
|
||||
void main()
|
||||
{
|
||||
#if (defined(SHADER_API_GLES3) && defined(GL_OES_EGL_image_external_essl3)) || defined(GL_OES_EGL_image_external)
|
||||
gl_FragData[0].x = gl_FragData[0].y = gl_FragData[0].z = 1.0f;
|
||||
#else
|
||||
gl_FragData[0].x = gl_FragData[0].y = gl_FragData[0].z = 0.0f;
|
||||
Dummy code for shader compilation failure.
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
ENDGLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 51ee31cd511ac614ea39aa4dd7841c15
|
||||
timeCreated: 1510192307
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
Shader "CriMana/AndroidSofdecPrimeYuv"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
[HideInInspector] _MovieTexture_ST ("MovieTexture_ST", Vector) = (1.0, 1.0, 0, 0)
|
||||
[HideInInspector] _MovieChromaTexture_ST("MovieChromaTexture_ST", Vector) = (1.0, 1.0, 0, 0)
|
||||
[HideInInspector] _MovieAlphaTexture_ST("MovieAlphaTexture_ST", Vector) = (1.0, 1.0, 0, 0)
|
||||
[HideInInspector] _TextureY ("TextureY", 2D) = "white" {}
|
||||
[HideInInspector] _TextureU ("TextureU", 2D) = "white" {}
|
||||
[HideInInspector] _TextureV ("TextureV", 2D) = "white" {}
|
||||
[HideInInspector] _TextureUV ("TextureUV", 2D) = "white" {}
|
||||
[HideInInspector] _TextureA ("TextureA", 2D) = "white" {}
|
||||
[HideInInspector] _SrcBlendMode ("SrcBlendMode", Int) = 0
|
||||
[HideInInspector] _DstBlendMode ("DstBlendMode", Int) = 0
|
||||
[HideInInspector] _CullMode("CullMode", Int) = 2
|
||||
[HideInInspector] _ZWriteMode("ZWriteMode", Int) = 1
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"Queue" = "Transparent"
|
||||
"PreviewType"="Plane"
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Blend [_SrcBlendMode] [_DstBlendMode]
|
||||
Cull [_CullMode]
|
||||
ZWrite [_ZWriteMode]
|
||||
ZTest [unity_GUIZTestMode]
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#if defined(SHADER_API_PSP2) || defined(SHADER_API_PS3)
|
||||
// seems that ARB_precision_hint_fastest is not supported on these platforms.
|
||||
#else
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#endif
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
#pragma multi_compile _ CRI_UV_FORMAT
|
||||
#pragma multi_compile _ CRI_ALPHA_MOVIE
|
||||
#pragma multi_compile _ CRI_APPLY_TARGET_ALPHA
|
||||
#pragma multi_compile _ CRI_LINEAR_COLORSPACE
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
half2 texcoord : TEXCOORD0;
|
||||
#ifdef CRI_APPLY_TARGET_ALPHA
|
||||
float4 color : COLOR;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
half2 uv : TEXCOORD0;
|
||||
half2 uv2 : TEXCOORD1;
|
||||
#ifdef CRI_ALPHA_MOVIE
|
||||
half2 uv3 : TEXCOORD2;
|
||||
#endif
|
||||
#ifdef CRI_APPLY_TARGET_ALPHA
|
||||
float4 color : COLOR;
|
||||
#endif
|
||||
};
|
||||
|
||||
float4 _MainTex_ST;
|
||||
float4 _MovieTexture_ST;
|
||||
float4 _MovieChromaTexture_ST;
|
||||
#ifdef CRI_ALPHA_MOVIE
|
||||
float4 _MovieAlphaTexture_ST;
|
||||
#endif
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = (TRANSFORM_TEX(v.texcoord, _MainTex) * _MovieTexture_ST.xy) + _MovieTexture_ST.zw;
|
||||
o.uv2 = (TRANSFORM_TEX(v.texcoord, _MainTex) * _MovieChromaTexture_ST.xy) + _MovieChromaTexture_ST.zw;
|
||||
#ifdef CRI_ALPHA_MOVIE
|
||||
o.uv3 = (TRANSFORM_TEX(v.texcoord, _MainTex) * _MovieAlphaTexture_ST.xy) + _MovieAlphaTexture_ST.zw;
|
||||
#endif
|
||||
#ifdef CRI_APPLY_TARGET_ALPHA
|
||||
o.color = v.color;
|
||||
#endif
|
||||
return o;
|
||||
}
|
||||
|
||||
static const fixed3x3 yuv_to_rgb = {
|
||||
{1.16438, 0.0, 1.59603},
|
||||
{1.16438, -0.39176, -0.81297},
|
||||
{1.16438, 2.01723, 0.0}
|
||||
};
|
||||
|
||||
sampler2D _TextureY;
|
||||
#ifdef CRI_UV_FORMAT
|
||||
sampler2D _TextureUV;
|
||||
#else
|
||||
sampler2D _TextureU;
|
||||
sampler2D _TextureV;
|
||||
#endif
|
||||
#ifdef CRI_ALPHA_MOVIE
|
||||
sampler2D _TextureA;
|
||||
#endif
|
||||
fixed _Transparency;
|
||||
|
||||
fixed4 frag(v2f i) : COLOR
|
||||
{
|
||||
fixed4 color;
|
||||
color.r = tex2D(_TextureY, i.uv).r;
|
||||
#ifdef CRI_UV_FORMAT
|
||||
color.g = tex2D(_TextureUV, i.uv2).r;
|
||||
color.b = tex2D(_TextureUV, i.uv2).a;
|
||||
#else
|
||||
color.g = tex2D(_TextureU, i.uv2).r;
|
||||
color.b = tex2D(_TextureV, i.uv2).r;
|
||||
#endif
|
||||
#ifdef CRI_ALPHA_MOVIE
|
||||
color.a = tex2D(_TextureA, i.uv3).r;
|
||||
#else
|
||||
color.a = 1.0;
|
||||
#endif
|
||||
color.rgb = color.rgb + fixed3(-0.06275, -0.50196, -0.50196);
|
||||
color.rgb = mul(yuv_to_rgb, color.rgb);
|
||||
#ifdef CRI_LINEAR_COLORSPACE
|
||||
color.rgb = pow(max(color.rgb, 0), 2.2);
|
||||
#endif
|
||||
#ifdef CRI_APPLY_TARGET_ALPHA
|
||||
color.a = color.a * i.color.a;
|
||||
#endif
|
||||
color.a *= 1 - _Transparency;
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 545dfb3f920144f7bb3599122209656b
|
||||
timeCreated: 1510116192
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
Shader "CriMana/AndroidSofdecPrimeYuvLegacy"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
[HideInInspector] _MovieTexture_ST ("MovieTexture_ST", Vector) = (1.0, 1.0, 0, 0)
|
||||
[HideInInspector] _MovieChromaTexture_ST ("MovieChromaTexture_ST", Vector) = (1.0, 1.0, 0, 0)
|
||||
[HideInInspector] _MovieAlphaTexture_ST ("MovieAlphaTexture_ST", Vector) = (1.0, 1.0, 0, 0)
|
||||
[HideInInspector] _TextureY ("TextureY", 2D) = "white" {}
|
||||
[HideInInspector] _TextureU ("TextureU", 2D) = "white" {}
|
||||
[HideInInspector] _TextureV ("TextureV", 2D) = "white" {}
|
||||
[HideInInspector] _TextureUV ("TextureUV", 2D) = "white" {}
|
||||
[HideInInspector] _TextureA ("TextureA", 2D) = "white" {}
|
||||
[HideInInspector] _SrcBlendMode ("SrcBlendMode", Int) = 0
|
||||
[HideInInspector] _DstBlendMode ("DstBlendMode", Int) = 0
|
||||
[HideInInspector] _CullMode ("CullMode", Int) = 2
|
||||
[HideInInspector] _ZWriteMode ("ZWriteMode", Int) = 1
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"Queue" = "Transparent"
|
||||
"PreviewType"="Plane"
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Blend [_SrcBlendMode] [_DstBlendMode]
|
||||
Cull [_CullMode]
|
||||
ZWrite [_ZWriteMode]
|
||||
ZTest [unity_GUIZTestMode]
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
#pragma multi_compile _ CRI_UV_FORMAT
|
||||
#pragma multi_compile _ CRI_ALPHA_MOVIE
|
||||
#pragma multi_compile _ CRI_APPLY_TARGET_ALPHA
|
||||
#pragma multi_compile _ CRI_LINEAR_COLORSPACE
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
half2 texcoord : TEXCOORD0;
|
||||
#ifdef CRI_APPLY_TARGET_ALPHA
|
||||
float4 color : COLOR;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
half2 uv : TEXCOORD0;
|
||||
half2 uv2 : TEXCOORD1;
|
||||
#ifdef CRI_ALPHA_MOVIE
|
||||
half2 uv3 : TEXCOORD2;
|
||||
#endif
|
||||
#ifdef CRI_APPLY_TARGET_ALPHA
|
||||
float4 color : COLOR;
|
||||
#endif
|
||||
};
|
||||
|
||||
float4 _MainTex_ST;
|
||||
float4 _MovieTexture_ST;
|
||||
float4 _MovieChromaTexture_ST;
|
||||
#ifdef CRI_ALPHA_MOVIE
|
||||
float4 _MovieAlphaTexture_ST;
|
||||
#endif
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = (TRANSFORM_TEX(v.texcoord, _MainTex) * _MovieTexture_ST.xy) + _MovieTexture_ST.zw;
|
||||
o.uv2 = (TRANSFORM_TEX(v.texcoord, _MainTex) * _MovieChromaTexture_ST.xy) + _MovieChromaTexture_ST.zw;
|
||||
#ifdef CRI_ALPHA_MOVIE
|
||||
o.uv3 = (TRANSFORM_TEX(v.texcoord, _MainTex) * _MovieAlphaTexture_ST.xy) + _MovieAlphaTexture_ST.zw;
|
||||
#endif
|
||||
#ifdef CRI_APPLY_TARGET_ALPHA
|
||||
o.color = v.color;
|
||||
#endif
|
||||
return o;
|
||||
}
|
||||
|
||||
static const fixed3x3 yuv_to_rgb = {
|
||||
{1.16438, 0.0, 1.59603},
|
||||
{1.16438, -0.39176, -0.81297},
|
||||
{1.16438, 2.01723, 0.0}
|
||||
};
|
||||
|
||||
sampler2D _TextureY;
|
||||
#ifdef CRI_UV_FORMAT
|
||||
sampler2D _TextureUV;
|
||||
#else
|
||||
sampler2D _TextureU;
|
||||
sampler2D _TextureV;
|
||||
#endif
|
||||
#ifdef CRI_ALPHA_MOVIE
|
||||
sampler2D _TextureA;
|
||||
#endif
|
||||
fixed _Transparency;
|
||||
|
||||
fixed4 frag(v2f i) : COLOR
|
||||
{
|
||||
fixed3 yuv;
|
||||
yuv.r = tex2D(_TextureY, i.uv).a;
|
||||
#ifdef CRI_UV_FORMAT
|
||||
yuv.g = tex2D(_TextureUV, i.uv2).r;
|
||||
yuv.b = tex2D(_TextureUV, i.uv2).g;
|
||||
#else
|
||||
yuv.g = tex2D(_TextureU, i.uv2).a;
|
||||
yuv.b = tex2D(_TextureV, i.uv2).a;
|
||||
#endif
|
||||
yuv = yuv + fixed3(-0.06275, -0.50196, -0.50196);
|
||||
fixed4 color;
|
||||
color.rgb = mul(yuv_to_rgb, yuv);
|
||||
#ifdef CRI_LINEAR_COLORSPACE
|
||||
color.rgb = pow(max(color.rgb, 0), 2.2);
|
||||
#endif
|
||||
#ifdef CRI_ALPHA_MOVIE
|
||||
color.a = tex2D(_TextureA, i.uv3).a;
|
||||
#else
|
||||
color.a = 1.0;
|
||||
#endif
|
||||
#ifdef CRI_APPLY_TARGET_ALPHA
|
||||
color.a = color.a * i.color.a;
|
||||
#endif
|
||||
color.a *= 1 - _Transparency;
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 510c610c0d60660428de1beaa9982292
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f17bd2af1cbd884fb63295a765287fb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,32 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 521d7b784dd40df459e34bafc2167eab
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dd5b85be0649e2646ad30cd7c49913b2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Binary file not shown.
+94
@@ -0,0 +1,94 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fd84e4785f0e6d1408d320599643aa77
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
platformData:
|
||||
- first:
|
||||
'': Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 0
|
||||
Exclude Editor: 1
|
||||
Exclude Linux: 1
|
||||
Exclude Linux64: 1
|
||||
Exclude LinuxUniversal: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude WebGL: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: ARM64
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DefaultValueInitialized: true
|
||||
OS: AnyOS
|
||||
- first:
|
||||
Facebook: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Facebook: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Linux
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86_64
|
||||
- first:
|
||||
Standalone: LinuxUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68c2d2dcab5ddcc47a56b2c3c165e7f8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Binary file not shown.
+145
@@ -0,0 +1,145 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d6295746feec9704e95338f43a6d517a
|
||||
timeCreated: 1433816086
|
||||
licenseType: Pro
|
||||
PluginImporter:
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
platformData:
|
||||
data:
|
||||
first:
|
||||
'': Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 0
|
||||
Exclude Editor: 1
|
||||
Exclude Linux: 1
|
||||
Exclude Linux64: 1
|
||||
Exclude LinuxUniversal: 1
|
||||
Exclude OSXIntel: 1
|
||||
Exclude OSXIntel64: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude WebGL: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
Exclude WindowsStoreApps: 1
|
||||
Exclude iOS: 1
|
||||
Exclude tvOS: 1
|
||||
data:
|
||||
first:
|
||||
'': Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
OS: AnyOS
|
||||
data:
|
||||
first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: ARMv7
|
||||
data:
|
||||
first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
data:
|
||||
first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
data:
|
||||
first:
|
||||
Facebook: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Facebook: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Standalone: Linux
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86
|
||||
data:
|
||||
first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86_64
|
||||
data:
|
||||
first:
|
||||
Standalone: OSXIntel
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Standalone: OSXIntel64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DontProcess: False
|
||||
PlaceholderPath:
|
||||
SDK: AnySDK
|
||||
ScriptingBackend: AnyScriptingBackend
|
||||
data:
|
||||
first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
data:
|
||||
first:
|
||||
tvOS: tvOS
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Binary file not shown.
+146
@@ -0,0 +1,146 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b4b9afed8aedea4dafc1a56bf9806f0
|
||||
timeCreated: 1486043713
|
||||
licenseType: Pro
|
||||
PluginImporter:
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
platformData:
|
||||
data:
|
||||
first:
|
||||
'': Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 0
|
||||
Exclude Editor: 1
|
||||
Exclude Linux: 1
|
||||
Exclude Linux64: 1
|
||||
Exclude LinuxUniversal: 1
|
||||
Exclude OSXIntel: 1
|
||||
Exclude OSXIntel64: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude PS4: 1
|
||||
Exclude WebGL: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
Exclude WindowsStoreApps: 1
|
||||
Exclude iOS: 1
|
||||
Exclude tvOS: 1
|
||||
data:
|
||||
first:
|
||||
'': Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
OS: AnyOS
|
||||
data:
|
||||
first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: ARMv7
|
||||
data:
|
||||
first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
data:
|
||||
first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
data:
|
||||
first:
|
||||
Facebook: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Facebook: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Standalone: Linux
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86
|
||||
data:
|
||||
first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86_64
|
||||
data:
|
||||
first:
|
||||
Standalone: OSXIntel
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Standalone: OSXIntel64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DontProcess: False
|
||||
PlaceholderPath:
|
||||
SDK: AnySDK
|
||||
ScriptingBackend: AnyScriptingBackend
|
||||
data:
|
||||
first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
data:
|
||||
first:
|
||||
tvOS: tvOS
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1c126827a14a46747863272b2b214f9b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
+145
@@ -0,0 +1,145 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8a5e2b17a976caf4397218dfc89ddd43
|
||||
timeCreated: 1433816086
|
||||
licenseType: Pro
|
||||
PluginImporter:
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
platformData:
|
||||
data:
|
||||
first:
|
||||
'': Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 0
|
||||
Exclude Editor: 1
|
||||
Exclude Linux: 1
|
||||
Exclude Linux64: 1
|
||||
Exclude LinuxUniversal: 1
|
||||
Exclude OSXIntel: 1
|
||||
Exclude OSXIntel64: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude WebGL: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
Exclude WindowsStoreApps: 1
|
||||
Exclude iOS: 1
|
||||
Exclude tvOS: 1
|
||||
data:
|
||||
first:
|
||||
'': Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
OS: AnyOS
|
||||
data:
|
||||
first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86
|
||||
data:
|
||||
first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
data:
|
||||
first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
data:
|
||||
first:
|
||||
Facebook: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Facebook: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Standalone: Linux
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86
|
||||
data:
|
||||
first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86_64
|
||||
data:
|
||||
first:
|
||||
Standalone: OSXIntel
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Standalone: OSXIntel64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DontProcess: False
|
||||
PlaceholderPath:
|
||||
SDK: AnySDK
|
||||
ScriptingBackend: AnyScriptingBackend
|
||||
data:
|
||||
first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
data:
|
||||
first:
|
||||
tvOS: tvOS
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad93b238b2f121f4f9c7b9641edf0532
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7e1c713fe6d13674196babf3a983b02a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
+140
@@ -0,0 +1,140 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 980c2fc129fa3174d98e044f20a0252e
|
||||
timeCreated: 1492403957
|
||||
licenseType: Pro
|
||||
PluginImporter:
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
platformData:
|
||||
data:
|
||||
first:
|
||||
'': Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 1
|
||||
Exclude Editor: 0
|
||||
Exclude Linux: 1
|
||||
Exclude Linux64: 0
|
||||
Exclude LinuxUniversal: 0
|
||||
Exclude OSXIntel: 1
|
||||
Exclude OSXIntel64: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude WebGL: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
Exclude iOS: 1
|
||||
data:
|
||||
first:
|
||||
'': Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86_64
|
||||
OS: Linux
|
||||
data:
|
||||
first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: ARMv7
|
||||
data:
|
||||
first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
data:
|
||||
first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86_64
|
||||
DefaultValueInitialized: true
|
||||
OS: Linux
|
||||
data:
|
||||
first:
|
||||
Facebook: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
data:
|
||||
first:
|
||||
Facebook: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
data:
|
||||
first:
|
||||
Standalone: Linux
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
data:
|
||||
first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86_64
|
||||
data:
|
||||
first:
|
||||
Standalone: LinuxUniversal
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86_64
|
||||
data:
|
||||
first:
|
||||
Standalone: OSXIntel
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
data:
|
||||
first:
|
||||
Standalone: OSXIntel64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
data:
|
||||
first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
data:
|
||||
first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
data:
|
||||
first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
data:
|
||||
first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f4d4b8194ff0f894790c01453f140608
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba14ea67cbf77c64a830d06c4509d0f8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3e43bf2102ffb8146a97ee8251425939
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cceabf142838dcb4a8a13baa3d5f491a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+227
@@ -0,0 +1,227 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2015 CRI Middleware Co., Ltd.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if UNITY_EDITOR_OSX || (!UNITY_EDITOR && UNITY_STANDALONE_OSX)
|
||||
using UnityEngine;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace CriWare {
|
||||
|
||||
namespace CriMana.Detail
|
||||
{
|
||||
public static partial class AutoResisterRendererResourceFactories
|
||||
{
|
||||
[RendererResourceFactoryPriority(7000)]
|
||||
public class RendererResourceFactoryOSXH264Yuv : RendererResourceFactory
|
||||
{
|
||||
public override RendererResource CreateRendererResource(int playerId, MovieInfo movieInfo, bool additive, Shader userShader)
|
||||
{
|
||||
bool isCodecSuitable = movieInfo.codecType == CodecType.H264;
|
||||
bool isSuitable = isCodecSuitable;
|
||||
return isSuitable
|
||||
? new RendererResourceOSXH264Yuv(playerId, movieInfo, additive, userShader)
|
||||
: null;
|
||||
}
|
||||
|
||||
protected override void OnDisposeManaged()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisposeUnmanaged()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class RendererResourceOSXH264Yuv : RendererResource
|
||||
{
|
||||
private int width;
|
||||
private int height;
|
||||
private int playerId;
|
||||
private bool useUserShader;
|
||||
private Vector4 movieTextureST = Vector4.zero;
|
||||
private Texture2D[] textures;
|
||||
private RenderTexture[] renderTextures;
|
||||
System.IntPtr[] nativePtrs;
|
||||
private bool isStoppingForSeek = false;
|
||||
private bool isStartTriggered = true;
|
||||
private bool hasRenderedNewFrame = false;
|
||||
|
||||
public RendererResourceOSXH264Yuv(int playerId, MovieInfo movieInfo, bool additive, Shader userShader)
|
||||
{
|
||||
this.width = (int)movieInfo.width;
|
||||
this.height = (int)movieInfo.height;
|
||||
this.playerId = playerId;
|
||||
this.hasAlpha = movieInfo.hasAlpha;
|
||||
this.additive = additive;
|
||||
this.useUserShader = userShader != null;
|
||||
|
||||
if (userShader != null) {
|
||||
shader = userShader;
|
||||
} else {
|
||||
string shaderName = "CriMana/OSXH264Yuv";
|
||||
shader = Shader.Find(shaderName);
|
||||
}
|
||||
|
||||
if (hasAlpha) {
|
||||
nativePtrs = new System.IntPtr[2];
|
||||
} else {
|
||||
nativePtrs = new System.IntPtr[1];
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDisposeManaged()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisposeUnmanaged()
|
||||
{
|
||||
DisposeTextures(textures);
|
||||
DisposeTextures(renderTextures);
|
||||
textures = null;
|
||||
renderTextures = null;
|
||||
currentMaterial = null;
|
||||
}
|
||||
|
||||
public override bool IsPrepared()
|
||||
{ return true; }
|
||||
|
||||
public override bool ContinuePreparing()
|
||||
{ return true; }
|
||||
|
||||
public override bool IsSuitable(int playerId, MovieInfo movieInfo, bool additive, Shader userShader)
|
||||
{
|
||||
bool isCodecSuitable = movieInfo.codecType == CodecType.H264;
|
||||
bool isAlphaSuitable = hasAlpha == movieInfo.hasAlpha;
|
||||
bool isAdditiveSuitable = this.additive == additive;
|
||||
bool isShaderSuitable = this.useUserShader ? (userShader == shader) : true;
|
||||
return isCodecSuitable && isAlphaSuitable && isAdditiveSuitable && isShaderSuitable;
|
||||
}
|
||||
|
||||
public override bool OnPlayerStopForSeek()
|
||||
{
|
||||
isStoppingForSeek = true;
|
||||
isStartTriggered = false;
|
||||
if (renderTextures != null || textures == null) {
|
||||
return true;
|
||||
}
|
||||
renderTextures = new RenderTexture[hasAlpha ? 2 : 1];
|
||||
for (int i = 0; i < renderTextures.Length; i++) {
|
||||
Texture2D baseTexture = textures[i];
|
||||
RenderTexture texture = new RenderTexture(baseTexture.width, baseTexture.height, 0,
|
||||
i == 0 ? RenderTextureFormat.ARGB32 : RenderTextureFormat.R8);
|
||||
texture.Create();
|
||||
Graphics.Blit(baseTexture, texture);
|
||||
renderTextures[i] = texture;
|
||||
}
|
||||
forceUpdateMaterialTextures(renderTextures);
|
||||
DisposeTextures(textures);
|
||||
textures = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnPlayerStart()
|
||||
{
|
||||
isStartTriggered = true;
|
||||
}
|
||||
|
||||
public override bool HasRenderedNewFrame()
|
||||
{
|
||||
return hasRenderedNewFrame;
|
||||
}
|
||||
|
||||
private void forceUpdateMaterialTextures(Texture[] newTextures)
|
||||
{
|
||||
if (currentMaterial != null) {
|
||||
currentMaterial.mainTexture = newTextures[0];
|
||||
currentMaterial.SetTexture("_TextureRGB", newTextures[0]);
|
||||
if (hasAlpha) {
|
||||
currentMaterial.SetTexture("_TextureA", newTextures[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void AttachToPlayer(int playerId)
|
||||
{
|
||||
// reset texture if exist
|
||||
DisposeTextures(textures);
|
||||
textures = null;
|
||||
hasRenderedNewFrame = false;
|
||||
}
|
||||
|
||||
public override bool UpdateFrame(int playerId, FrameInfo frameInfo, ref bool frameDrop)
|
||||
{
|
||||
bool isFrameUpdated = CRIWARE9061FF01(playerId, 0, null, frameInfo, ref frameDrop);
|
||||
if (isFrameUpdated && !frameDrop) {
|
||||
UpdateMovieTextureST(frameInfo.dispWidth, frameInfo.dispHeight);
|
||||
}
|
||||
|
||||
return isFrameUpdated;
|
||||
}
|
||||
|
||||
public override bool UpdateMaterial(Material material)
|
||||
{
|
||||
if (currentMaterial != material) {
|
||||
if (textures != null || isStoppingForSeek) {
|
||||
currentMaterial = material;
|
||||
SetupStaticMaterialProperties();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
material.SetVector("_MovieTexture_ST", movieTextureST);
|
||||
if (textures != null && !isStoppingForSeek) {
|
||||
material.SetTexture("_TextureRGB", textures[0]);
|
||||
if (hasAlpha) {
|
||||
material.SetTexture("_TextureA", textures[1]);
|
||||
}
|
||||
DisposeTextures(renderTextures);
|
||||
renderTextures = null;
|
||||
hasRenderedNewFrame = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void UpdateMovieTextureST(System.UInt32 dispWidth, System.UInt32 dispHeight)
|
||||
{
|
||||
float uScale = (dispWidth != width) ? (float)(dispWidth - 0.5f) / width : 1.0f;
|
||||
float vScale = (dispHeight != height) ? (float)(dispHeight - 0.5f) / height : 1.0f;
|
||||
movieTextureST.x = uScale;
|
||||
movieTextureST.y = -vScale;
|
||||
movieTextureST.z = 0.0f;
|
||||
movieTextureST.w = vScale;
|
||||
}
|
||||
|
||||
public override void UpdateTextures()
|
||||
{
|
||||
for (int i = 0; i < nativePtrs.Length; i++) {
|
||||
nativePtrs[i] = System.IntPtr.Zero;
|
||||
}
|
||||
bool isTextureUpdated = CRIWAREDA63C3D7(playerId, nativePtrs.Length, nativePtrs);
|
||||
if (isTextureUpdated && nativePtrs[0] != System.IntPtr.Zero && isStartTriggered) {
|
||||
if (textures == null) {
|
||||
textures = new Texture2D[2];
|
||||
textures[0] = Texture2D.CreateExternalTexture(width, height, TextureFormat.BGRA32, false, false, nativePtrs[0]);
|
||||
textures[0].wrapMode = TextureWrapMode.Clamp;
|
||||
if (hasAlpha) {
|
||||
textures[1] = Texture2D.CreateExternalTexture(width, height, TextureFormat.R8, false, false, nativePtrs[1]);
|
||||
textures[1].wrapMode = TextureWrapMode.Clamp;
|
||||
}
|
||||
} else {
|
||||
textures[0].UpdateExternalTexture(nativePtrs[0]);
|
||||
if (hasAlpha) {
|
||||
textures[1].UpdateExternalTexture(nativePtrs[1]);
|
||||
}
|
||||
}
|
||||
isStoppingForSeek = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace CriWare
|
||||
|
||||
#endif
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 90d607173f1704c988704d3aed98260c
|
||||
timeCreated: 1461031521
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 18b37d25e817cb04f88473c6a7eb1f7f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7d05e68ec8b2ea84f9fc2b883101751e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9586ec280901aae4d876151aee8ab969
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
Shader "CriMana/OSXH264Yuv"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
[HideInInspector] _MovieTexture_ST ("MovieTexture_ST", Vector) = (1.0, 1.0, 0, 0)
|
||||
[HideInInspector] _TextureRGB("TextureRGB", 2D) = "white" {}
|
||||
[HideInInspector] _TextureA("TextureA", 2D) = "white" {}
|
||||
[HideInInspector] _SrcBlendMode("SrcBlendMode", Int) = 0
|
||||
[HideInInspector] _DstBlendMode("DstBlendMode", Int) = 0
|
||||
[HideInInspector] _CullMode("CullMode", Int) = 2
|
||||
[HideInInspector] _ZWriteMode("ZWriteMode", Int) = 1
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"Queue" = "Transparent"
|
||||
"PreviewType"="Plane"
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Blend [_SrcBlendMode] [_DstBlendMode]
|
||||
Cull [_CullMode]
|
||||
ZWrite [_ZWriteMode]
|
||||
ZTest [unity_GUIZTestMode]
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
#pragma multi_compile _ CRI_ALPHA_MOVIE
|
||||
#pragma multi_compile _ CRI_APPLY_TARGET_ALPHA
|
||||
#pragma multi_compile _ CRI_LINEAR_COLORSPACE
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
half2 texcoord : TEXCOORD0;
|
||||
#ifdef CRI_APPLY_TARGET_ALPHA
|
||||
float4 color : COLOR;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
half2 uv : TEXCOORD0;
|
||||
#ifdef CRI_APPLY_TARGET_ALPHA
|
||||
float4 color : COLOR;
|
||||
#endif
|
||||
};
|
||||
|
||||
float4 _MainTex_ST;
|
||||
float4 _MovieTexture_ST;
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = (TRANSFORM_TEX(v.texcoord, _MainTex) * _MovieTexture_ST.xy) + _MovieTexture_ST.zw;
|
||||
#ifdef CRI_APPLY_TARGET_ALPHA
|
||||
o.color = v.color;
|
||||
#endif
|
||||
return o;
|
||||
}
|
||||
|
||||
sampler2D _TextureRGB;
|
||||
#ifdef CRI_ALPHA_MOVIE
|
||||
sampler2D _TextureA;
|
||||
#endif
|
||||
fixed _Transparency;
|
||||
|
||||
fixed4 frag(v2f i) : COLOR
|
||||
{
|
||||
fixed4 color = tex2D(_TextureRGB, i.uv);
|
||||
#ifdef CRI_ALPHA_MOVIE
|
||||
fixed4 alpha = tex2D(_TextureA, i.uv);
|
||||
color.a = alpha.r;
|
||||
#endif
|
||||
#ifdef CRI_LINEAR_COLORSPACE
|
||||
color.rgb = pow(max(color.rgb, 0), 2.2);
|
||||
#endif
|
||||
#ifdef CRI_APPLY_TARGET_ALPHA
|
||||
color.a = color.a * i.color.a;
|
||||
#endif
|
||||
color.a *= 1 - _Transparency;
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ecadf8cf71554c599b839bc4a1933ec
|
||||
timeCreated: 1461226273
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,34 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f94522956777deb4e8d972962d38163b
|
||||
folderAsset: yes
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 88559606d836bf24a993061c34c02e08
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>BuildMachineOSBuild</key>
|
||||
<string>20G165</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>cri_ware_unity</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>CRI-MIddleware.cri-ware-unity</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>cri_ware_unity</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
<array>
|
||||
<string>MacOSX</string>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>DTCompiler</key>
|
||||
<string>com.apple.compilers.llvm.clang.1_0</string>
|
||||
<key>DTPlatformBuild</key>
|
||||
<string>12E262</string>
|
||||
<key>DTPlatformName</key>
|
||||
<string>macosx</string>
|
||||
<key>DTPlatformVersion</key>
|
||||
<string>11.3</string>
|
||||
<key>DTSDKBuild</key>
|
||||
<string>20E214</string>
|
||||
<key>DTSDKName</key>
|
||||
<string>macosx11.3</string>
|
||||
<key>DTXcode</key>
|
||||
<string>1250</string>
|
||||
<key>DTXcodeBuild</key>
|
||||
<string>12E262</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.8</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2011 CRI Middleware Co., Ltd. All rights reserved.</string>
|
||||
</dict>
|
||||
</plist>
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 46f76bc75ce101d4296a6a2cf1a54468
|
||||
timeCreated: 1433816075
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b42da6358acfc714f824d34950105eaa
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Binary file not shown.
+8
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 389f1b8cdccb3dd41b4ce4196bebdf2c
|
||||
timeCreated: 1433816075
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5612404e556d7a4fbd0a90e33e403a0
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1486e94701ec91a49bbf03853d7dcc6f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f9fd4d8483bedeb42af10f32fb1f5edc
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c1acf7590ab665846b0f97f1e6964343
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2018 CRI Middleware Co., Ltd.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if UNITY_EDITOR_WIN || (!UNITY_EDITOR && UNITY_STANDALONE_WIN)
|
||||
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace CriWare {
|
||||
|
||||
namespace CriMana.Detail
|
||||
{
|
||||
public static partial class AutoResisterRendererResourceFactories
|
||||
{
|
||||
[RendererResourceFactoryPriority(7050)]
|
||||
public class RendererResourceFactoryH264Yuv : RendererResourceFactory
|
||||
{
|
||||
public override RendererResource CreateRendererResource(int playerId, MovieInfo movieInfo, bool additive, Shader userShader)
|
||||
{
|
||||
bool isCodecSuitable = movieInfo.codecType == CodecType.H264;
|
||||
bool isSuitable = isCodecSuitable;
|
||||
return isSuitable
|
||||
? new RendererResourceH264Yuv(playerId, movieInfo, additive, userShader)
|
||||
: null;
|
||||
}
|
||||
|
||||
protected override void OnDisposeManaged()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisposeUnmanaged()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public class RendererResourceH264Yuv : RendererResourceSofdecPrimeYuv
|
||||
{
|
||||
public RendererResourceH264Yuv(int playerId, MovieInfo movieInfo, bool additive, Shader userShader)
|
||||
: base(playerId, movieInfo, additive, userShader)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace CriWare
|
||||
|
||||
#endif
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 22b685975748b4f458c2d610d4c0fa8a
|
||||
timeCreated: 1519977517
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0085654a191787142b488dd4b2f6f630
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,170 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 97f1044c5eb4800469ccddc26b4b5051
|
||||
timeCreated: 1426744594
|
||||
licenseType: Pro
|
||||
PluginImporter:
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
platformData:
|
||||
data:
|
||||
first:
|
||||
'': Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 1
|
||||
Exclude Editor: 0
|
||||
Exclude Linux: 1
|
||||
Exclude Linux64: 1
|
||||
Exclude LinuxUniversal: 1
|
||||
Exclude OSXIntel: 1
|
||||
Exclude OSXIntel64: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude WebGL: 1
|
||||
Exclude Win: 0
|
||||
Exclude Win64: 1
|
||||
Exclude WindowsStoreApps: 1
|
||||
Exclude iOS: 1
|
||||
Exclude tvOS: 1
|
||||
data:
|
||||
first:
|
||||
'': Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86
|
||||
OS: Windows
|
||||
data:
|
||||
first:
|
||||
'': WP8
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DontProcess: False
|
||||
PlaceholderPath:
|
||||
data:
|
||||
first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: ARMv7
|
||||
data:
|
||||
first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
data:
|
||||
first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86
|
||||
DefaultValueInitialized: true
|
||||
OS: Windows
|
||||
data:
|
||||
first:
|
||||
Facebook: Win
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Facebook: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
data:
|
||||
first:
|
||||
Standalone: Linux
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
data:
|
||||
first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
data:
|
||||
first:
|
||||
Standalone: LinuxUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
data:
|
||||
first:
|
||||
Standalone: OSXIntel
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
data:
|
||||
first:
|
||||
Standalone: OSXIntel64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
data:
|
||||
first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
data:
|
||||
first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
data:
|
||||
first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DontProcess: False
|
||||
PlaceholderPath:
|
||||
SDK: AnySDK
|
||||
ScriptingBackend: AnyScriptingBackend
|
||||
data:
|
||||
first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
data:
|
||||
first:
|
||||
tvOS: tvOS
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e98eac060c5549243955f09502bb8fe9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,170 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 11dc7019b5cfcce4fa41ab5aeed0d100
|
||||
timeCreated: 1426744594
|
||||
licenseType: Pro
|
||||
PluginImporter:
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
platformData:
|
||||
data:
|
||||
first:
|
||||
'': Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 1
|
||||
Exclude Editor: 0
|
||||
Exclude Linux: 1
|
||||
Exclude Linux64: 1
|
||||
Exclude LinuxUniversal: 1
|
||||
Exclude OSXIntel: 1
|
||||
Exclude OSXIntel64: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude WebGL: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 0
|
||||
Exclude WindowsStoreApps: 1
|
||||
Exclude iOS: 1
|
||||
Exclude tvOS: 1
|
||||
data:
|
||||
first:
|
||||
'': Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86_64
|
||||
OS: Windows
|
||||
data:
|
||||
first:
|
||||
'': WP8
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DontProcess: False
|
||||
PlaceholderPath:
|
||||
data:
|
||||
first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: ARMv7
|
||||
data:
|
||||
first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
data:
|
||||
first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86_64
|
||||
DefaultValueInitialized: true
|
||||
OS: Windows
|
||||
data:
|
||||
first:
|
||||
Facebook: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
data:
|
||||
first:
|
||||
Facebook: Win64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Standalone: Linux
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
data:
|
||||
first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
data:
|
||||
first:
|
||||
Standalone: LinuxUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
data:
|
||||
first:
|
||||
Standalone: OSXIntel
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
data:
|
||||
first:
|
||||
Standalone: OSXIntel64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
data:
|
||||
first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
data:
|
||||
first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
data:
|
||||
first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DontProcess: False
|
||||
PlaceholderPath:
|
||||
SDK: AnySDK
|
||||
ScriptingBackend: AnyScriptingBackend
|
||||
data:
|
||||
first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
data:
|
||||
first:
|
||||
tvOS: tvOS
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68b614df2c042ad4398088c45c588c00
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c403dfd3a2abce649a9d6614ea01b477
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4076c7d5838e59547a5e9564d834c0ec
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8a40a096f7fd29442897934a830baf4f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+304
@@ -0,0 +1,304 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2015 CRI Middleware Co., Ltd.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if !UNITY_TVOS
|
||||
#define CRIMANAUNITY_ENABLE_PAUSE_TEXTURE
|
||||
#endif
|
||||
|
||||
#if !UNITY_EDITOR && (UNITY_IOS || UNITY_TVOS)
|
||||
|
||||
using UnityEngine;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace CriWare {
|
||||
|
||||
namespace CriMana.Detail
|
||||
{
|
||||
public static partial class AutoResisterRendererResourceFactories
|
||||
{
|
||||
[RendererResourceFactoryPriority(7000)]
|
||||
public class RendererResourceFactoryIOSH264Yuv : RendererResourceFactory
|
||||
{
|
||||
public override RendererResource CreateRendererResource(int playerId, MovieInfo movieInfo, bool additive, Shader userShader)
|
||||
{
|
||||
bool isCodecSuitable = movieInfo.codecType == CodecType.H264;
|
||||
bool isSuitable = isCodecSuitable;
|
||||
return isSuitable
|
||||
? new RendererResourceIOSH264Yuv(playerId, movieInfo, additive, userShader)
|
||||
: null;
|
||||
}
|
||||
|
||||
protected override void OnDisposeManaged()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisposeUnmanaged()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class RendererResourceIOSH264Yuv : RendererResource
|
||||
{
|
||||
private int width;
|
||||
private int height;
|
||||
private int playerId;
|
||||
private bool useUserShader;
|
||||
private bool useOGLTempTextures;
|
||||
private bool isPaused;
|
||||
|
||||
private Vector4 movieTextureST = Vector4.zero;
|
||||
|
||||
private Texture2D[] textures;
|
||||
private RenderTexture[] pauseTextures;
|
||||
private Texture[] currentTextures;
|
||||
private System.IntPtr[] nativePtrs;
|
||||
private bool isStoppingForSeek = false;
|
||||
private bool isStartTriggered = true;
|
||||
|
||||
public RendererResourceIOSH264Yuv(int playerId, MovieInfo movieInfo, bool additive, Shader userShader)
|
||||
{
|
||||
this.width = (int)movieInfo.width;
|
||||
this.height = (int)movieInfo.height;
|
||||
this.playerId = playerId;
|
||||
hasAlpha = movieInfo.hasAlpha;
|
||||
this.additive = additive;
|
||||
useUserShader = userShader != null;
|
||||
|
||||
if (userShader != null) {
|
||||
shader = userShader;
|
||||
} else {
|
||||
string shaderName = "CriMana/IOSH264Yuv";
|
||||
shader = Shader.Find(shaderName);
|
||||
}
|
||||
|
||||
int numTextures = hasAlpha ? 3 : 2;
|
||||
textures = new Texture2D[numTextures];
|
||||
nativePtrs = new System.IntPtr[numTextures];
|
||||
|
||||
UpdateMovieTextureST(movieInfo.dispWidth, movieInfo.dispHeight);
|
||||
|
||||
#if (UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_5_0)
|
||||
useOGLTempTextures = SystemInfo.graphicsDeviceVersion.StartsWith("OpenGL");
|
||||
#else
|
||||
useOGLTempTextures = (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.OpenGLES2);
|
||||
#endif
|
||||
currentTextures = textures;
|
||||
}
|
||||
|
||||
|
||||
protected override void OnDisposeManaged()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
protected override void OnDisposeUnmanaged()
|
||||
{
|
||||
DisposeTextures(textures);
|
||||
DisposeTextures(pauseTextures);
|
||||
textures = null;
|
||||
pauseTextures = null;
|
||||
currentMaterial = null;
|
||||
}
|
||||
|
||||
|
||||
public override bool IsPrepared()
|
||||
{ return true; }
|
||||
|
||||
|
||||
public override bool ContinuePreparing()
|
||||
{ return true; }
|
||||
|
||||
public override bool IsSuitable(int playerId, MovieInfo movieInfo, bool additive, Shader userShader)
|
||||
{
|
||||
bool isCodecSuitable = movieInfo.codecType == CodecType.H264;
|
||||
bool isAlphaSuitable = hasAlpha == movieInfo.hasAlpha;
|
||||
bool isAdditiveSuitable = this.additive == additive;
|
||||
bool isShaderSuitable = this.useUserShader ? (userShader == shader) : true;
|
||||
return isCodecSuitable && isAlphaSuitable && isAdditiveSuitable && isShaderSuitable;
|
||||
}
|
||||
|
||||
public override void AttachToPlayer(int playerId)
|
||||
{
|
||||
DisposeTextures(textures);
|
||||
if (!isStoppingForSeek) {
|
||||
DisposeTextures(pauseTextures);
|
||||
pauseTextures = null;
|
||||
currentTextures = textures;
|
||||
}
|
||||
isPaused = false;
|
||||
}
|
||||
|
||||
// app did goes background / will goes foreground or player is paused
|
||||
public override void OnPlayerPause(bool pauseStatus, bool triggredFromApplciationPause)
|
||||
{
|
||||
#if CRIMANAUNITY_ENABLE_PAUSE_TEXTURE
|
||||
if (pauseStatus && !triggredFromApplciationPause) {
|
||||
// Do nothing if the user code triggered Pause(true).
|
||||
return;
|
||||
}
|
||||
|
||||
if (pauseStatus == true) {
|
||||
if (isPaused == false && !isStoppingForSeek) {
|
||||
isPaused = true;
|
||||
applyCurrentTexturesToPausedTextures();
|
||||
}
|
||||
} else {
|
||||
isPaused = false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public override bool OnPlayerStopForSeek() {
|
||||
isStoppingForSeek = true;
|
||||
isStartTriggered = false;
|
||||
if (pauseTextures != null || textures[0] == null) {
|
||||
return true;
|
||||
}
|
||||
applyCurrentTexturesToPausedTextures();
|
||||
DisposeTextures(textures);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnPlayerStart() {
|
||||
isStartTriggered = true;
|
||||
}
|
||||
|
||||
private void restorePausedTextures()
|
||||
{
|
||||
forceUpdateMaterialTextures(textures);
|
||||
DisposeTextures(pauseTextures);
|
||||
pauseTextures = null;
|
||||
}
|
||||
|
||||
private void applyCurrentTexturesToPausedTextures() {
|
||||
if (textures[0] == null) {
|
||||
return;
|
||||
}
|
||||
pauseTextures = new RenderTexture[hasAlpha ? 3 : 2];
|
||||
for (int i = 0; i < pauseTextures.Length; i++) {
|
||||
Texture2D baseTexture = textures[i];
|
||||
RenderTexture texture = new RenderTexture(baseTexture.width, baseTexture.height, 0,
|
||||
i == 1 ? RenderTextureFormat.RG16 : RenderTextureFormat.R8);
|
||||
texture.Create();
|
||||
Graphics.Blit(baseTexture, texture);
|
||||
pauseTextures[i] = texture;
|
||||
}
|
||||
forceUpdateMaterialTextures(pauseTextures);
|
||||
}
|
||||
|
||||
private void forceUpdateMaterialTextures(Texture[] newTextures)
|
||||
{
|
||||
currentTextures = newTextures;
|
||||
if (currentMaterial != null) {
|
||||
currentMaterial.SetTexture("_TextureY", currentTextures[0]);
|
||||
currentMaterial.SetTexture("_TextureUV", currentTextures[1]);
|
||||
if (hasAlpha) {
|
||||
currentMaterial.SetTexture("_TextureA", currentTextures[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool UpdateFrame(int playerId, FrameInfo frameInfo, ref bool frameDrop)
|
||||
{
|
||||
bool isFrameUpdated = CRIWARE9061FF01(playerId, 0, null, frameInfo, ref frameDrop);
|
||||
if (isFrameUpdated && !frameDrop) {
|
||||
UpdateMovieTextureST(frameInfo.dispWidth, frameInfo.dispHeight);
|
||||
}
|
||||
return isFrameUpdated;
|
||||
}
|
||||
|
||||
public override bool UpdateMaterial(Material material)
|
||||
{
|
||||
if (currentTextures[0] != null) {
|
||||
if (currentMaterial != material) {
|
||||
currentMaterial = material;
|
||||
SetupStaticMaterialProperties();
|
||||
}
|
||||
|
||||
if (!(isPaused || isStoppingForSeek) && pauseTextures != null &&
|
||||
!CRIWARE98E7CD5C(playerId)) {
|
||||
restorePausedTextures();
|
||||
isStoppingForSeek = false;
|
||||
} else {
|
||||
material.SetTexture("_TextureY", currentTextures[0]);
|
||||
material.SetTexture("_TextureUV", currentTextures[1]);
|
||||
if (hasAlpha) {
|
||||
material.SetTexture("_TextureA", currentTextures[2]);
|
||||
}
|
||||
}
|
||||
material.SetVector("_MovieTexture_ST", movieTextureST);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void UpdateMovieTextureST(System.UInt32 dispWidth, System.UInt32 dispHeight)
|
||||
{
|
||||
float uScale = (dispWidth != width) ? (float)(dispWidth - 0.5f) / width : 1.0f;
|
||||
float vScale = (dispHeight != height) ? (float)(dispHeight - 0.5f) / height : 1.0f;
|
||||
movieTextureST.x = uScale;
|
||||
movieTextureST.y = -vScale;
|
||||
movieTextureST.z = 0.0f;
|
||||
movieTextureST.w = vScale;
|
||||
}
|
||||
|
||||
|
||||
public override void UpdateTextures()
|
||||
{
|
||||
int numTextures = hasAlpha ? 3 : 2;
|
||||
for (int i = 0; i < numTextures; i++) {
|
||||
nativePtrs[i] = System.IntPtr.Zero;
|
||||
}
|
||||
bool isTextureUpdated = CRIWAREDA63C3D7(playerId, numTextures, nativePtrs); // out textures
|
||||
if (isTextureUpdated && nativePtrs[0] != System.IntPtr.Zero && isStartTriggered) {
|
||||
if (useOGLTempTextures) {
|
||||
for (int i = 0; i < numTextures; i++) {
|
||||
if (textures[i] == null) {
|
||||
textures[i] = Texture2D.CreateExternalTexture((i == 1) ? width / 2 : width,
|
||||
(i == 1) ? height / 2 : height,
|
||||
TextureFormat.Alpha8, false, false, nativePtrs[i]);
|
||||
}
|
||||
Texture2D tmptexture = Texture2D.CreateExternalTexture(textures[i].width, textures[i].height,
|
||||
textures[i].format, false, false, nativePtrs[i]);
|
||||
tmptexture.wrapMode = TextureWrapMode.Clamp;
|
||||
textures[i].UpdateExternalTexture(tmptexture.GetNativeTexturePtr());
|
||||
Texture2D.Destroy(tmptexture);
|
||||
}
|
||||
} else {
|
||||
if (textures[0] == null) {
|
||||
for (int i = 0; i < numTextures; i++) {
|
||||
textures[i] = Texture2D.CreateExternalTexture((i == 1) ? width / 2 : width,
|
||||
(i == 1) ? height / 2 : height,
|
||||
TextureFormat.Alpha8, false, false, nativePtrs[i]);
|
||||
textures[i].wrapMode = TextureWrapMode.Clamp;
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < numTextures; i++) {
|
||||
textures[i].UpdateExternalTexture(nativePtrs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
isStoppingForSeek = false;
|
||||
}
|
||||
}
|
||||
#region DLL Import
|
||||
#if !CRIWARE_ENABLE_HEADLESS_MODE
|
||||
[DllImport(CriWare.Common.pluginName, CallingConvention = CriWare.Common.pluginCallingConvention)]
|
||||
private static extern bool CRIWARE98E7CD5C(int player_id);
|
||||
#else
|
||||
private static bool CRIWARE98E7CD5C(int player_id) { return false; }
|
||||
#endif
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace CriWare
|
||||
|
||||
#endif
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94c1562415bc34e84ae61159d64be8ba
|
||||
timeCreated: 1445063317
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b738fb39de55bf04082cd90d03122f77
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba8d491c70288244f8c3c7e611f5de1c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 96ba295336ea5bb4180347189069a981
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
Shader "CriMana/IOSH264Yuv"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
[HideInInspector] _MovieTexture_ST ("MovieTexture_ST", Vector) = (1.0, 1.0, 0, 0)
|
||||
[HideInInspector] _TextureY ("TextureY", 2D) = "white" {}
|
||||
[HideInInspector] _TextureUV ("TextureUV", 2D) = "white" {}
|
||||
[HideInInspector] _TextureA("TextureA", 2D) = "white" {}
|
||||
[HideInInspector] _SrcBlendMode("SrcBlendMode", Int) = 0
|
||||
[HideInInspector] _DstBlendMode("DstBlendMode", Int) = 0
|
||||
[HideInInspector] _CullMode("CullMode", Int) = 2
|
||||
[HideInInspector] _ZWriteMode("ZWriteMode", Int) = 1
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"Queue" = "Transparent"
|
||||
"PreviewType"="Plane"
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Blend [_SrcBlendMode] [_DstBlendMode]
|
||||
Cull [_CullMode]
|
||||
ZWrite [_ZWriteMode]
|
||||
ZTest [unity_GUIZTestMode]
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
#pragma multi_compile _ CRI_ALPHA_MOVIE
|
||||
#pragma multi_compile _ CRI_APPLY_TARGET_ALPHA
|
||||
#pragma multi_compile _ CRI_LINEAR_COLORSPACE
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
half2 texcoord : TEXCOORD0;
|
||||
#ifdef CRI_APPLY_TARGET_ALPHA
|
||||
float4 color : COLOR;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
half2 uv : TEXCOORD0;
|
||||
#ifdef CRI_APPLY_TARGET_ALPHA
|
||||
float4 color : COLOR;
|
||||
#endif
|
||||
};
|
||||
|
||||
float4 _MainTex_ST;
|
||||
float4 _MovieTexture_ST;
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = (TRANSFORM_TEX(v.texcoord, _MainTex) * _MovieTexture_ST.xy) + _MovieTexture_ST.zw;
|
||||
#ifdef CRI_APPLY_TARGET_ALPHA
|
||||
o.color = v.color;
|
||||
#endif
|
||||
return o;
|
||||
}
|
||||
|
||||
static const fixed3x3 yuv_to_rgb = {
|
||||
{1.16438, 0.0, 1.59603},
|
||||
{1.16438, -0.39176, -0.81297},
|
||||
{1.16438, 2.01723, 0.0}
|
||||
};
|
||||
|
||||
sampler2D _TextureY;
|
||||
sampler2D _TextureUV;
|
||||
#ifdef CRI_ALPHA_MOVIE
|
||||
sampler2D _TextureA;
|
||||
#endif
|
||||
fixed _Transparency;
|
||||
|
||||
fixed4 frag(v2f i) : COLOR
|
||||
{
|
||||
fixed3 yuv = {
|
||||
(tex2D(_TextureY, i.uv).r - 0.06275),
|
||||
(tex2D(_TextureUV, i.uv).rg - 0.50196)
|
||||
};
|
||||
fixed4 color;
|
||||
color.rgb = mul(yuv_to_rgb, yuv);
|
||||
#ifdef CRI_LINEAR_COLORSPACE
|
||||
color.rgb = pow(max(color.rgb, 0), 2.2);
|
||||
#endif
|
||||
#ifdef CRI_ALPHA_MOVIE
|
||||
color.a = tex2D(_TextureA, i.uv).r;
|
||||
#else
|
||||
color.a = 1.0;
|
||||
#endif
|
||||
#ifdef CRI_APPLY_TARGET_ALPHA
|
||||
color.a = color.a * i.color.a;
|
||||
#endif
|
||||
color.a *= 1 - _Transparency;
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 656f87fa1d9f944d58250696a84e9156
|
||||
timeCreated: 1445063698
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,158 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ffa5e8469874b54bbf51f0e75e154fa
|
||||
timeCreated: 1433816085
|
||||
licenseType: Pro
|
||||
PluginImporter:
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
platformData:
|
||||
data:
|
||||
first:
|
||||
'': Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 1
|
||||
Exclude Editor: 1
|
||||
Exclude Linux: 1
|
||||
Exclude Linux64: 1
|
||||
Exclude LinuxUniversal: 1
|
||||
Exclude OSXIntel: 1
|
||||
Exclude OSXIntel64: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude WebGL: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
Exclude WindowsStoreApps: 1
|
||||
Exclude iOS: 0
|
||||
Exclude tvOS: 1
|
||||
data:
|
||||
first:
|
||||
'': Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
OS: AnyOS
|
||||
data:
|
||||
first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: ARMv7
|
||||
data:
|
||||
first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 1
|
||||
Exclude Editor: 1
|
||||
Exclude Linux: 1
|
||||
Exclude Linux64: 1
|
||||
Exclude LinuxUniversal: 1
|
||||
Exclude OSXIntel: 1
|
||||
Exclude OSXIntel64: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude WebGL: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
Exclude iOS: 0
|
||||
Exclude tvOS: 1
|
||||
data:
|
||||
first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
data:
|
||||
first:
|
||||
Facebook: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Facebook: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Standalone: Linux
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86
|
||||
data:
|
||||
first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86_64
|
||||
data:
|
||||
first:
|
||||
Standalone: OSXIntel
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Standalone: OSXIntel64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DontProcess: False
|
||||
PlaceholderPath:
|
||||
SDK: AnySDK
|
||||
ScriptingBackend: AnyScriptingBackend
|
||||
data:
|
||||
first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
data:
|
||||
first:
|
||||
tvOS: tvOS
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ce84d2ef51a0b341ad70b233b61bfa0
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a828a7fe5697c384c8e4decaa8373824
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 91f529aa944b914449d62b8c40f188fe
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: -11
|
||||
icon: {instanceID: 0}
|
||||
@@ -0,0 +1,230 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2011 CRI Middleware Co., Ltd.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
/**
|
||||
* \addtogroup CRIATOM_UNITY_COMPONENT
|
||||
* @{
|
||||
*/
|
||||
|
||||
namespace CriWare {
|
||||
|
||||
/**
|
||||
* <summary>A component that represents a 3D listener.</summary>
|
||||
* <remarks>
|
||||
* <para header='Description'>Usually, it is used by attaching it to the GameObject object of the camera or main character.
|
||||
* The current position is updated automatically, so no special operation or setting is required.</para>
|
||||
* </remarks>
|
||||
*/
|
||||
[AddComponentMenu("CRIWARE/CRI Atom Listener")]
|
||||
public class CriAtomListener : CriMonoBehaviour
|
||||
{
|
||||
#region CRIWARE internals
|
||||
public static void CreateDummyNativeListener()
|
||||
{
|
||||
if (dummyNativeListener == null) {
|
||||
dummyNativeListener = new CriAtomEx3dListener();
|
||||
}
|
||||
}
|
||||
|
||||
public static void DestroyDummyNativeListener()
|
||||
{
|
||||
if (dummyNativeListener != null) {
|
||||
dummyNativeListener.Dispose();
|
||||
dummyNativeListener = null;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Fields & Properties
|
||||
/**
|
||||
* <summary>This is the CriAtomEx3dListener used internally.</summary>
|
||||
* <remarks>
|
||||
* <para header='Description'>If you want to control CriAtom3dListener directly, get CriAtom3dListener from this property.</para>
|
||||
* </remarks>
|
||||
*/
|
||||
public CriAtomEx3dListener nativeListener { get; protected set; }
|
||||
|
||||
[SerializeField] CriAtomRegion regionOnStart = null;
|
||||
|
||||
/**
|
||||
* <summary>Whether to make it an exclusive active listener in OnEnable</summary>
|
||||
* <remarks>
|
||||
* <para header='Description'>If true, when OnEnable is called, this listener will be activated
|
||||
* and all the other listeners will be deactivated.
|
||||
* If false, it will become active without affecting other listeners.</para>
|
||||
* </remarks>
|
||||
*/
|
||||
public bool activateListenerOnEnable = false;
|
||||
|
||||
/**
|
||||
* <summary>Whether the CriAtomListener is active</summary>
|
||||
* <remarks>
|
||||
* <para header='Description'>An active CriAtomListener acts as a listener for CriAtomSource audio. <br/>
|
||||
* If there are multiple CriAtomListeners, The 3D sound will be calculated <br/>
|
||||
* using the active listener that is closest to the CriAtomSource.</para>
|
||||
* </remarks>
|
||||
*/
|
||||
public bool isActive {
|
||||
get { return _isActive; }
|
||||
set {
|
||||
if (_isActive == value) return;
|
||||
_isActive = value;
|
||||
if (value)
|
||||
UpdatePosition();
|
||||
else {
|
||||
/* Make the listener unactive by setting far position. */
|
||||
nativeListener.SetPosition(float.MaxValue, float.MaxValue, float.MaxValue);
|
||||
nativeListener.Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <summary>Sets/gets 3D region of the sound source</summary>
|
||||
*/
|
||||
public CriAtomRegion region3d
|
||||
{
|
||||
get { return this.currentRegion; }
|
||||
set {
|
||||
if (this.currentRegion == value) {
|
||||
return;
|
||||
}
|
||||
/* Remove the reference frome the current region */
|
||||
if (this.currentRegion != null) {
|
||||
this.currentRegion.referringListeners.Remove(this);
|
||||
}
|
||||
CriAtomEx3dRegion regionHandle = (value == null) ? null : value.region3dHn;
|
||||
if (this.nativeListener != null) {
|
||||
this.nativeListener.Set3dRegion(regionHandle);
|
||||
this.nativeListener.Update();
|
||||
this.currentRegion = value;
|
||||
/* Seup a reference from a new region */
|
||||
if (this.currentRegion != null) {
|
||||
this.currentRegion.referringListeners.Add(this);
|
||||
}
|
||||
} else {
|
||||
Debug.LogError("[CRIWARE] Internal: CriAtomListener is not initialized correctly.");
|
||||
this.currentRegion = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Internal Variables
|
||||
static List<CriAtomListener> listenersList = new List<CriAtomListener>();
|
||||
|
||||
/* Dummy listenr used when CriAtomListenr is not exists. */
|
||||
static CriAtomEx3dListener dummyNativeListener;
|
||||
|
||||
private Vector3 lastPosition;
|
||||
private CriAtomRegion currentRegion = null;
|
||||
private bool _isActive = true;
|
||||
#endregion
|
||||
|
||||
#region Functions
|
||||
private void Awake()
|
||||
{
|
||||
if (!listenersList.Contains(this))
|
||||
listenersList.Add(this);
|
||||
DestroyDummyNativeListener();
|
||||
nativeListener = new CriAtomEx3dListener();
|
||||
isActive = enabled;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (regionOnStart != null) {
|
||||
region3d = this.regionOnStart;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
ActivateListener(activateListenerOnEnable);
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
base.OnDisable();
|
||||
isActive = false;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (listenersList.Contains(this)) {
|
||||
listenersList.Remove(this);
|
||||
}
|
||||
region3d = null;
|
||||
nativeListener.Dispose();
|
||||
nativeListener = null;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void OnDrawGizmos() {
|
||||
if (this.enabled == false) { return; }
|
||||
var criWareLightBlue = new Color(0.332f, 0.661f, 0.991f);
|
||||
Gizmos.color = isActive || !Application.isPlaying ? criWareLightBlue : Color.gray;
|
||||
Gizmos.DrawLine(this.transform.position, this.transform.position + this.transform.forward);
|
||||
Gizmos.DrawLine(this.transform.position, this.transform.position + this.transform.up);
|
||||
UnityEditor.Handles.color = isActive || !Application.isPlaying ? criWareLightBlue : Color.gray;
|
||||
UnityEditor.Handles.ArrowHandleCap(1, this.transform.position + this.transform.forward, this.transform.rotation, 1f, EventType.Repaint);
|
||||
UnityEditor.Handles.RectangleHandleCap(1, this.transform.position, this.transform.rotation * Quaternion.LookRotation(Vector3.up), 1f, EventType.Repaint);
|
||||
}
|
||||
#endif
|
||||
|
||||
public override void CriInternalUpdate() { }
|
||||
|
||||
public override void CriInternalLateUpdate()
|
||||
{
|
||||
if (isActive)
|
||||
UpdatePosition();
|
||||
}
|
||||
|
||||
void UpdatePosition()
|
||||
{
|
||||
Vector3 position = this.transform.position;
|
||||
Vector3 velocity = (position - this.lastPosition) / Time.deltaTime;
|
||||
Vector3 front = this.transform.forward;
|
||||
Vector3 up = this.transform.up;
|
||||
this.lastPosition = position;
|
||||
if (nativeListener != null) {
|
||||
nativeListener.SetPosition(position.x, position.y, position.z);
|
||||
nativeListener.SetVelocity(velocity.x, velocity.y, velocity.z);
|
||||
nativeListener.SetOrientation(front.x, front.y, front.z, up.x, up.y, up.z);
|
||||
nativeListener.Update();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
/**
|
||||
* <summary>Make it an active listener</summary>
|
||||
* <param name='exclusive'>Whether to make this AtomListener the only active listener</param>
|
||||
* <remarks>
|
||||
* <para header='Description'>When it becomes an active listener, it acts as a 3D listener for CriWare.CriAtomSource .</para>
|
||||
* <para header='Note'>For compatibility with old plugins, when called with no arguments, <br/>
|
||||
* only the CriAtomListener calling this method will be active.</para>
|
||||
* </remarks>
|
||||
*/
|
||||
public void ActivateListener(bool exclusive = true)
|
||||
{
|
||||
if (exclusive) {
|
||||
foreach (var listener in listenersList) {
|
||||
if (listener == this) continue;
|
||||
listener.isActive = false;
|
||||
}
|
||||
}
|
||||
isActive = true;
|
||||
}
|
||||
} // end of class
|
||||
|
||||
} //namespace CriWare
|
||||
/** @} */
|
||||
/* end of file */
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce7d42e042e4c9c4db4bde98b863e167
|
||||
timeCreated: 1433816077
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 54b14f2540d554f4c9bafa3501e6dc9f, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,291 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) CRI Middleware Co., Ltd.
|
||||
*
|
||||
****************************************************************************/
|
||||
#if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IOS)
|
||||
#define CRIWAREPLUGIN_SUPPORT_OUTPUTDEVICE_OBSERVER
|
||||
#endif
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
|
||||
/**
|
||||
* \addtogroup CRIWARE_COMMON_CLASS
|
||||
* @{
|
||||
*/
|
||||
|
||||
namespace CriWare {
|
||||
|
||||
|
||||
/**
|
||||
* <summary>A component that monitors the connection status of audio output devices.</summary>
|
||||
* <remarks>
|
||||
* <para header='Description'>Use it by adding it to any GameObject.<br/>
|
||||
* You can monitor the connection status of the audio output device on your smartphone device and acquire the status externally.<br/>
|
||||
* By registering a delegate, you can also receive callbacks when the connection status changes.<br/>
|
||||
* To use this component, it is necessary to initialize the Atom library first.</para>
|
||||
* <para header='Note'>Currently, the functions of this component only work on smartphones (Android / iOS).<br/>
|
||||
* Please wait for future updates for support for other platforms.</para>
|
||||
* </remarks>
|
||||
*/
|
||||
public class CriAtomOutputDeviceObserver : CriMonoBehaviour
|
||||
{
|
||||
/**
|
||||
* <summary>Type of audio output device</summary>
|
||||
* <remarks>
|
||||
* <para header='Description'>Types of device to which audio is output from the application.</para>
|
||||
* </remarks>
|
||||
* <seealso cref='CriAtomOutputDeviceObserver::DeviceType'/>
|
||||
*/
|
||||
public enum OutputDeviceType {
|
||||
BuiltinSpeaker, /**< Internal Speaker */
|
||||
WiredDevice, /**< Wired device (wired headset, etc.) */
|
||||
WirelessDevice, /**< Wireless device (Bluetooth headset, etc.) */
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <summary>Connection state change callback delegate type</summary>
|
||||
* <param name='isConnected'>Output device connection status (false = disconnected, true = connected)</param>
|
||||
* <param name='deviceType'>Output device type</param>
|
||||
* <remarks>
|
||||
* <para header='Description'>This is the type of the callback function that is called when the connection status of the audio output device changes.</para>
|
||||
* </remarks>
|
||||
* <seealso cref='CriAtomOutputDeviceObserver::OnDeviceConnectionChanged'/>
|
||||
*/
|
||||
public delegate void DeviceConnectionChangeCallback(bool isConnected, OutputDeviceType deviceType);
|
||||
|
||||
|
||||
/**
|
||||
* <summary>Connection state change callback delegate</summary>
|
||||
* <remarks>
|
||||
* <para header='Description'>This is a callback function that is called when the connection status of the audio output device changes.<br/>
|
||||
* Called from the application's main thread.</para>
|
||||
* </remarks>
|
||||
* <seealso cref='CriAtomExOutputDeviceObserver::DeviceConnectionChangeCallback'/>
|
||||
*/
|
||||
public static event DeviceConnectionChangeCallback OnDeviceConnectionChanged {
|
||||
add {
|
||||
_onDeviceConnectionChanged += value;
|
||||
if (instance) {
|
||||
value(IsDeviceConnected, DeviceType);
|
||||
}
|
||||
}
|
||||
remove {
|
||||
_onDeviceConnectionChanged -= value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <summary>Gets device connection status</summary>
|
||||
* <returns>Whether connected (false = disconnected, true = connected)</returns>
|
||||
* <remarks>
|
||||
* <para header='Description'>Returns whether an audio output device is connected to the machine.<br/>
|
||||
* Returns true if the output destination is a device other than the internal speaker.</para>
|
||||
* </remarks>
|
||||
*/
|
||||
public static bool IsDeviceConnected {
|
||||
get {
|
||||
if (instance == null) {
|
||||
return false;
|
||||
}
|
||||
#if !UNITY_EDITOR && UNITY_IOS
|
||||
return UnsafeNativeMethods.criAtomUnity_IsOutputDeviceConnected_IOS();
|
||||
#elif !UNITY_EDITOR && UNITY_ANDROID
|
||||
return instance.isConnected;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <summary>Gets the output device type</summary>
|
||||
* <returns>Output device type</returns>
|
||||
* <remarks>
|
||||
* <para header='Description'>Gets the type of the current audio output device.</para>
|
||||
* </remarks>
|
||||
*/
|
||||
public static OutputDeviceType DeviceType {
|
||||
get {
|
||||
if (instance == null) {
|
||||
return OutputDeviceType.BuiltinSpeaker;
|
||||
}
|
||||
#if !UNITY_EDITOR && UNITY_IOS
|
||||
return UnsafeNativeMethods.criAtomUnity_GetOutputDeviceType_IOS();
|
||||
#elif !UNITY_EDITOR && UNITY_ANDROID
|
||||
return instance.deviceType;
|
||||
#else
|
||||
return OutputDeviceType.BuiltinSpeaker;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#region Internal Members
|
||||
[SerializeField] bool dontDestroyOnLoad = false;
|
||||
bool lastIsConnected = false;
|
||||
bool isConnected = false;
|
||||
OutputDeviceType lastDeviceType = OutputDeviceType.BuiltinSpeaker;
|
||||
OutputDeviceType deviceType = OutputDeviceType.BuiltinSpeaker;
|
||||
static CriAtomOutputDeviceObserver instance = null;
|
||||
static event DeviceConnectionChangeCallback _onDeviceConnectionChanged = null;
|
||||
#if !UNITY_EDITOR && UNITY_ANDROID
|
||||
static UnityEngine.AndroidJavaObject checker = null;
|
||||
#endif
|
||||
#endregion
|
||||
|
||||
#region Internal Functions
|
||||
private void Awake() {
|
||||
if (instance != null) {
|
||||
Destroy(this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CriAtomPlugin.IsLibraryInitialized()) {
|
||||
Debug.LogError("[CRIWARE] Atom library is not initialized. Cannot setup CriAtomExOutputDeviceObserver.");
|
||||
Destroy(this);
|
||||
return;
|
||||
}
|
||||
|
||||
instance = this;
|
||||
|
||||
#if CRIWAREPLUGIN_SUPPORT_OUTPUTDEVICE_OBSERVER
|
||||
#if !UNITY_EDITOR && UNITY_IOS
|
||||
bool isStarted = UnsafeNativeMethods.criAtomUnity_StartOutputDeviceObserver_IOS();
|
||||
if (!isStarted) {
|
||||
Debug.LogError("[CRIWARE] CriAtomOutputDeviceObserver cannot start while Atom library is not initialized.");
|
||||
}
|
||||
#elif !UNITY_EDITOR && UNITY_ANDROID
|
||||
UnityEngine.AndroidJavaClass jc = new UnityEngine.AndroidJavaClass("com.unity3d.player.UnityPlayer");
|
||||
UnityEngine.AndroidJavaObject activity = jc.GetStatic<UnityEngine.AndroidJavaObject>("currentActivity");
|
||||
|
||||
if (checker == null) {
|
||||
checker = new UnityEngine.AndroidJavaObject("com.crimw.crijavaclasses.CriOutputDeviceObserver", activity, this.gameObject.name, "CallbackFromObserver_ANDROID");
|
||||
}
|
||||
if (checker == null) {
|
||||
Debug.LogError("[CRIWARE] Cannot load CriOutputDeviceObserver class in library.");
|
||||
}
|
||||
checker.Call("Start", activity);
|
||||
CheckOutputDevice_ANDROID();
|
||||
#endif
|
||||
isConnected = lastIsConnected = IsDeviceConnected;
|
||||
deviceType = lastDeviceType = DeviceType;
|
||||
if (_onDeviceConnectionChanged != null) {
|
||||
_onDeviceConnectionChanged(isConnected, deviceType);
|
||||
}
|
||||
#elif !UNITY_EDITOR
|
||||
Debug.Log("[CRIWARE] CriAtomOutputDeviceObserver is not supported on this platform.");
|
||||
#endif
|
||||
if (this.dontDestroyOnLoad) {
|
||||
GameObject.DontDestroyOnLoad(this.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void OnDestroy() {
|
||||
if (instance != this) {
|
||||
return;
|
||||
}
|
||||
instance = null;
|
||||
|
||||
#if CRIWAREPLUGIN_SUPPORT_OUTPUTDEVICE_OBSERVER
|
||||
#if !UNITY_EDITOR && UNITY_IOS
|
||||
UnsafeNativeMethods.criAtomUnity_StopOutputDeviceObserver_IOS();
|
||||
#elif !UNITY_EDITOR && UNITY_ANDROID
|
||||
UnityEngine.AndroidJavaClass jc = new UnityEngine.AndroidJavaClass("com.unity3d.player.UnityPlayer");
|
||||
UnityEngine.AndroidJavaObject activity = jc.GetStatic<UnityEngine.AndroidJavaObject>("currentActivity");
|
||||
if (activity != null && checker != null) {
|
||||
checker.Call("Stop", activity);
|
||||
}
|
||||
checker = null;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
public override void CriInternalUpdate() {
|
||||
isConnected = IsDeviceConnected;
|
||||
deviceType = DeviceType;
|
||||
|
||||
if ((isConnected != lastIsConnected ||
|
||||
deviceType != lastDeviceType) &&
|
||||
_onDeviceConnectionChanged != null) {
|
||||
_onDeviceConnectionChanged(isConnected, deviceType);
|
||||
}
|
||||
lastIsConnected = isConnected;
|
||||
lastDeviceType = deviceType;
|
||||
}
|
||||
|
||||
|
||||
public override void CriInternalLateUpdate() {
|
||||
}
|
||||
|
||||
#if !UNITY_EDITOR && UNITY_ANDROID
|
||||
/* [ANDROID] Callback from CriOutputDeviceObserver class */
|
||||
private void CallbackFromObserver_ANDROID(string message) {
|
||||
if (message[0] == 'a') {
|
||||
CheckOutputDevice_ANDROID();
|
||||
} else if (message[0] == 'b') {
|
||||
StartCoroutine("CoroutineForCheck_ANDROID");
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckOutputDevice_ANDROID() {
|
||||
if (checker == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
UnityEngine.AndroidJavaClass jc = new UnityEngine.AndroidJavaClass("com.unity3d.player.UnityPlayer");
|
||||
UnityEngine.AndroidJavaObject activity = jc.GetStatic<UnityEngine.AndroidJavaObject>("currentActivity");
|
||||
int device = checker.Call<int>("CheckOutputDeviceType", activity);
|
||||
deviceType = (OutputDeviceType)device;
|
||||
isConnected = (deviceType != OutputDeviceType.BuiltinSpeaker);
|
||||
|
||||
}
|
||||
|
||||
private IEnumerator CoroutineForCheck_ANDROID() {
|
||||
const float waitSec = 2.0f;
|
||||
float time = 0.0f;
|
||||
while (time < waitSec) {
|
||||
yield return null;
|
||||
time += Time.deltaTime;
|
||||
}
|
||||
CheckOutputDevice_ANDROID();
|
||||
}
|
||||
|
||||
#endif
|
||||
#endregion
|
||||
|
||||
#region Dll Import
|
||||
private static class UnsafeNativeMethods
|
||||
{
|
||||
#if !CRIWARE_ENABLE_HEADLESS_MODE
|
||||
#if !UNITY_EDITOR && UNITY_IOS
|
||||
[DllImport(CriWare.Common.pluginName, CallingConvention = CriWare.Common.pluginCallingConvention)]
|
||||
internal static extern bool criAtomUnity_StartOutputDeviceObserver_IOS();
|
||||
[DllImport(CriWare.Common.pluginName, CallingConvention = CriWare.Common.pluginCallingConvention)]
|
||||
internal static extern void criAtomUnity_StopOutputDeviceObserver_IOS();
|
||||
[DllImport(CriWare.Common.pluginName, CallingConvention = CriWare.Common.pluginCallingConvention)]
|
||||
internal static extern bool criAtomUnity_IsOutputDeviceConnected_IOS();
|
||||
[DllImport(CriWare.Common.pluginName, CallingConvention = CriWare.Common.pluginCallingConvention)]
|
||||
internal static extern OutputDeviceType criAtomUnity_GetOutputDeviceType_IOS();
|
||||
#endif
|
||||
#else
|
||||
#if !UNITY_EDITOR && UNITY_IOS
|
||||
internal static bool criAtomUnity_StartOutputDeviceObserver_IOS() { return false; }
|
||||
internal static void criAtomUnity_StopOutputDeviceObserver_IOS() { }
|
||||
internal static bool criAtomUnity_IsOutputDeviceConnected_IOS() { return false; }
|
||||
internal static OutputDeviceType criAtomUnity_GetOutputDeviceType_IOS() { return OutputDeviceType.BuiltinSpeaker; }
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
#endregion
|
||||
|
||||
} // end of class
|
||||
|
||||
} //namespace CriWare
|
||||
/** @} */
|
||||
/* end of file */
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c9b37739fef8f4647acb0b94be4d34fc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,111 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2020 CRI Middleware Co., Ltd.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
/**
|
||||
* \addtogroup CRIATOM_UNITY_COMPONENT
|
||||
* @{
|
||||
*/
|
||||
|
||||
namespace CriWare {
|
||||
|
||||
/**
|
||||
* <summary>3D region component</summary>
|
||||
* <remarks>
|
||||
* <para header='Description'>A component that groups 3D sound sources, 3D listeners and transceivers by space.<br/>
|
||||
* Used by attaching to any GameObject.<br/>
|
||||
* This can be used as an value of region3d in CriAtomSource, CriAtomListener and CriAtomTransceiver,<br/>
|
||||
* or can be set as initial region setting.<br/>
|
||||
* Only one of this component can be attached to a GameObject.</para>
|
||||
* </remarks>
|
||||
* <seealso cref='CriAtomSource'/>
|
||||
* <seealso cref='CriAtomListener'/>
|
||||
* <seealso cref='CriAtomTransceiver'/>
|
||||
*/
|
||||
[AddComponentMenu("CRIWARE/CRI Atom Region"), DisallowMultipleComponent]
|
||||
public class CriAtomRegion : CriMonoBehaviour
|
||||
{
|
||||
#region Fields & Properties
|
||||
/**
|
||||
* <summary>The CriAtomEx3dRegion used internally.</summary>
|
||||
* <remarks>
|
||||
* <para header='Description'>If you want to control CriAtomEx3dRegion directly, get CriAtomEx3dRegion from this property.</para>
|
||||
* </remarks>
|
||||
*/
|
||||
public CriAtomEx3dRegion region3dHn { get; protected set; }
|
||||
#endregion
|
||||
|
||||
#region Private Fields & Properties
|
||||
internal List<CriAtomSourceBase> referringSources = new List<CriAtomSourceBase>();
|
||||
internal List<CriAtomListener> referringListeners = new List<CriAtomListener>();
|
||||
internal List<CriAtomTransceiver> referringTransceivers = new List<CriAtomTransceiver>();
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
this.InternalInitialize();
|
||||
}
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
this.InitializeParameters();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
this.InternalFinalize();
|
||||
}
|
||||
|
||||
protected virtual void InternalInitialize()
|
||||
{
|
||||
CriAtomPlugin.InitializeLibrary();
|
||||
this.region3dHn = new CriAtomEx3dRegion();
|
||||
}
|
||||
|
||||
protected virtual void InternalFinalize()
|
||||
{
|
||||
/* Clear references to this region */
|
||||
while (referringSources.Count > 0) {
|
||||
referringSources[0].region3d = null;
|
||||
}
|
||||
referringSources.Clear();
|
||||
while (referringListeners.Count > 0) {
|
||||
referringListeners[0].region3d = null;
|
||||
}
|
||||
referringListeners.Clear();
|
||||
while(referringTransceivers.Count > 0) {
|
||||
referringTransceivers[0].region3d = null;
|
||||
}
|
||||
referringTransceivers.Clear();
|
||||
|
||||
region3dHn.Dispose();
|
||||
region3dHn = null;
|
||||
CriAtomPlugin.FinalizeLibrary();
|
||||
}
|
||||
|
||||
protected virtual void InitializeParameters()
|
||||
{
|
||||
if (this.region3dHn == null) {
|
||||
Debug.LogError("[CRIWARE] Internal: CriAtomEx3dRegion is not created correctly.", this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public override void CriInternalUpdate() { }
|
||||
|
||||
public override void CriInternalLateUpdate() { }
|
||||
|
||||
#endregion
|
||||
} // end of class
|
||||
|
||||
} //namespace CriWare
|
||||
/** @} */
|
||||
/* end of file */
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f90e8bb5f5c39384c915cfdeb1ee0bbb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,197 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2011 CRI Middleware Co., Ltd.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace CriWare {
|
||||
|
||||
public class CriAtomServer : CriMonoBehaviour {
|
||||
|
||||
#region Internal Fields
|
||||
private static CriAtomServer _instance = null;
|
||||
#if UNITY_EDITOR
|
||||
private bool isApplicationPaused = false;
|
||||
private bool isEditorPaused = false;
|
||||
#endif
|
||||
#endregion
|
||||
|
||||
public System.Action<bool> onApplicationPausePreProcess;
|
||||
public System.Action<bool> onApplicationPausePostProcess;
|
||||
static public bool KeepPlayingSoundOnPause = true;
|
||||
static public bool EnableAutoConsumePcmOutput = true;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private bool consumingPcmOutput = false;
|
||||
private float consumeStartTime = 0.0f;
|
||||
private ulong consumedSamples = 0;
|
||||
private int samplingRate;
|
||||
private int channels;
|
||||
private float[][] buffer;
|
||||
#endif
|
||||
|
||||
public static CriAtomServer instance {
|
||||
get {
|
||||
CreateInstance();
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
public static void CreateInstance() {
|
||||
if (_instance == null) {
|
||||
CriWare.Common.managerObject.AddComponent<CriAtomServer>();
|
||||
}
|
||||
}
|
||||
|
||||
public static void DestroyInstance() {
|
||||
if (_instance != null) {
|
||||
UnityEngine.GameObject.Destroy(_instance);
|
||||
}
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
/* インスタンスは常に1つしか生成されないことを保証する */
|
||||
if (_instance == null) {
|
||||
_instance = this;
|
||||
} else {
|
||||
GameObject.Destroy(this);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
#if UNITY_EDITOR
|
||||
#if UNITY_2017_2_OR_NEWER
|
||||
UnityEditor.EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
|
||||
UnityEditor.EditorApplication.pauseStateChanged += OnPauseStateChanged;
|
||||
#else
|
||||
UnityEditor.EditorApplication.playmodeStateChanged += OnPlaymodeStateChange;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
base.OnDisable();
|
||||
#if UNITY_EDITOR
|
||||
#if UNITY_2017_2_OR_NEWER
|
||||
UnityEditor.EditorApplication.playModeStateChanged -= OnPlayModeStateChanged;
|
||||
UnityEditor.EditorApplication.pauseStateChanged -= OnPauseStateChanged;
|
||||
#else
|
||||
UnityEditor.EditorApplication.playmodeStateChanged -= OnPlaymodeStateChange;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (_instance == this) {
|
||||
_instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
public override void CriInternalUpdate()
|
||||
{
|
||||
CriAtomPlugin.ExecuteQueuedCueLinkCallbacks();
|
||||
CriAtomPlugin.ExecuteQueuedEventCallbacks();
|
||||
CriAtomPlugin.ExecuteQueuedBeatSyncCallbacks();
|
||||
|
||||
if (EnableAutoConsumePcmOutput) {
|
||||
ConsumePcmOutput();
|
||||
}
|
||||
}
|
||||
|
||||
public override void CriInternalLateUpdate() { }
|
||||
|
||||
private void ConsumePcmOutput()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (!CriAtomPlugin.IsInitializedForPcmOutput()) {
|
||||
consumingPcmOutput = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (buffer == null) {
|
||||
channels = CriAtomPlugin.GetOutputChannels();
|
||||
samplingRate = CriAtomPlugin.GetOutputSamplingRate();
|
||||
buffer = new float[channels][];
|
||||
for (int i = 0; i < channels; i++) {
|
||||
buffer[i] = new float[samplingRate];
|
||||
}
|
||||
}
|
||||
|
||||
if (!consumingPcmOutput) {
|
||||
consumeStartTime = Time.time;
|
||||
consumedSamples = 0;
|
||||
consumingPcmOutput = true;
|
||||
}
|
||||
|
||||
int numToConsume = (int)(((Time.time - consumeStartTime) * samplingRate) - consumedSamples);
|
||||
consumedSamples += (ulong)CriAtomExAsr.GetPcmOutput(channels, numToConsume, buffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void OnPlaymodeStateChange()
|
||||
{
|
||||
bool paused = UnityEditor.EditorApplication.isPaused;
|
||||
if (!isApplicationPaused && isEditorPaused != paused) {
|
||||
ProcessApplicationPause(paused);
|
||||
isEditorPaused = paused;
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_2017_2_OR_NEWER
|
||||
private void OnPlayModeStateChanged(UnityEditor.PlayModeStateChange state)
|
||||
{
|
||||
OnPlaymodeStateChange();
|
||||
}
|
||||
private void OnPauseStateChanged(UnityEditor.PauseState state)
|
||||
{
|
||||
OnPlaymodeStateChange();
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
void OnApplicationPause(bool appPause)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (!isEditorPaused && isApplicationPaused != appPause) {
|
||||
ProcessApplicationPause(appPause);
|
||||
isApplicationPaused = appPause;
|
||||
}
|
||||
#else
|
||||
ProcessApplicationPause(appPause);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ProcessApplicationPause(bool appPause)
|
||||
{
|
||||
if (onApplicationPausePreProcess != null) {
|
||||
onApplicationPausePreProcess(appPause);
|
||||
}
|
||||
#if !UNITY_EDITOR && UNITY_IOS
|
||||
if(appPause == false) {
|
||||
CriAtomPlugin.CallOnApplicationResume_IOS();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if UNITY_STANDALONE || UNITY_EDITOR
|
||||
if (!KeepPlayingSoundOnPause) {
|
||||
CriAtomPlugin.Pause(appPause);
|
||||
}
|
||||
#else
|
||||
#if !UNITY_IOS
|
||||
CriAtomPlugin.Pause(appPause);
|
||||
#endif
|
||||
#endif
|
||||
if (onApplicationPausePostProcess != null) {
|
||||
onApplicationPausePostProcess(appPause);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace CriWare
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4ef410aed001b60468abcbb30b09687a
|
||||
timeCreated: 1433816076
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,130 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2011 CRI Middleware Co., Ltd.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
/**
|
||||
* \addtogroup CRIATOM_UNITY_COMPONENT
|
||||
* @{
|
||||
*/
|
||||
|
||||
namespace CriWare {
|
||||
|
||||
/**
|
||||
* <summary>A component that plays sound.</summary>
|
||||
* <remarks>
|
||||
* <para header='Description'>Used by attaching to any GameObject.<br/>
|
||||
* If the Cue to be played is set to do 3D Positioning, 3D playback is performed.
|
||||
* In this case, it is necessary to attach CriWare.CriAtomListener to the camera or main character
|
||||
* since the localization is calculated with the position of the GameObject to which CriWare.CriAtomListener is attached.<br/>
|
||||
* Public variables are basically set on UnityEditor.</para>
|
||||
* </remarks>
|
||||
*/
|
||||
[AddComponentMenu("CRIWARE/CRI Atom Source")]
|
||||
public class CriAtomSource : CriAtomSourceBase
|
||||
{
|
||||
#region Variables
|
||||
[SerializeField]
|
||||
private string _cueName = "";
|
||||
[SerializeField]
|
||||
private string _cueSheet = "";
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/**
|
||||
* <summary>Sets/gets the name of the Cue to be played.</summary>
|
||||
* <remarks>
|
||||
* <para header='Description'>When you call the CriAtomSource::Play() function or
|
||||
* when you play sound at the start of execution by setting the CriAtomSource::playOnStart property,
|
||||
* the Cue set by this property is played.</para>
|
||||
* </remarks>
|
||||
*/
|
||||
public string cueName {
|
||||
get {return this._cueName;}
|
||||
set {this._cueName = value;}
|
||||
}
|
||||
|
||||
/**
|
||||
* <summary>Sets/gets the Cue Sheet name.</summary>
|
||||
* <remarks>
|
||||
* <para header='Description'>The Cue specified in the CriAtomSource::Play function or CriAtomSource::CueName property
|
||||
* is searched from the Cue Sheet set in this property.</para>
|
||||
* </remarks>
|
||||
*/
|
||||
public string cueSheet {
|
||||
get {return this._cueSheet;}
|
||||
set {this._cueSheet = value;}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Functions
|
||||
|
||||
/**
|
||||
* <summary>Starts playing the Cue that is set.</summary>
|
||||
* <returns>Playback ID</returns>
|
||||
* <remarks>
|
||||
* <para header='Description'>The Cue to be played must be set in advance to the
|
||||
* CriAtomSource::CueName property.</para>
|
||||
* </remarks>
|
||||
*/
|
||||
public override CriAtomExPlayback Play()
|
||||
{
|
||||
return this.Play(this.cueName);
|
||||
}
|
||||
|
||||
protected override CriAtomExAcb GetAcb()
|
||||
{
|
||||
CriAtomExAcb acb = null;
|
||||
if (!String.IsNullOrEmpty(this.cueSheet)) {
|
||||
acb = CriAtom.GetAcb(this.cueSheet);
|
||||
}
|
||||
return acb;
|
||||
}
|
||||
|
||||
/**
|
||||
* <summary>Starts playing the Cue that is set.</summary>
|
||||
* <remarks>
|
||||
* <para header='Description'>You must set the CriAtomSource::playOnStart, CriAtomSource::CueName
|
||||
* properties in advance.</para>
|
||||
* </remarks>
|
||||
*/
|
||||
protected override void PlayOnStart()
|
||||
{
|
||||
if (this.playOnStart && !String.IsNullOrEmpty(this.cueName)) {
|
||||
StartCoroutine(PlayAsync(this.cueName));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <summary>Asynchronously starts playing the Cue with the specified Cue name.</summary>
|
||||
* <param name='cueName'>Cue name</param>
|
||||
* <returns>Coroutine</returns>
|
||||
* <remarks>
|
||||
* <para header='Description'>It is executed asynchronously by using the coroutine function of Unity.
|
||||
* Call this function by specifying it as an argument of MonoBehaviour::StartCoroutine.</para>
|
||||
* </remarks>
|
||||
*/
|
||||
private IEnumerator PlayAsync(string cueName)
|
||||
{
|
||||
CriAtomExAcb acb = null;
|
||||
while (acb == null && !String.IsNullOrEmpty(this.cueSheet)) {
|
||||
acb = CriAtom.GetAcb(this.cueSheet);
|
||||
if (acb == null) {
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
this.player.SetCue(acb, cueName);
|
||||
InternalPlayCue();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
} //namespace CriWare
|
||||
/** @} */
|
||||
/* end of file */
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1e631c3b9947b54c823c6853a05529c
|
||||
timeCreated: 1433816077
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: c7b655dd5eeac7b489f2ddd1304fb5f4, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user