squash commits

This commit is contained in:
2025-01-07 18:54:46 +02:00
parent 855639487b
commit 62c0a21987
3632 changed files with 708443 additions and 999 deletions
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 Jason Booth
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 580cfc624734b96409a41117dde7daae
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 35611
packageName: UMA 2
packageVersion: 2.13
assetPath: Assets/UMA/Content/ShaderPackages/ShaderPackager-main/LICENSE
uploadId: 679826
@@ -0,0 +1,19 @@
# ShaderPackager
Shader Packager is system for combining multiple shaders, written for specific render pipelines or unity versions, and making them act as a single shader in the project. The goal is to help fix on of the #SRPLife problems, which is that users install your shaders and see nothing but pink shaders, because the versions that shipped with your asset are for the wrong pipeline. The usual workaround for this is to provide various zip files and have the user unpack the right versions for the SRP and Unity version they are using- however, this is a horrible experience for new users.
So what this system does is take a list of shaders, with requirements about SRP type and Unity version, and pack them all into a single file. At import time, it detects which SRP is installed, and imports the correct shader from the package into the project. To the user, it looks like any other shader, but just works on the first install regardless of which SRP they are installed into (Assuming you have provided support for that version).
# Using in your asset store asset
To use this in an Asset Store context, you will need to do the following:
- Copy the files into your project somewhere
- Change the namespace on the files to your own namespace, so they do not conflict with someone else using the same system
- In ShaderPackagerImporter, change the k_FileExtension to something unique to your project.
- Note that you don't need to ship the ShaderPackagerImportEditor.cs file to your users, it is only required for the packing UI.
# ShaderPackager
To pack your shaders, generate your shaders in whatever program you'd like. My asset, Better Shaders, will let you write a single shader that compiles for any SRP, and can export shaders for each pipeline for you - or you can hand write them, or use something like ASE to generate them. Then create a new Shader Package in the project from the right click menu.
Add some entries, and set the SRP Target, Min and Max Unity versions for each, and set the shader. When you are done, press the Pack button, it will copy the source code for each shader into the text block of each entry. Then press Apply, and you will notice that your object now becomes a shader for the current project.
# Current Issues
The render pipeline detection is based on installed pipeline, not installed and active pipeline. So if a user switches has multiple SRPs installed, or one installed and not active, they will get the wrong shader. I'll have to fix this at some point soon.
@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 7b5c0e1a8d9e26c4f8d6692206b672f7
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 35611
packageName: UMA 2
packageVersion: 2.13
assetPath: Assets/UMA/Content/ShaderPackages/ShaderPackager-main/README.md
uploadId: 679826
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fdfb8502cbf70c44f8207e428b91bac9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c2a4c26696c3f7f42a896bf204a4b04e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,74 @@
#define __BETTERSHADERS__
//////////////////////////////////////////////////////
// Shader Packager
// Copyright (c)2021 Jason Booth
//////////////////////////////////////////////////////
using System;
using System.Linq;
using System.Reflection;
using System.Collections.Generic;
using UnityEditor;
#if UNITY_2019_3_OR_NEWER
// installs defines for render pipelines, so we can #if USING_HDRP and do stuff. Can't believe Unity doesn't provide this crap, they
// really go out of their way to make it hard to work across pipelines.
namespace UMA.ShaderPackager
{
public static class RenderPipelineDefine
{
private const string HDRP_PACKAGE = "HDRenderPipelineAsset";
private const string URP_PACKAGE = "UniversalRenderPipelineAsset";
public static bool IsHDRP { get; private set; }
public static bool IsURP { get; private set; }
public static bool IsStandardRP { get; private set; }
[UnityEditor.Callbacks.DidReloadScripts]
private static void OnScriptsReloaded()
{
IsHDRP = DoesTypeExist(HDRP_PACKAGE);
IsURP = DoesTypeExist(URP_PACKAGE);
if (!(IsHDRP || IsURP))
{
IsStandardRP = true;
}
}
public static bool DoesTypeExist(string className)
{
var foundType = (from assembly in AppDomain.CurrentDomain.GetAssemblies()
from type in GetTypesSafe(assembly)
where type.Name == className
select type).FirstOrDefault();
return foundType != null;
}
public static IEnumerable<Type> GetTypesSafe(System.Reflection.Assembly assembly)
{
Type[] types;
try
{
types = assembly.GetTypes();
}
catch (ReflectionTypeLoadException e)
{
types = e.Types;
}
return types.Where(x => x != null);
}
}
}
#endif
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 4510e9e9a4679ae40b1f2e153e1e1366
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 35611
packageName: UMA 2
packageVersion: 2.13
assetPath: Assets/UMA/Content/ShaderPackages/ShaderPackager-main/Scripts/Editor/RenderPipelineDefine.cs
uploadId: 679826
@@ -0,0 +1,247 @@
//////////////////////////////////////////////////////
// Shader Packager
// Copyright (c)2021 Jason Booth
//////////////////////////////////////////////////////
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace UMA.ShaderPackager
{
public class ShaderPackage : ScriptableObject
{
static List<string> GetFlags()
{
string s = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
string[] split = s.Split(';');
return new List<string>(split);
}
static void SetFlags(List<string> flags)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
for (int i = 0; i < flags.Count; ++i)
{
sb.Append(flags[i]);
sb.Append(";");
}
PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, sb.ToString());
}
public enum SRPTarget
{
Standard,
URP,
HDRP
}
public enum UnityVersion
{
Min = 0,
Unity2021_2 = 20212,
Unity2021_3 = 20213,
Unity2022_1 = 20221,
Unity2022_2 = 20222,
Unity2022_3 = 20223,
Unity2023_2 = 20232,
Unity2023_3 = 20233,
Max = 30000
}
[System.Serializable]
public class Entry
{
public SRPTarget srpTarget = SRPTarget.Standard;
public UnityVersion UnityVersionMin = UnityVersion.Min;
public UnityVersion UnityVersionMax = UnityVersion.Max;
public Shader shader;
[HideInInspector] public string shaderSrc;
}
public List<Entry> entries = new List<Entry>();
#if __BETTERSHADERS__
public Shader betterShader;
public string betterShaderPath;
public JBooth.BetterShaders.OptionOverrides optionOverrides;
#endif
public void Pack(bool warnErrors)
{
#if __BETTERSHADERS__
if (betterShader != null)
{
betterShaderPath = AssetDatabase.GetAssetPath(betterShader);
}
if (betterShader == null)
{
if (!System.IO.File.Exists(betterShaderPath))
{
Debug.LogWarning("Shader Packager: Source shader GUID and path have changed, you will need to manually repack the shaders from source");
return;
}
}
if (!string.IsNullOrEmpty(betterShaderPath))
{
var assetPath = betterShaderPath;
if (assetPath.EndsWith(".surfshader"))
{
entries.Clear();
ShaderPackage.Entry e = new ShaderPackage.Entry();
entries.Add(e);
e.shaderSrc = JBooth.BetterShaders.BetterShaderImporterEditor.BuildExportShader(JBooth.BetterShaders.ShaderBuilder.RenderPipeline.Standard, optionOverrides, assetPath);
e.srpTarget = ShaderPackage.SRPTarget.Standard;
e.UnityVersionMin = ShaderPackage.UnityVersion.Unity2021_2;
e.UnityVersionMax = ShaderPackage.UnityVersion.Max;
e = new ShaderPackage.Entry();
entries.Add(e);
e.shaderSrc = JBooth.BetterShaders.BetterShaderImporterEditor.BuildExportShader(JBooth.BetterShaders.ShaderBuilder.RenderPipeline.HDRP2021, optionOverrides, assetPath);
e.srpTarget = ShaderPackage.SRPTarget.HDRP;
e.UnityVersionMin = ShaderPackage.UnityVersion.Unity2021_2;
e.UnityVersionMax = ShaderPackage.UnityVersion.Unity2022_1;
e = new ShaderPackage.Entry();
entries.Add(e);
e.shaderSrc = JBooth.BetterShaders.BetterShaderImporterEditor.BuildExportShader(JBooth.BetterShaders.ShaderBuilder.RenderPipeline.URP2021, optionOverrides, assetPath);
e.srpTarget = ShaderPackage.SRPTarget.URP;
e.UnityVersionMin = ShaderPackage.UnityVersion.Unity2021_2;
e.UnityVersionMax = ShaderPackage.UnityVersion.Unity2022_1;
e = new ShaderPackage.Entry();
entries.Add(e);
e.shaderSrc = JBooth.BetterShaders.BetterShaderImporterEditor.BuildExportShader(JBooth.BetterShaders.ShaderBuilder.RenderPipeline.HDRP2022, optionOverrides, assetPath);
e.srpTarget = ShaderPackage.SRPTarget.HDRP;
e.UnityVersionMin = ShaderPackage.UnityVersion.Unity2022_2;
e.UnityVersionMax = ShaderPackage.UnityVersion.Max;
e = new ShaderPackage.Entry();
entries.Add(e);
e.shaderSrc = JBooth.BetterShaders.BetterShaderImporterEditor.BuildExportShader(JBooth.BetterShaders.ShaderBuilder.RenderPipeline.URP2022, optionOverrides, assetPath);
e.srpTarget = ShaderPackage.SRPTarget.URP;
e.UnityVersionMin = ShaderPackage.UnityVersion.Unity2022_2;
e.UnityVersionMax = ShaderPackage.UnityVersion.Max;
}
else if (assetPath.EndsWith(".stackedshader"))
{
entries.Clear();
ShaderPackage.Entry e = new ShaderPackage.Entry();
entries.Add(e);
e.shaderSrc = JBooth.BetterShaders.StackedShaderImporterEditor.BuildExportShader(JBooth.BetterShaders.ShaderBuilder.RenderPipeline.Standard, optionOverrides, assetPath);
e.srpTarget = ShaderPackage.SRPTarget.Standard;
e.UnityVersionMin = ShaderPackage.UnityVersion.Unity2021_2;
e.UnityVersionMax = ShaderPackage.UnityVersion.Max;
e = new ShaderPackage.Entry();
entries.Add(e);
e.shaderSrc = JBooth.BetterShaders.StackedShaderImporterEditor.BuildExportShader(JBooth.BetterShaders.ShaderBuilder.RenderPipeline.URP2021, optionOverrides, assetPath);
e.srpTarget = ShaderPackage.SRPTarget.URP;
e.UnityVersionMin = ShaderPackage.UnityVersion.Unity2021_2;
e.UnityVersionMax = ShaderPackage.UnityVersion.Unity2022_1;
e = new ShaderPackage.Entry();
entries.Add(e);
e.shaderSrc = JBooth.BetterShaders.StackedShaderImporterEditor.BuildExportShader(JBooth.BetterShaders.ShaderBuilder.RenderPipeline.HDRP2021, optionOverrides, assetPath);
e.srpTarget = ShaderPackage.SRPTarget.HDRP;
e.UnityVersionMin = ShaderPackage.UnityVersion.Unity2022_1;
e.UnityVersionMax = ShaderPackage.UnityVersion.Max;
e = new ShaderPackage.Entry();
entries.Add(e);
e.shaderSrc = JBooth.BetterShaders.StackedShaderImporterEditor.BuildExportShader(JBooth.BetterShaders.ShaderBuilder.RenderPipeline.URP2022, optionOverrides, assetPath);
e.srpTarget = ShaderPackage.SRPTarget.URP;
e.UnityVersionMin = ShaderPackage.UnityVersion.Unity2022_2;
e.UnityVersionMax = ShaderPackage.UnityVersion.Max;
e = new ShaderPackage.Entry();
entries.Add(e);
e.shaderSrc = JBooth.BetterShaders.StackedShaderImporterEditor.BuildExportShader(JBooth.BetterShaders.ShaderBuilder.RenderPipeline.HDRP2022, optionOverrides, assetPath);
e.srpTarget = ShaderPackage.SRPTarget.HDRP;
e.UnityVersionMin = ShaderPackage.UnityVersion.Unity2022_2;
e.UnityVersionMax = ShaderPackage.UnityVersion.Max;
}
}
#endif
foreach (var e in entries)
{
if (e.shader
#if __BETTERSHADERS__
&& betterShader == null
#endif
)
{
if (warnErrors)
{
Debug.LogError("Shader is null, cannot pack");
}
break;
}
if (e.UnityVersionMax == ShaderPackage.UnityVersion.Min && e.UnityVersionMin == ShaderPackage.UnityVersion.Min)
{
e.UnityVersionMax = ShaderPackage.UnityVersion.Max;
}
if (e.shader != null)
{
var path = AssetDatabase.GetAssetPath(e.shader);
e.shaderSrc = System.IO.File.ReadAllText(path);
}
}
}
public string GetShaderSrc()
{
UnityVersion curVersion = UnityVersion.Min;
#if UNITY_2021_2_OR_NEWER
curVersion = UnityVersion.Unity2021_2;
#endif
#if UNITY_2021_3_OR_NEWER
curVersion = UnityVersion.Unity2021_3;
#endif
#if UNITY_2022_1_OR_NEWER
curVersion = UnityVersion.Unity2022_1;
#endif
#if UNITY_2022_2_OR_NEWER
curVersion = UnityVersion.Unity2022_2;
#endif
#if UNITY_2022_3_OR_NEWER
curVersion = UnityVersion.Unity2022_3;
#endif
SRPTarget target = SRPTarget.Standard;
if (RenderPipelineDefine.IsHDRP)
{
target = SRPTarget.HDRP;
}
else if (RenderPipelineDefine.IsURP)
{
target = SRPTarget.URP;
}
string s = null;
foreach (var e in entries)
{
if (target != e.srpTarget)
continue;
// default init state..
if (e.UnityVersionMax == UnityVersion.Min && e.UnityVersionMin == UnityVersion.Min)
{
e.UnityVersionMax = UnityVersion.Max;
}
if (curVersion >= e.UnityVersionMin && curVersion <= e.UnityVersionMax)
{
if (s != null)
{
Debug.LogWarning("Found multiple possible entries for unity version of shader");
}
s = e.shaderSrc;
}
}
return s;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: a7569f89f8035c245b03586ca61a45a9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 35611
packageName: UMA 2
packageVersion: 2.13
assetPath: Assets/UMA/Content/ShaderPackages/ShaderPackager-main/Scripts/Editor/ShaderPackage.cs
uploadId: 679826
@@ -0,0 +1,81 @@
//////////////////////////////////////////////////////
// Shader Packager
// Copyright (c)2021 Jason Booth
//////////////////////////////////////////////////////
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
#if UNITY_2020_2_OR_NEWER
using UnityEditor.AssetImporters;
#else
using UnityEditor.Experimental.AssetImporters;
#endif
using System.IO;
namespace UMA.ShaderPackager
{
[ScriptedImporter(0, ShaderPackageImporter.k_FileExtension)]
public class ShaderPackageImporter : ScriptedImporter
{
public const string k_FileExtension = ".umaShaderPack";
public override void OnImportAsset(AssetImportContext ctx)
{
string fileContent = File.ReadAllText(ctx.assetPath);
var package = ObjectFactory.CreateInstance<ShaderPackage>();
if (!string.IsNullOrEmpty(fileContent))
{
EditorJsonUtility.FromJsonOverwrite(fileContent, package);
}
if (package.entries == null)
{
package.entries = new List<ShaderPackage.Entry>();
}
#if __BETTERSHADERS__
if (package.betterShader != null)
{
package.betterShaderPath = AssetDatabase.GetAssetPath(package.betterShader);
}
#endif
package.Pack(false);
#if __BETTERSHADERS__
if (package.betterShader != null)
{
ctx.DependsOnSourceAsset(package.betterShaderPath);
}
#endif
foreach (var e in package.entries)
{
if (e.shader != null)
{
ctx.DependsOnSourceAsset(AssetDatabase.GetAssetPath(e.shader));
}
}
string shaderSrc = package.GetShaderSrc();
if (shaderSrc == null)
{
Debug.LogError("No Shader for this platform and SRP provided");
// maybe make an error shader here?
return;
}
Shader shader = ShaderUtil.CreateShaderAsset(ctx, shaderSrc, false);
ctx.AddObjectToAsset("MainAsset", shader);
ctx.SetMainObject(shader);
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 432996ca1b2bd36408bd150d34f9b6ca
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 35611
packageName: UMA 2
packageVersion: 2.13
assetPath: Assets/UMA/Content/ShaderPackages/ShaderPackager-main/Scripts/Editor/ShaderPackageImporter.cs
uploadId: 679826
@@ -0,0 +1,155 @@
//////////////////////////////////////////////////////
// Shader Packager
// Copyright (c)2021 Jason Booth
//////////////////////////////////////////////////////
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UMA.ShaderPackager;
#if UNITY_2020_2_OR_NEWER
using UnityEditor.AssetImporters;
#else
using UnityEditor.Experimental.AssetImporters;
#endif
using System.IO;
namespace UMA.ShaderPackager
{
[CustomEditor(typeof(ShaderPackageImporter))]
[CanEditMultipleObjects]
public class ShaderPackageImporterEditor : ScriptedImporterEditor
{
SerializedProperty m_autoUpdate;
SerializedProperty m_entryProperties;
#if __BETTERSHADERS__
SerializedProperty m_betterShader;
SerializedProperty m_optionOverrides;
#endif
// override extraDataType to return the type that will be used in the Editor.
protected override System.Type extraDataType => typeof(ShaderPackage);
// override InitializeExtraDataInstance to set up the data.
protected override void InitializeExtraDataInstance(Object extraTarget, int targetIndex)
{
var stack = (ShaderPackage)extraTarget;
string fileContent = File.ReadAllText(((AssetImporter)targets[targetIndex]).assetPath);
EditorJsonUtility.FromJsonOverwrite(fileContent, stack);
}
protected override void Apply()
{
base.Apply();
// After the Importer is applied, rewrite the file with the custom value.
for (int i = 0; i < targets.Length; i++)
{
string path = ((AssetImporter)targets[i]).assetPath;
File.WriteAllText(path, EditorJsonUtility.ToJson((ShaderPackage)extraDataTargets[i]));
}
}
public override void OnEnable()
{
base.OnEnable();
// In OnEnable, retrieve the importerUserSerializedObject property and store it.
m_entryProperties = extraDataSerializedObject.FindProperty("entries");
#if __BETTERSHADERS__
m_betterShader = extraDataSerializedObject.FindProperty("betterShader");
m_optionOverrides = extraDataSerializedObject.FindProperty("optionOverrides");
#endif
}
public override void OnInspectorGUI()
{
extraDataSerializedObject.Update();
ShaderPackage sp = extraDataSerializedObject.targetObject as ShaderPackage;
#if __BETTERSHADERS__
EditorGUILayout.PropertyField(m_betterShader);
EditorGUILayout.PropertyField(m_optionOverrides);
#endif
EditorGUILayout.PropertyField(m_entryProperties);
if ((typeof(ShaderPackage).Namespace == "JBooth.ShaderPackager") ||
ShaderPackageImporter.k_FileExtension == ".shaderpack")
{
EditorGUILayout.HelpBox("Warning: You must change the namespace and extension!", MessageType.Error);
}
if (GUILayout.Button("Pack"))
{
sp.Pack(true);
}
if (GUILayout.Button("Pack all in Project"))
{
var guids = AssetDatabase.FindAssets("t:Shader");
List<string> shaders = new List<string>();
for (int i = 0; i < guids.Length; ++i)
{
var path = AssetDatabase.GUIDToAssetPath(guids[i]);
if (path.EndsWith(ShaderPackageImporter.k_FileExtension))
{
shaders.Add(path);
}
}
for (int i = 0; i < shaders.Count; ++i)
{
var path = shaders[i];
EditorUtility.DisplayProgressBar("Packing Shaders", Path.GetFileName(path), (float)i / shaders.Count);
try
{
ShaderPackage packed = ShaderPackage.CreateInstance<ShaderPackage>();
UnityEditor.EditorJsonUtility.FromJsonOverwrite(File.ReadAllText(path), packed);
packed.Pack(true);
File.WriteAllText(path, EditorJsonUtility.ToJson(packed));
EditorUtility.SetDirty(packed);
AssetDatabase.SaveAssets();
AssetDatabase.ImportAsset(path);
}
catch
{
EditorUtility.ClearProgressBar();
}
}
EditorUtility.ClearProgressBar();
}
extraDataSerializedObject.ApplyModifiedProperties();
ApplyRevertGUI();
}
[MenuItem("Assets/Create/Shader Package", priority = 300)]
static void CreateMenuItemShaderPackage()
{
string directoryPath = "Assets";
foreach (Object obj in Selection.GetFiltered(typeof(Object), SelectionMode.Assets))
{
directoryPath = AssetDatabase.GetAssetPath(obj);
if (!string.IsNullOrEmpty(directoryPath) && File.Exists(directoryPath))
{
directoryPath = Path.GetDirectoryName(directoryPath);
break;
}
}
directoryPath = directoryPath.Replace("\\", "/");
if (directoryPath.Length > 0 && directoryPath[directoryPath.Length - 1] != '/')
directoryPath += "/";
if (string.IsNullOrEmpty(directoryPath))
directoryPath = "Assets/";
var fileName = string.Format("New ShaderPackage{0}", ShaderPackageImporter.k_FileExtension);
directoryPath = AssetDatabase.GenerateUniqueAssetPath(directoryPath + fileName);
var content = ScriptableObject.CreateInstance<ShaderPackage>();
File.WriteAllText(directoryPath, EditorJsonUtility.ToJson(content));
AssetDatabase.Refresh();
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 019a594d1421fc84e91aafcfd10b8fec
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 35611
packageName: UMA 2
packageVersion: 2.13
assetPath: Assets/UMA/Content/ShaderPackages/ShaderPackager-main/Scripts/Editor/ShaderPackageImporterEditor.cs
uploadId: 679826
@@ -0,0 +1,57 @@
///////////////////////////////////////////
///
/// Shader Packager
/// ©2021 Jason Booth
///
/// makes sure shader get in the shader menu
using System;
using UnityEditor;
using UnityEngine;
namespace UMA.ShaderPackager
{
class ShaderPackagerPostProcessor : AssetPostprocessor
{
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
{
RegisterShaders(importedAssets);
}
static void RegisterShaders(string[] paths)
{
foreach (var assetPath in paths)
{
if (!assetPath.EndsWith(ShaderPackageImporter.k_FileExtension, StringComparison.InvariantCultureIgnoreCase))
{
continue;
}
var mainObj = AssetDatabase.LoadMainAssetAtPath(assetPath) as Shader;
if (mainObj != null)
{
ShaderUtil.ClearShaderMessages(mainObj);
if (!ShaderUtil.ShaderHasError(mainObj))
{
ShaderUtil.RegisterShader(mainObj);
}
}
foreach (var obj in AssetDatabase.LoadAllAssetRepresentationsAtPath(assetPath))
{
if (obj is Shader)
{
Shader s = obj as Shader;
ShaderUtil.ClearShaderMessages(s);
if (!ShaderUtil.ShaderHasError(s))
{
ShaderUtil.RegisterShader((Shader)obj);
}
}
}
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 3afbe1c2d9067094b8f730ae7fbba375
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 35611
packageName: UMA 2
packageVersion: 2.13
assetPath: Assets/UMA/Content/ShaderPackages/ShaderPackager-main/Scripts/Editor/ShaderPackagePostProcessor.cs
uploadId: 679826
@@ -0,0 +1,16 @@
{
"name": "Shaderpackager-editor",
"rootNamespace": "",
"references": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: e3e49a33120359147ac80b496584785d
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 35611
packageName: UMA 2
packageVersion: 2.13
assetPath: Assets/UMA/Content/ShaderPackages/ShaderPackager-main/Scripts/Editor/Shaderpackager-editor.asmdef
uploadId: 679826