Skip to content

Commit

Permalink
Add auto-switch option for Volume access type
Browse files Browse the repository at this point in the history
- Add `autoSwitchVolumeAccessType` toggle to control access type behavior
- When enabled: automatically switches between Profile/SharedProfile based on play mode
- When disabled: allows manual selection of access type
  • Loading branch information
ShiinaRinne committed Nov 12, 2024
1 parent 5ae7734 commit ceed340
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 38 deletions.
33 changes: 33 additions & 0 deletions Editor/MAOTimelineExtensionVolumeSettingsEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using UnityEditor;
using UnityEngine;


namespace MAOTimelineExtension.Editor
{
[CustomEditor(typeof(MAOTimelineExtensionVolumeSettings))]
public class MAOTimelineExtensionVolumeSettingsEditor : UnityEditor.Editor
{
SerializedProperty autoSwitchVolumeAccessType;
SerializedProperty manualVolumeAccessType;

private void OnEnable()
{
autoSwitchVolumeAccessType = serializedObject.FindProperty("autoSwitchVolumeAccessType");
manualVolumeAccessType = serializedObject.FindProperty("manualVolumeAccessType");
}

public override void OnInspectorGUI()
{
serializedObject.Update();

EditorGUILayout.PropertyField(autoSwitchVolumeAccessType, new GUIContent("Auto Switch Access Type"));

using (new EditorGUI.DisabledGroupScope(autoSwitchVolumeAccessType.boolValue))
{
EditorGUILayout.PropertyField(manualVolumeAccessType, new GUIContent("Volume Access Type"));
}

serializedObject.ApplyModifiedProperties();
}
}
}
19 changes: 2 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ English | [中文](README_CN.md)
## Introduction

Some extensions for Unity Timeline.
You can edit `Volume` or `GameObject`'s properties in the Timeline more easily **without writing code**,<br>
You can edit `Volume` or `GameObject Component`'s properties in the Timeline more easily **without writing code**,<br>
or help you quickly develop prototypes.

[//]: # (This project was originally developed mainly to expand the post-processing volume,
and will gradually improve other types in the future.)

At present, there are some extensions to the original post-processing volume of Unity URP, which are used to dynamically adjust the volume in the timeline<br>
At present, there are some extensions to the original Post-Processing Volume of Unity URP, which are used to dynamically adjust the volume in the Timeline<br>
It can be directly imported into the project for use, or quickly expand through the "**MAO Timeline playable Wizard**" tool.

