Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions Assets/PreviewTexture.renderTexture
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!84 &8400000
RenderTexture:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: PreviewTexture
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
m_IsAlphaChannelOptional: 0
serializedVersion: 5
m_Width: 1920
m_Height: 1080
m_AntiAliasing: 1
m_MipCount: -1
m_DepthStencilFormat: 94
m_ColorFormat: 8
m_MipMap: 0
m_GenerateMips: 1
m_SRGB: 0
m_UseDynamicScale: 1
m_BindMS: 0
m_EnableCompatibleFormat: 1
m_EnableRandomWrite: 0
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 0
m_MipBias: 0
m_WrapU: 1
m_WrapV: 1
m_WrapW: 1
m_Dimension: 2
m_VolumeDepth: 1
m_ShadowSamplingMode: 2
8 changes: 8 additions & 0 deletions Assets/PreviewTexture.renderTexture.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Assets/Runtime/Prefabs/Plume-Player.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!4 &3527861557537485353
Transform:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1065,6 +1065,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
typeRegistryProvider: {fileID: 27516560266712775}
loop: 0
previewRenderTexture: {fileID: 8400000, guid: 5cf7293dda184f74e920fa26c0430ab1, type: 2}
freeCamera: {fileID: 5243149662805609015}
topViewCamera: {fileID: 5720294478372019317}
mainCamera: {fileID: 4958596500381266705}
Expand Down
7 changes: 5 additions & 2 deletions Assets/Runtime/Scripts/RecordAssetBundle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ public T GetOrDefaultAssetByIdentifier<T>(AssetIdentifier identifier) where T :

var assetType = Type.GetType(assetTypeName) ?? typeof(Object);

Debug.Log($"'{assetType}' '{assetPath}' '{assetName}' '{assetSource}'");

var asset = assetSource switch
{
"Custom" => LoadCustomAsset(assetType, assetPath, assetName),
Expand All @@ -50,6 +48,11 @@ public T GetOrDefaultAssetByIdentifier<T>(AssetIdentifier identifier) where T :
private Object LoadCustomAsset(Type assetType, string assetPath, string assetName)
{
var assets = _assetBundle.LoadAssetWithSubAssets(assetPath, assetType);
if (assets == null || assets.Length == 0)
{
Debug.LogWarning($"Asset '{assetPath}' not found in asset bundle.");
return null;
}
return assets.FirstOrDefault(asset => asset.name == assetName);
}

Expand Down
2 changes: 1 addition & 1 deletion Assets/Runtime/Scripts/Viewer/MainWindowPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private void Start()
_mainWindowUI.PreviewRenderAspectRatio.RegisterCallback<NavigationMoveEvent>(OnPreviewRenderNavigationMove);
_mainWindowUI.PreviewRenderAspectRatio.RegisterCallback<KeyDownEvent>(OnPreviewRenderKeyDown);
_mainWindowUI.PreviewRender.style.backgroundImage =
Background.FromRenderTexture(player.PreviewRenderTexture);
Background.FromRenderTexture(player.previewRenderTexture);

_mainWindowUI.Timeline.RegisterCallback<KeyDownEvent>(OnPlayPauseKeyDown);
_mainWindowUI.PlayPauseButton.RegisterCallback<KeyDownEvent>(OnPlayPauseKeyDown);
Expand Down
16 changes: 7 additions & 9 deletions Assets/Runtime/Scripts/Viewer/Player/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class Player : MonoBehaviour, IDisposable
private bool _isPlaying;
private ulong _currentTimeNanoseconds;

public RenderTexture PreviewRenderTexture { get; private set; }
public RenderTexture previewRenderTexture;

public event Action OnFinishLoading = delegate { };

Expand Down Expand Up @@ -81,11 +81,10 @@ public static void OnInitialize()
transform.parent = null;
DontDestroyOnLoad(gameObject);
}

PreviewRenderTexture = RenderTexture.GetTemporary(1920, 1080);
freeCamera.PreviewRenderTexture = PreviewRenderTexture;
topViewCamera.PreviewRenderTexture = PreviewRenderTexture;
mainCamera.PreviewRenderTexture = PreviewRenderTexture;

freeCamera.PreviewRenderTexture = previewRenderTexture;
topViewCamera.PreviewRenderTexture = previewRenderTexture;
mainCamera.PreviewRenderTexture = previewRenderTexture;
freeCamera.transform.position = new Vector3(-2.24f, 1.84f, 0.58f);
freeCamera.transform.rotation = Quaternion.Euler(25f, -140f, 0f);
topViewCamera.transform.position = new Vector3(0, 3.25f, -4);
Expand Down Expand Up @@ -242,7 +241,7 @@ private static async UniTask<string> GetBundlePath(string recordFilePath = null)
public void SetCurrentPreviewCamera(PreviewCamera camera)
{
var rt = RenderTexture.active;
RenderTexture.active = PreviewRenderTexture;
RenderTexture.active = previewRenderTexture;
GL.Clear(true, true, Color.clear);
RenderTexture.active = rt;

Expand Down Expand Up @@ -273,7 +272,6 @@ private void FixedUpdate()

public void OnDestroy()
{
PreviewRenderTexture.Release();
_recordLoader.Dispose();
}

Expand Down Expand Up @@ -362,7 +360,7 @@ public float GetRecordLoadingProgress()

public float GetRecordAssetBundleLoadingProgress()
{
return _bundleLoader.GetLoadingProgress();
return _bundleLoader?.GetLoadingProgress() ?? 0;
}

public void SetPlaySpeed(float playSpeed)
Expand Down
12 changes: 8 additions & 4 deletions Assets/Scenes/PlayerScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,18 @@ PrefabInstance:
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1041767726375591474, guid: b4a12f1ba345b14438d4ad048811be15, type: 3}
propertyPath: PreviewRenderTexture
value:
objectReference: {fileID: 8400000, guid: 5cf7293dda184f74e920fa26c0430ab1, type: 2}
- target: {fileID: 1622235944094969762, guid: b4a12f1ba345b14438d4ad048811be15, type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3688873362705555609, guid: b4a12f1ba345b14438d4ad048811be15, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3853190476271717280, guid: b4a12f1ba345b14438d4ad048811be15, type: 3}
propertyPath: m_LocalPosition.x
value: 0
Expand Down Expand Up @@ -207,10 +215,6 @@ PrefabInstance:
propertyPath: defaultInteractionType
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6271649878948817840, guid: b4a12f1ba345b14438d4ad048811be15, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7333346258209044708, guid: b4a12f1ba345b14438d4ad048811be15, type: 3}
propertyPath: m_RequiresDepthTextureOption
value: 1
Expand Down
4 changes: 2 additions & 2 deletions Assets/UniversalRenderPipelineGlobalSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ MonoBehaviour:
lightLayerName7:
m_StripDebugVariants: 1
m_StripUnusedPostProcessingVariants: 0
m_StripUnusedVariants: 1
m_StripUnusedVariants: 0
m_StripUnusedLODCrossFadeVariants: 1
m_StripScreenCoordOverrideVariants: 1
m_StripScreenCoordOverrideVariants: 0
supportRuntimeDebugDisplay: 0
m_ShaderVariantLogLevel: 0
m_ExportShaderVariants: 1
2 changes: 1 addition & 1 deletion ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ PlayerSettings:
AndroidTargetSdkVersion: 0
AndroidPreferredInstallLocation: 1
aotOptions:
stripEngineCode: 1
stripEngineCode: 0
iPhoneStrippingLevel: 0
iPhoneScriptCallOptimization: 0
ForceInternetPermission: 0
Expand Down