Skip to content

Commit

Permalink
demo: add demos
Browse files Browse the repository at this point in the history
  • Loading branch information
mob-sakai committed Jan 26, 2025
1 parent 372519d commit c5dfc3b
Show file tree
Hide file tree
Showing 47 changed files with 22,149 additions and 1,844 deletions.
8 changes: 8 additions & 0 deletions Assets/Demos/ControlByScript.meta

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

74 changes: 74 additions & 0 deletions Assets/Demos/ControlByScript/ControlByScript.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System;
using System.Linq;
using UnityEngine;
using Coffee.UIEffects;
using UnityEngine.Events;
using UnityEngine.UI;

public class ControlByScript : MonoBehaviour
{
[SerializeField]
private UIEffect m_Effect;

[SerializeField]
private ControlTemplate m_ControlTemplate;

private void Start()
{
m_ControlTemplate.Instantiate()
.InitAsDropDown(nameof(m_Effect.toneFilter), typeof(ToneFilter),
(int)m_Effect.toneFilter, x => m_Effect.toneFilter = (ToneFilter)x);

m_ControlTemplate.Instantiate()
.InitAsSlider(nameof(m_Effect.toneIntensity), m_Effect.toneIntensity, x => m_Effect.toneIntensity = x);

m_ControlTemplate.Instantiate()
.InitAsDropDown(nameof(m_Effect.colorFilter), typeof(ColorFilter),
(int)m_Effect.colorFilter, x => m_Effect.colorFilter = (ColorFilter)x);

m_ControlTemplate.Instantiate()
.InitAsSlider(nameof(m_Effect.colorIntensity), m_Effect.colorIntensity, x => m_Effect.colorIntensity = x);

m_ControlTemplate.Instantiate()
.InitAsColorDropDown(nameof(m_Effect.color), m_Effect.color, x => m_Effect.color = x);

m_ControlTemplate.Instantiate()
.InitAsSlider("Hue", m_Effect.color.r, x =>
{
var color = m_Effect.color;
color.r = x;
m_Effect.color = color;
});

m_ControlTemplate.Instantiate()
.InitAsToggle(nameof(m_Effect.colorGlow), m_Effect.colorGlow, x => m_Effect.colorGlow = x);
}


private void AddColor(ColorFilter filter, Action<ColorFilter> filterSetter,
float intensity, Action<float> intensitySetter,
Color color, Action<Color> colorSetter,
bool glow, Action<bool> glowSetter)
{
m_ControlTemplate.Instantiate()
.InitAsDropDown(nameof(m_Effect.colorFilter), typeof(ColorFilter),
(int)m_Effect.colorFilter, x => m_Effect.colorFilter = (ColorFilter)x);

m_ControlTemplate.Instantiate()
.InitAsSlider(nameof(m_Effect.colorIntensity), m_Effect.colorIntensity, x => m_Effect.colorIntensity = x);

m_ControlTemplate.Instantiate()
.InitAsColorDropDown(nameof(m_Effect.color), m_Effect.color, x => m_Effect.color = x);

m_ControlTemplate.Instantiate()
.InitAsSlider("Hue", m_Effect.color.r, x =>
{
var color = m_Effect.color;
color.r = x;
m_Effect.color = color;
});

m_ControlTemplate.Instantiate()
.InitAsToggle(nameof(m_Effect.colorGlow), m_Effect.colorGlow, x => m_Effect.colorGlow = x);
}
}
11 changes: 11 additions & 0 deletions Assets/Demos/ControlByScript/ControlByScript.cs.meta

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

Loading

0 comments on commit c5dfc3b

Please sign in to comment.