![](https://r2.youngmoe.com/ym-r2-bucket/2023/11/fb552984c57c7f0d554303d97d4387c6.gif)
Expand Down Expand Up @@ -39,22 +39,9 @@ It can be directly imported into the project for use, or quickly expand through



[//]: # (Currently supported:)

[//]: # (- Bloom)

## Usage

[//]: # (### Download/Installation)

[//]: # ()
[//]: # (Get it from one of the following sources:)

[//]: # ()
[//]: # (- Download the latest release from the [releases page]&#40;&#41;.)

[//]: # (- Clone the repository: `git clone https://xx.git`.)

### Typical usecase

1. Open the Timeline window and create a new Timeline.
Expand Down Expand Up @@ -111,8 +98,6 @@ The namespace affects how the Track appears in the context menu when adding a Tr

## TODO
- [x] Add attributes like `[Range()]`, `[Min()]`, `[Max()]` to the properties of the Clip.
- [x] Optimize attribute adding method in "MAO Timeline Playable Wizard".
- [ ] Add support for more parameters.
- [ ] Support high-level settings such as `Blend Curves`, `Easing-in and Easing-out`.

Expand Down
35 changes: 18 additions & 17 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

## Introduction

这个库包含一些对Unity Timeline的扩展。<br>
可以在不编写代码的情况下更轻松的通过Timeline编辑Volume或Object属性,或者快速开发原型
这个库包含一些对 Unity Timeline 的扩展。<br>
可以在不编写代码的情况下更轻松的通过 Timeline 编辑 Volume 或 GameObject Component 属性,或者快速开发原型以便自定义更多逻辑

目前这个repo里有一些Unity URP原有的后处理Volume的扩展,用来在Timeline中动态调节Volume<br>
目前这个 repo 里有一些 Unity URP 原有的后处理 Volume 的扩展,用来在 Timeline 中动态调节 Volume<br>
可以直接导入项目使用, 也可以通过”**MAO Timeline Playable Wizard**”这个工具自行扩展。

![](https://r2.youngmoe.com/ym-r2-bucket/2023/11/fb552984c57c7f0d554303d97d4387c6.gif)

## Features

### 目前在Volume模式中支持的、可用的参数:
### 目前在 Volume 模式中支持的、可用的参数:

- `FloatParameter`
- `IntParameter`
Expand All @@ -38,11 +38,11 @@

### Typical usecase

1. 打开Timeline窗口,创建一个新的Timeline
2. 在Scene中创建一个Volume,添加 `TimelineExtensionVolumeSettings` 组件
3. 在Timeline中添加一个新的Track。如果是直接使用的这个repo,它的名字应该以`MAO`开头,例如`MAOBloom`
1. 打开 Timeline 窗口,创建一个新的 Timeline
2. 在 Scene 中创建一个 Volume,添加 `TimelineExtensionVolumeSettings` 组件
3. 在 Timeline 中添加一个新的 Track。如果是直接使用的这个 repo,它的名字应该以`MAO`开头,例如`MAOBloom`
4. 将创建的 `TimelineExtensionVolumeSettings` 组件绑定到这个Track上
5. 在Track中添加新的Clip,编辑属性,或者与其他的Clip进行混合即可
5. 在 Track 中添加新的 Clip,编辑属性,或者与其他的 Clip 进行混合即可

#### `TimelineExtensionVolumeSettings` 组件设置:
- `VolumeAccessType`:
Expand All @@ -55,8 +55,8 @@

### Wizard Usage

这是一个可以快速生成Timeline扩展的工具<br>
它可以直接获取当前AppDomain下的所有类,并通过C#反射来获取需要的字段,这样就不再需要自己写扩展了~
这是一个可以快速生成 Timeline 扩展代码的工具<br>
它可以直接获取当前 AppDomain 下的所有类,并通过 C# 反射来获取需要的字段,这样就不再需要自己写扩展了~


**Volume Component:**
Expand All @@ -66,18 +66,18 @@

<img src="https://r2.youngmoe.com/ym-r2-bucket/2023/11/19e8b6032028290d224b7fadef049284.png" width="50%">

3. 将Default Values设置为Volume
3. `Default Values` 设置为 `Volume`

<img src="https://r2.youngmoe.com/ym-r2-bucket/2023/11/7a228f2972434178c205c8aaf67a6b0b.png" width="50%">

4. 添加属性

<img src="https://r2.youngmoe.com/ym-r2-bucket/2023/11/14b3980e06f8d6cb0b87f9e74eb025e4.png" width="50%">

5. 最后点 `Create`就可以了,等编译完之后就可以使用,你可以在 `Assets/TimelineExtensions`找到生成的脚本
5. 最后点 `Create` 就可以了,等编译完之后就可以使用,你可以在 `Assets/TimelineExtensions` 找到生成的脚本

> [!IMPORTANT]
> 目前不支持Enum类型(例如景深的 Gaussian 或 Bokeh 模式),如果确实需要的话,可以参考以下方法分成多个Track制作:<br>
> 目前不支持 Enum 类型(例如景深的 Gaussian 或 Bokeh 模式),如果确实需要的话,可以参考以下方法分成多个 Track 制作:<br>
> <img src="https://r2.youngmoe.com/ym-r2-bucket/2023/11/48d3bda1b26b762ac0477f2b94fc2a75.png" width="50%">
> <img src="https://r2.youngmoe.com/ym-r2-bucket/2023/11/8d325d458c0209b9068427474dce6377.png" width="50%">
Expand All @@ -88,10 +88,8 @@
> <img src="https://r2.youngmoe.com/ym-r2-bucket/2024/11/namespace.png" width="50%">
## TODO
- [x] 在生成时,自动获取`[Range()]`,`[Min()]`,`[Max()]`这些属性
- [x] 优化添加属性时候的操作
- [ ] 添加对更多类型参数的支持
- [ ] 支持一些高级设置,例如`Blend Curves`,`Easing-in and Easing-out`.
- [ ] 支持一些高级设置,例如`Blend Curves`, `Easing-in and Easing-out`.

## License

Expand All @@ -106,4 +104,7 @@
[//]: # (我不是在给爱莉生日做视频吗!为什么最后做了这个东西出来!我的爱莉呢!!!)

[//]: # (## 彩蛋2)
[//]: # (一年过去了,爱莉还是没有来到我身边QAQ)
[//]: # (一年过去了,爱莉还是没有来到我身边QAQ)

[//]: # (## 彩蛋2)
[//]: # (两年了)
8 changes: 8 additions & 0 deletions Resources/MAOTimelineExtensionsConfigSO.asset.meta

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

25 changes: 21 additions & 4 deletions Scripts/MAOTimelineExtensionVolumeSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ namespace MAOTimelineExtension
public class MAOTimelineExtensionVolumeSettings : MonoBehaviour
{
// https://docs.unity3d.com/Packages/[email protected]/manual/Volumes-API.html#access-a-shared-volume-profile
[Tooltip(""+
@"- Access a shared Volume Profile
[Tooltip("" +
@"- Access a shared Volume Profile
One method is to access the Volume's shared Profile. You do this via the Volume's sharedProfile property. This gives you a reference to the instance of the Volume Profile asset.
If you modify this Volume Profile:
- HDRP applies any changes you make to every Volume that uses this Volume Profile asset.
Expand All @@ -26,7 +26,22 @@ The other method is to clone the Volume Profile asset. The advantage of this is
- The modification you make reset when you exit Play mode.
- It is your responsibility to destroy the duplicate Volume Profile when you no longer need it.
Note that you can use this property to assign a different Volume Profile to the Volume.")]
public VolumeAccessType volumeAccessType = VolumeAccessType.Profile;

[SerializeField] private VolumeAccessType manualVolumeAccessType = VolumeAccessType.Profile;

private VolumeAccessType volumeAccessType
{
get
{
if (!autoSwitchVolumeAccessType)
return manualVolumeAccessType;

return Application.isPlaying ? VolumeAccessType.Profile : VolumeAccessType.SharedProfile;
}
}


[SerializeField] private bool autoSwitchVolumeAccessType = true;

private Volume _volume;
private Volume VolumeComponent
Expand All @@ -48,7 +63,9 @@ public VolumeProfile VolumeProfile
{
if (_volumeProfile == null)
{
_volumeProfile = volumeAccessType == VolumeAccessType.Profile? VolumeComponent.profile : VolumeComponent.sharedProfile;
_volumeProfile = volumeAccessType == VolumeAccessType.Profile
? VolumeComponent.profile
: VolumeComponent.sharedProfile;
}
return _volumeProfile;
}
Expand Down
11 changes: 11 additions & 0 deletions Scripts/MAOTimelineExtensionsConfigSO.cs.meta

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

0 comments on commit ceed340

Please sign in to comment.