Refactor VRCBoardImage component and remove unused shader/editor files

This commit is contained in:
2024-10-15 17:34:54 +03:00
parent e25230326b
commit f93aedbc88
6 changed files with 17 additions and 149 deletions

View File

@@ -168,6 +168,7 @@ namespace VRCBoard.Components
Array.Resize(ref script.imageIds, newSize); Array.Resize(ref script.imageIds, newSize);
Array.Resize(ref script.texturePropertyMappings, newSize); Array.Resize(ref script.texturePropertyMappings, newSize);
Array.Resize(ref script.defaultTextures, newSize); Array.Resize(ref script.defaultTextures, newSize);
EditorUtility.SetDirty(script);
} }
MaterialPropertyBlock propertyBlock = new MaterialPropertyBlock(); MaterialPropertyBlock propertyBlock = new MaterialPropertyBlock();
for (int i = 0; i < script.imageIds.Length; i++) for (int i = 0; i < script.imageIds.Length; i++)
@@ -194,12 +195,25 @@ namespace VRCBoard.Components
defaultImage = EditorGUILayout.ObjectField(defaultImage, typeof(Texture2D), false) as Texture2D; defaultImage = EditorGUILayout.ObjectField(defaultImage, typeof(Texture2D), false) as Texture2D;
EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal();
if (defaultImage != null) propertyBlock.SetTexture(propertyName, defaultImage); if (defaultImage != null) propertyBlock.SetTexture(propertyName, defaultImage);
}
if (script.defaultTextures[i] != defaultImage)
{
script.defaultTextures[i] = defaultImage; script.defaultTextures[i] = defaultImage;
EditorUtility.SetDirty(script);
} }
script.imageIds[i] = imageId; if (script.imageIds[i] != imageId)
if (selectedIndex >= 0 && selectedIndex < materialPropertyNames.Length) script.texturePropertyMappings[i] = materialPropertyNames[selectedIndex]; {
script.imageIds[i] = imageId;
EditorUtility.SetDirty(script);
}
if (selectedIndex >= 0 && selectedIndex < materialPropertyNames.Length && script.texturePropertyMappings[i] != materialPropertyNames[selectedIndex])
{
script.texturePropertyMappings[i] = materialPropertyNames[selectedIndex];
EditorUtility.SetDirty(script);
}
GUILayout.EndVertical(); GUILayout.EndVertical();
} }

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: beb1ece4e81f7d54481022aa41ad1214
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,20 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UdonSharp;
using UnityEngine;
using UnityEditor;
namespace VRCBoard
{
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
public class VRCBoardShaderEditor : ShaderGUI
{
// Start is called before the first frame update
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
{
EditorGUILayout.LabelField("Please use the VRCBoardImage component to edit the material properties.");
//base.OnGUI(materialEditor, properties);
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 54050364012eda64b93ac4539faa4a15
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,98 +0,0 @@
Shader "VRCBoard/VRCBoardAtlasShader"
{
Properties
{
// _MainTex
_MainTexAtlas("Albedo", 2D) = "white" {}
[HideInInspector] _MainTexAtlasSize("Atlas Size", int) = 1
[HideInInspector] _MainTexAtlasIndex("Atlas Position", int) = 0
[HideInInspector] _MainTexColor("Color", Color) = (1,1,1,1)
// _EmissionMap
_EmissionMapAtlas("Emission", 2D) = "black" {}
[HideInInspector] _EmissionMapAtlasSize("Emission Atlas Size", int) = 1
[HideInInspector] _EmissionMapAtlasIndex("Emission Atlas Position", int) = 0
[HideInInspector] _EmissionColor("Emission Color", Color) = (1,1,1,1)
// _NormalMap
_NormalMapAtlas("Normal", 2D) = "bump" {}
[HideInInspector] _NormalMapAtlasSize("Normal Atlas Size", int) = 1
[HideInInspector] _NormalMapAtlasIndex("Normal Atlas Position", int) = 0
[HideInInspector] _NormalMapScale("Normal Scale", float) = 1
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Standard fullforwardshadows
#pragma target 3.0
sampler2D _MainTexAtlas;
sampler2D _EmissionMapAtlas;
sampler2D _NormalMapAtlas;
uint _MainTexAtlasSize;
uint _MainTexAtlasIndex;
float4 _MainTexColor;
uint _EmissionMapAtlasSize;
uint _EmissionMapAtlasIndex;
float4 _EmissionColor;
uint _NormalMapAtlasSize;
uint _NormalMapAtlasIndex;
float _NormalMapScale;
struct Input
{
float2 uv_MainTexAtlas;
float2 uv_EmissionMapAtlas;
float2 uv_NormalMapAtlas;
};
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
// #pragma instancing_options assumeuniformscaling
UNITY_INSTANCING_BUFFER_START(Props)
UNITY_INSTANCING_BUFFER_END(Props)
void surf (Input IN, inout SurfaceOutputStandard o)
{
_MainTexAtlasIndex = _MainTexAtlasIndex+_MainTexAtlasSize;
_EmissionMapAtlasIndex = _EmissionMapAtlasIndex+_EmissionMapAtlasSize;
_NormalMapAtlasIndex = _NormalMapAtlasIndex+_NormalMapAtlasSize;
float2 MainTexAtlasUV = float2(
(float(_MainTexAtlasIndex % _MainTexAtlasSize) + IN.uv_MainTexAtlas.x) / _MainTexAtlasSize,
1.0 - (float(_MainTexAtlasIndex / _MainTexAtlasSize) - IN.uv_MainTexAtlas.y) / _MainTexAtlasSize
);
float2 EmissionMapAtlasUV = float2(
(float(_EmissionMapAtlasIndex % _EmissionMapAtlasSize) + IN.uv_EmissionMapAtlas.x) / _EmissionMapAtlasSize,
1.0 - (float(_EmissionMapAtlasIndex / _EmissionMapAtlasSize) - IN.uv_EmissionMapAtlas.y) / _EmissionMapAtlasSize
);
float2 NormalMapAtlasUV = float2(
(float(_NormalMapAtlasIndex % _NormalMapAtlasSize) + IN.uv_NormalMapAtlas.x) / _NormalMapAtlasSize,
1.0 - (float(_NormalMapAtlasIndex / _NormalMapAtlasSize) - IN.uv_NormalMapAtlas.y) / _NormalMapAtlasSize
);
fixed4 c = tex2D (_MainTexAtlas, MainTexAtlasUV);
fixed4 e = tex2D (_EmissionMapAtlas, EmissionMapAtlasUV);
fixed4 n = tex2D (_NormalMapAtlas, NormalMapAtlasUV);
o.Albedo = c.rgb * _MainTexColor.rgb;
o.Emission = e.rgb * _EmissionColor.rgb;
o.Normal = UnpackNormal(n);
}
ENDCG
}
FallBack "Diffuse"
CustomEditor "VRCBoard.VRCBoardShaderEditor"
}

View File

@@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 8391ead9ad6feee41a7c2f7f6ccd5f81
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant: