Skip to content

Commit

Permalink
feat: PrefsGUI.RosetatUI supports "Enum(UnityEngine.Rendering.BlendMo…
Browse files Browse the repository at this point in the history
…de)" property attribute
  • Loading branch information
fuqunaga committed Jan 15, 2024
1 parent a0c088d commit 2b9577b
Show file tree
Hide file tree
Showing 11 changed files with 604 additions and 60 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using PrefsGUI.RosettaUI;
using System.Collections.Generic;
using System.Linq;
using PrefsGUI.RosettaUI;
using RosettaUI;
using UnityEngine;

Expand All @@ -7,7 +9,7 @@ namespace PrefsGUI.Example
[RequireComponent(typeof(RosettaUIRoot))]
public class PrefsMaterialPropertyRosettaUIExample : MonoBehaviour
{
public PrefsMaterialProperty prefsMaterialProperty;
public List<PrefsMaterialProperty> prefsMaterialProperties;
public Vector2 position;

public void Start()
Expand All @@ -16,7 +18,7 @@ public void Start()

rosettaUIRoot.Build(
UI.Window(
prefsMaterialProperty.CreateElement()
prefsMaterialProperties.Select(pm => pm.CreateElement())
).SetPosition(position)
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
Shader "Unlit/PrefsMaterialPropertyUnlit"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
_Alpha("Alpha", Range(0, 1)) = 1
[Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend("Source Blend", Float) = 5
[Enum(UnityEngine.Rendering.BlendMode)] _DstBlend("Destination Blend", Float) = 10
[Enum(Off, 0, On, 1)] _ZWrite("ZWrite", Float) = 0
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100

Pass
{
Blend [_SrcBlend][_DstBlend] // soft additive
ZWrite [_ZWrite]

CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// make fog work
#pragma multi_compile_fog

#include "UnityCG.cginc"

struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};

struct v2f
{
float2 uv : TEXCOORD0;
UNITY_FOG_COORDS(1)
float4 vertex : SV_POSITION;
};

sampler2D _MainTex;
float4 _MainTex_ST;
float _Alpha;

v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
return o;
}

fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv);
col.a *= _Alpha;
return col;
}
ENDCG
}
}
}

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

Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ Material:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: ExampleMaterial
m_Name: StandardMaterial
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords:
- _EMISSION
m_InvalidKeywords: []
Expand All @@ -18,6 +20,7 @@ Material:
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
Expand Down Expand Up @@ -82,6 +85,6 @@ Material:
- _ZWrite: 1
m_Colors:
- <noninit>: {r: 0, g: 1, b: 1, a: 1}
- _Color: {r: 0.375, g: 0.375, b: 0.375, a: 1}
- _Color: {r: 0.45882353, g: 0.45882353, b: 0.45882353, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []
85 changes: 85 additions & 0 deletions Assets/Examples/PrefsMaterialPropertyExample/UnlitMaterial.mat
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: UnlitMaterial
m_Shader: {fileID: 4800000, guid: ccbc9691055a2ce4887639a3cc0e0c21, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 683f78241a0a6244db2fbd66c23c8876, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _Alpha: 1
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _UseTexture: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []

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

Loading

0 comments on commit 2b9577b

Please sign in to comment.