[Add] All in one shader
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public abstract class AbstractMaterialInfo
|
||||
{
|
||||
public string[] enabledKeywords;
|
||||
public Material mat;
|
||||
|
||||
public AbstractMaterialInfo(Material mat)
|
||||
{
|
||||
this.enabledKeywords = new string[0];
|
||||
this.mat = mat;
|
||||
}
|
||||
|
||||
public abstract void RefreshKeywords();
|
||||
|
||||
public abstract void EnableKeyword(string keyword);
|
||||
|
||||
public abstract void DisableKeyword(string keyword);
|
||||
|
||||
public abstract bool IsShaderVariant();
|
||||
|
||||
public bool IsKeywordEnabled(string keyword)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
for (int i = 0; i < enabledKeywords.Length; i++)
|
||||
{
|
||||
if (enabledKeywords[i] == keyword)
|
||||
{
|
||||
res = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public int GetEnabledKeywordIndexByEffect(AllIn13DEffectConfig effectConfig)
|
||||
{
|
||||
int res = -1;
|
||||
for (int i = 0; i < enabledKeywords.Length; i++)
|
||||
{
|
||||
res = effectConfig.GetKeywordIndex(enabledKeywords[i]);
|
||||
if(res >= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public int GetEnabledKeywordIndexByEffectProperty(EffectProperty effectProperty)
|
||||
{
|
||||
int res = -1;
|
||||
|
||||
if(effectProperty.IsEnumProperty() || effectProperty.IsToggleProperty())
|
||||
{
|
||||
for (int i = 0; i < enabledKeywords.Length; i++)
|
||||
{
|
||||
for (int j = 0; j < effectProperty.fullKeywordNames.Length; j++)
|
||||
{
|
||||
if (effectProperty.fullKeywordNames[j] == enabledKeywords[i])
|
||||
{
|
||||
res = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(res >= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public static AbstractMaterialInfo CreateInstance(Material mat)
|
||||
{
|
||||
EffectsProfileCollection effectsProfileCollection = GlobalConfiguration.instance.effectsProfileCollection;
|
||||
EffectsProfile effectsProfile = effectsProfileCollection.FindEffectProfileByShader(mat.shader);
|
||||
|
||||
AbstractMaterialInfo res = null;
|
||||
if (effectsProfile == null)
|
||||
{
|
||||
res = new CommonMaterialInfo(mat);
|
||||
}
|
||||
else
|
||||
{
|
||||
res = new EffectProfileMaterialInfo(effectsProfile, mat);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 695b6880e2c7f3746be8b2dfaff26022
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/AbstractMaterialInfo.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,501 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using static AllIn13DShader.EffectsExtraData;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
[System.Serializable]
|
||||
public class AllIn13DEffectConfig
|
||||
{
|
||||
public string effectName;
|
||||
public string displayName;
|
||||
public string group;
|
||||
|
||||
public int keywordPropertyIndex;
|
||||
public string keywordPropertyName;
|
||||
|
||||
public string effectDrawerID;
|
||||
public string dependentOnEffect;
|
||||
public string incompatibleWithEffectID;
|
||||
public string docURL;
|
||||
public MessageByKeywords[] customMessages;
|
||||
|
||||
//public List<string> keywords;
|
||||
public List<EffectKeywordData> keywords;
|
||||
public string[] keywordsDisplayNames;
|
||||
public List<EffectProperty> effectProperties;
|
||||
|
||||
public string disabledKeyword;
|
||||
|
||||
public int displayIndex;
|
||||
|
||||
public EffectConfigType effectConfigType;
|
||||
public AllIn13DPassType[] extraPasses;
|
||||
|
||||
public AllIn13DEffectConfig(
|
||||
string displayName, string propertyName, int propertyIndex, EffectConfigType effectConfigType,
|
||||
EffectAttributeData data, EffectsExtraData effectsExtraData, int displayIndex)
|
||||
{
|
||||
this.displayName = displayName;
|
||||
this.keywordPropertyName = propertyName;
|
||||
this.keywordPropertyIndex = propertyIndex;
|
||||
this.effectConfigType = effectConfigType;
|
||||
|
||||
this.effectName = data.effectID;
|
||||
this.group = data.groupID;
|
||||
this.effectDrawerID = data.drawerID;
|
||||
this.dependentOnEffect = data.dependentEffectID;
|
||||
this.incompatibleWithEffectID = data.incompatibleWithEffectID;
|
||||
|
||||
EffectsExtraData.ExtraData extraData = effectsExtraData.GetExtraDataByEffectID(effectName);
|
||||
if(extraData != null)
|
||||
{
|
||||
this.docURL = extraData.docURL;
|
||||
this.customMessages = extraData.customMessages;
|
||||
}
|
||||
|
||||
this.keywords = new List<EffectKeywordData>();
|
||||
this.effectProperties = new List<EffectProperty>();
|
||||
this.keywordsDisplayNames = new string[0];
|
||||
this.extraPasses = new AllIn13DPassType[0];
|
||||
|
||||
for(int i = 0; i < data.extraPasses.Length; i++)
|
||||
{
|
||||
AllIn13DPassType passType;
|
||||
Enum.TryParse(data.extraPasses[i], out passType);
|
||||
|
||||
ArrayUtility.Add(ref extraPasses, passType);
|
||||
}
|
||||
|
||||
this.displayIndex = displayIndex;
|
||||
}
|
||||
|
||||
public void AddKeyword(EffectKeywordData kw)
|
||||
{
|
||||
keywords.Add(kw);
|
||||
}
|
||||
|
||||
public void AddKeywords(EffectKeywordData[] kws)
|
||||
{
|
||||
keywords.AddRange(kws);
|
||||
}
|
||||
|
||||
public void Setup()
|
||||
{
|
||||
for(int i = 0; i < keywords.Count; i++)
|
||||
{
|
||||
ArrayUtility.Add(ref keywordsDisplayNames, keywords[i].displayName);
|
||||
}
|
||||
}
|
||||
|
||||
public EffectProperty FindEffectPropertyByIndex(int propertyIndex)
|
||||
{
|
||||
EffectProperty res = null;
|
||||
|
||||
for (int i = 0; i < effectProperties.Count; i++)
|
||||
{
|
||||
if (effectProperties[i].propertyIndex == propertyIndex)
|
||||
{
|
||||
res = effectProperties[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public EffectProperty FindEffectPropertyByName(string propertyName)
|
||||
{
|
||||
EffectProperty res = null;
|
||||
|
||||
for(int i = 0; i < effectProperties.Count; i++)
|
||||
{
|
||||
if (effectProperties[i].propertyName == propertyName)
|
||||
{
|
||||
res = effectProperties[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public EffectProperty CreateEffectProperty(int propertyIndex, string propertyName, string displayName,
|
||||
ShaderPropertyType shaderPropertyType, ShaderPropertyFlags shaderPropertyFlags,
|
||||
EffectPropertyAttributeData data)
|
||||
{
|
||||
EffectProperty res = new EffectProperty(this, propertyIndex, propertyName, displayName,
|
||||
data.keywordsOp, data.allowReset, shaderPropertyType, shaderPropertyFlags);
|
||||
effectProperties.Add(res);
|
||||
|
||||
for (int i = 0; i < data.keywords.Count; i++)
|
||||
{
|
||||
res.AddKeyword(data.keywords[i]);
|
||||
}
|
||||
|
||||
for(int i = 0; i < data.incompatibleWithKws.Count; i++)
|
||||
{
|
||||
res.AddIncompatibleKeyword(data.incompatibleWithKws[i]);
|
||||
}
|
||||
|
||||
res.AddPropertyKeywords(data.propertyKeywords);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public string GetCustomMessage(AbstractMaterialInfo[] targetMatInfos)
|
||||
{
|
||||
string res = string.Empty;
|
||||
if(targetMatInfos.Length == 1)
|
||||
{
|
||||
res = GetCustomMessage(targetMatInfos[0]);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public string GetCustomMessage(AbstractMaterialInfo targetMatInfo)
|
||||
{
|
||||
string res = string.Empty;
|
||||
|
||||
if(customMessages != null && customMessages.Length > 0)
|
||||
{
|
||||
for(int i = 0; i < customMessages.Length; i++)
|
||||
{
|
||||
MessageByKeywords customMessage = customMessages[i];
|
||||
|
||||
if (customMessage.IsMessageEnabled(targetMatInfo))
|
||||
{
|
||||
res = customMessage.message;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public static bool IsEffectAvailable(AllIn13DEffectConfig effectConfig, AllIn13DShaderInspectorReferences references)
|
||||
{
|
||||
bool res = true;
|
||||
bool isShaderVariant = references.IsShaderVariant();
|
||||
|
||||
if (isShaderVariant)
|
||||
{
|
||||
for (int i = 0; i < references.targetMatInfos.Length; i++)
|
||||
{
|
||||
AbstractMaterialInfo matInfo = references.targetMatInfos[i];
|
||||
res = res && AllIn13DEffectConfig.IsEffectEnabled(effectConfig, matInfo);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public static bool IsEffectEnabled(AllIn13DEffectConfig effectConfig, AllIn13DShaderInspectorReferences references)
|
||||
{
|
||||
int selectedIndex = 0;
|
||||
return IsEffectEnabled(effectConfig, ref selectedIndex, references);
|
||||
}
|
||||
|
||||
public static bool IsEffectEnabled(AllIn13DEffectConfig effectConfig, AbstractMaterialInfo targetMatInfo)
|
||||
{
|
||||
int selectedIndex = 0;
|
||||
return IsEffectEnabled(effectConfig, ref selectedIndex, targetMatInfo);
|
||||
}
|
||||
|
||||
public static bool IsEffectEnabled(AllIn13DEffectConfig effectConfig, ref int selectedIndex, AllIn13DShaderInspectorReferences references)
|
||||
{
|
||||
bool res = true;
|
||||
for (int i = 0; i < references.targetMatInfos.Length; i++)
|
||||
{
|
||||
res = res && IsEffectEnabled(effectConfig, ref selectedIndex, references.targetMatInfos[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public bool AreDependenciesMet(PropertiesConfig propertiesConfig, AbstractMaterialInfo targetMatInfo)
|
||||
{
|
||||
bool res = true;
|
||||
|
||||
if (!string.IsNullOrEmpty(dependentOnEffect))
|
||||
{
|
||||
AllIn13DEffectConfig dependentEffect = propertiesConfig.FindEffectConfigByID(dependentOnEffect);
|
||||
res = res && IsEffectEnabled(dependentEffect, targetMatInfo);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public static bool IsEffectEnabled(AllIn13DEffectConfig effectConfig, ref int selectedIndex, AbstractMaterialInfo targetMatInfo)
|
||||
{
|
||||
selectedIndex = 0;
|
||||
|
||||
bool res = false;
|
||||
|
||||
if (effectConfig.keywords.Count == 1)
|
||||
{
|
||||
if (targetMatInfo.IsKeywordEnabled(effectConfig.keywords[0].keyword))
|
||||
{
|
||||
res = true;
|
||||
selectedIndex = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < effectConfig.keywords.Count; i++)
|
||||
{
|
||||
string keywordToCheck = effectConfig.keywords[i].keyword;
|
||||
|
||||
bool isNoneOption = effectConfig.keywordsDisplayNames[i] == Constants.DISABLED_ENUM_OPTION_STR;
|
||||
if (targetMatInfo.IsKeywordEnabled(keywordToCheck) && !isNoneOption)
|
||||
{
|
||||
res = true;
|
||||
selectedIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public static bool IsEffectPropertyEnabled(EffectProperty effectProperty, ref int selectedIndex, string[] enabledKeywords)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
if (effectProperty.fullKeywordNames.Length == 1)
|
||||
{
|
||||
if (ArrayUtility.Contains(enabledKeywords, effectProperty.fullKeywordNames[0]))
|
||||
{
|
||||
res = true;
|
||||
selectedIndex = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < effectProperty.fullKeywordNames.Length; i++)
|
||||
{
|
||||
if (ArrayUtility.Contains(enabledKeywords, effectProperty.fullKeywordNames[i]))
|
||||
{
|
||||
res = true;
|
||||
selectedIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public static bool IsEffectPropertyEnabled(EffectProperty effectProperty, ref int selectedIndex, AbstractMaterialInfo targetMatInfo)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
if(effectProperty.fullKeywordNames.Length == 1)
|
||||
{
|
||||
if (targetMatInfo.IsKeywordEnabled(effectProperty.fullKeywordNames[0]))
|
||||
{
|
||||
res = true;
|
||||
selectedIndex = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i = 0; i < effectProperty.fullKeywordNames.Length; i++)
|
||||
{
|
||||
if (targetMatInfo.IsKeywordEnabled(effectProperty.fullKeywordNames[i]))
|
||||
{
|
||||
res = true;
|
||||
selectedIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public static void ResetProperty(MaterialProperty targetProperty, AllIn13DShaderInspectorReferences references, AbstractMaterialInfo targetMatInfo)
|
||||
{
|
||||
Shader shader = targetMatInfo.mat.shader;
|
||||
|
||||
if (references.materialWithDefaultValues == null)
|
||||
{
|
||||
references.materialWithDefaultValues = new Material(shader);
|
||||
}
|
||||
|
||||
AllIn1ShaderPropertyType targetPropertyType = EditorUtils.GetShaderTypeByMaterialProperty(targetProperty);
|
||||
int propertyIndex = shader.FindPropertyIndex(targetProperty.name);
|
||||
if (targetPropertyType == AllIn1ShaderPropertyType.Float || targetPropertyType == AllIn1ShaderPropertyType.Range)
|
||||
{
|
||||
targetProperty.floatValue = references.materialWithDefaultValues.GetFloat(targetProperty.name);
|
||||
}
|
||||
else if (targetPropertyType == AllIn1ShaderPropertyType.Vector)
|
||||
{
|
||||
targetProperty.vectorValue = references.materialWithDefaultValues.GetVector(targetProperty.name);
|
||||
}
|
||||
else if (targetPropertyType == AllIn1ShaderPropertyType.Color)
|
||||
{
|
||||
targetProperty.colorValue = references.materialWithDefaultValues.GetColor(targetProperty.name);
|
||||
}
|
||||
else if (targetPropertyType == AllIn1ShaderPropertyType.Texture)
|
||||
{
|
||||
targetProperty.textureValue = references.materialWithDefaultValues.GetTexture(targetProperty.name);
|
||||
}
|
||||
}
|
||||
|
||||
public static void EnableEffect(AllIn13DEffectConfig effectConfig, AllIn13DShaderInspectorReferences references, AbstractMaterialInfo targetMatInfo)
|
||||
{
|
||||
for (int i = 0; i < effectConfig.keywords.Count; i++)
|
||||
{
|
||||
string kw = effectConfig.keywords[i].keyword;
|
||||
targetMatInfo.EnableKeyword(kw);
|
||||
}
|
||||
}
|
||||
|
||||
public static void EnableEffectToggle(AllIn13DEffectConfig effectConfig, AllIn13DShaderInspectorReferences references, AbstractMaterialInfo targetMatInfo)
|
||||
{
|
||||
targetMatInfo.EnableKeyword(effectConfig.keywords[0].keyword);
|
||||
references.matProperties[effectConfig.keywordPropertyIndex].floatValue = 1f;
|
||||
}
|
||||
|
||||
public static void DisableEffectToggle(AllIn13DEffectConfig effectConfig, AllIn13DShaderInspectorReferences references, AbstractMaterialInfo targetMatInfo)
|
||||
{
|
||||
targetMatInfo.DisableKeyword(effectConfig.keywords[0].keyword);
|
||||
references.matProperties[effectConfig.keywordPropertyIndex].floatValue = 0f;
|
||||
}
|
||||
|
||||
public static void EnableEffectByIndex(AllIn13DEffectConfig effectConfig, int index, AllIn13DShaderInspectorReferences references, AbstractMaterialInfo targetMatInfo)
|
||||
{
|
||||
DisableEffect(effectConfig, targetMatInfo);
|
||||
string kwToEnable = effectConfig.keywords[index].keyword;
|
||||
|
||||
targetMatInfo.EnableKeyword(kwToEnable);
|
||||
}
|
||||
|
||||
public static void DisableEffect(AllIn13DEffectConfig effectConfig, AllIn13DShaderInspectorReferences references)
|
||||
{
|
||||
for(int i = 0; i < references.targetMatInfos.Length; i++)
|
||||
{
|
||||
DisableEffect(effectConfig, references.targetMatInfos[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DisableEffect(AllIn13DEffectConfig effectConfig, AbstractMaterialInfo targetMatInfo)
|
||||
{
|
||||
for (int i = 0; i < effectConfig.keywords.Count; i++)
|
||||
{
|
||||
string kw = effectConfig.keywords[i].keyword;
|
||||
|
||||
targetMatInfo.DisableKeyword(kw);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool ContainsKeyword(Material mat, string kw, LocalKeyword[] enabledKeywords)
|
||||
{
|
||||
bool res = false;
|
||||
for (int i = 0; i < enabledKeywords.Length; i++)
|
||||
{
|
||||
if (enabledKeywords[i].name == kw)
|
||||
{
|
||||
res = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int GetKeywordIndex(string keyword)
|
||||
{
|
||||
int res = -1;
|
||||
for (int i = 0; i < keywords.Count; i++)
|
||||
{
|
||||
if (keywords[i].keyword == keyword)
|
||||
{
|
||||
res = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public string[] GetPropertyNames()
|
||||
{
|
||||
string[] res = new string[effectProperties.Count];
|
||||
|
||||
for(int i = 0; i < effectProperties.Count; i++)
|
||||
{
|
||||
res[i] = $"{effectProperties[i].displayName} ({effectProperties[i].propertyName})";
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public bool ContainsKeywordProperties()
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
for(int i = 0; i < effectProperties.Count; i++)
|
||||
{
|
||||
if (effectProperties[i].IsPropertyWithKeywords())
|
||||
{
|
||||
res = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public GUIContent CreateGUIContent(int globalEffectIndex, int keywordSelectedIndex)
|
||||
{
|
||||
string label = $"{globalEffectIndex}. {displayName}";
|
||||
string tooltip = keywords[keywordSelectedIndex].keyword + " (C#)";
|
||||
|
||||
GUIContent res = new GUIContent(label, tooltip);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public bool ContainsKeyword(string keyword)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
for(int i = 0; i < keywords.Count; i++)
|
||||
{
|
||||
if (keywords[i].keyword == keyword)
|
||||
{
|
||||
res = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public bool ContainsSomeKeywordFromList(string[] keywords)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
for(int i = 0; i < keywords.Length; i++)
|
||||
{
|
||||
if (ContainsKeyword(keywords[i]))
|
||||
{
|
||||
res = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9e56d697165908f4a802d77da51b7913
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/AllIn13DEffectConfig.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "AllIn13DShaderAssemebly.Editor",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:1b1237e1ff5eb504898a6f1f45e9b538",
|
||||
"GUID:c579267770062bf448e75eb160330b7f",
|
||||
"GUID:15fc0a57446b3144c949da3e2b9737a9",
|
||||
"GUID:3eae0364be2026648bf74846acb8a731"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9180457c15877e84e9afced3000f4ee1
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/AllIn13DShaderAssemebly.Editor.asmdef
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,19 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public static class AllIn13DShaderConfig
|
||||
{
|
||||
//Default Material Name
|
||||
public const string MATERIAL_NAME_DEFAULT = "AllIn13DMaterial.mat";
|
||||
|
||||
public static Texture GetInspectorImage()
|
||||
{
|
||||
Texture res = null;
|
||||
|
||||
res = EditorUtils.FindAsset<Texture>("AllIn13dShaderCustomEditorHeader");
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ac8fcdac0e79974c8d61e1de5dc57ed
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/AllIn13DShaderConfig.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,194 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class AllIn13DShaderInspectorReferences
|
||||
{
|
||||
public MaterialProperty[] matProperties;
|
||||
public string[] oldKeyWords;
|
||||
|
||||
public AbstractMaterialInfo[] targetMatInfos;
|
||||
|
||||
public Material materialWithDefaultValues;
|
||||
|
||||
public MaterialEditor editorMat;
|
||||
|
||||
//Styles
|
||||
private const int bigFontSize = 16, smallFontSize = 11;
|
||||
public GUIStyle propertiesStyle, bigLabelStyle, smallLabelStyle, toggleButtonStyle, tabButtonStyle;
|
||||
|
||||
//Outline Effect
|
||||
public AllIn13DEffectConfig outlineEffectConfig;
|
||||
|
||||
//Cast Shadows Effect
|
||||
public AllIn13DEffectConfig castShadowsEffectConfig;
|
||||
|
||||
//Effects Profile Collection
|
||||
public EffectsProfileCollection effectsProfileCollection;
|
||||
|
||||
public AllIn13DShaderInspectorReferences()
|
||||
{
|
||||
propertiesStyle = new GUIStyle(EditorStyles.helpBox);
|
||||
propertiesStyle.margin = new RectOffset(0, 0, 0, 0);
|
||||
|
||||
bigLabelStyle = new GUIStyle(EditorStyles.boldLabel);
|
||||
bigLabelStyle.fontSize = bigFontSize;
|
||||
|
||||
smallLabelStyle = new GUIStyle(EditorStyles.boldLabel);
|
||||
smallLabelStyle.fontSize = smallFontSize;
|
||||
|
||||
toggleButtonStyle = new GUIStyle(GUI.skin.button) { alignment = TextAnchor.MiddleCenter, richText = true };
|
||||
|
||||
tabButtonStyle = new GUIStyle(GUI.skin.button) { fontSize = 10 };
|
||||
}
|
||||
|
||||
public void Setup(MaterialEditor materialEditor, MaterialProperty[] properties)
|
||||
{
|
||||
this.editorMat = materialEditor;
|
||||
|
||||
if (this.targetMatInfos == null)
|
||||
{
|
||||
this.targetMatInfos = new AbstractMaterialInfo[materialEditor.targets.Length];
|
||||
for (int i = 0; i < materialEditor.targets.Length; i++)
|
||||
{
|
||||
Material mat = (Material)materialEditor.targets[i];
|
||||
targetMatInfos[i] = AbstractMaterialInfo.CreateInstance(mat);
|
||||
}
|
||||
|
||||
materialWithDefaultValues = new Material(targetMatInfos[0].mat.shader);
|
||||
}
|
||||
|
||||
this.effectsProfileCollection = GlobalConfiguration.instance.effectsProfileCollection;
|
||||
|
||||
this.matProperties = properties;
|
||||
}
|
||||
|
||||
public void SetOutlineEffect(PropertiesConfig propertiesConfig)
|
||||
{
|
||||
this.outlineEffectConfig = propertiesConfig.FindEffectConfigByID("OUTLINETYPE");
|
||||
}
|
||||
|
||||
public void SetCastShadowsEffect(PropertiesConfig propertiesConfig)
|
||||
{
|
||||
this.castShadowsEffectConfig = propertiesConfig.FindEffectConfigByID("CAST_SHADOWS_ON");
|
||||
}
|
||||
|
||||
public void SetMaterialsDirty()
|
||||
{
|
||||
for(int i = 0; i < targetMatInfos.Length; i++)
|
||||
{
|
||||
EditorUtility.SetDirty(targetMatInfos[i].mat);
|
||||
}
|
||||
}
|
||||
|
||||
public Shader GetShader()
|
||||
{
|
||||
return targetMatInfos[0].mat.shader;
|
||||
}
|
||||
|
||||
public bool IsKeywordEnabled(string keyword)
|
||||
{
|
||||
bool res = true;
|
||||
|
||||
for(int i = 0; i < targetMatInfos.Length; i++)
|
||||
{
|
||||
res = res && targetMatInfos[i].IsKeywordEnabled(keyword);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public void RefreshMaterialKeywords()
|
||||
{
|
||||
for(int i = 0; i < this.targetMatInfos.Length; i++)
|
||||
{
|
||||
this.targetMatInfos[i].RefreshKeywords();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsShaderVariant()
|
||||
{
|
||||
bool res = true;
|
||||
|
||||
for(int i = 0; i < targetMatInfos.Length; i++)
|
||||
{
|
||||
res = res && targetMatInfos[i].IsShaderVariant();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public bool IsEffectEnabled(AllIn13DEffectConfig effectConfig, ref int selectedIndex)
|
||||
{
|
||||
bool res = true;
|
||||
|
||||
for (int i = 0; i < targetMatInfos.Length; i++)
|
||||
{
|
||||
int enumIdx = -1;
|
||||
AbstractMaterialInfo matInfo = targetMatInfos[i];
|
||||
|
||||
bool effectEnabled = AllIn13DEffectConfig.IsEffectEnabled(effectConfig, ref enumIdx, matInfo);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
selectedIndex = enumIdx;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = res && (enumIdx == selectedIndex);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public bool IsEffectPropertyEnabled(EffectProperty effectProperty, ref int selectedIndex)
|
||||
{
|
||||
bool res = true;
|
||||
|
||||
for (int i = 0; i < targetMatInfos.Length; i++)
|
||||
{
|
||||
int enumIdx = 0;
|
||||
AbstractMaterialInfo matInfo = targetMatInfos[i];
|
||||
|
||||
res = res && AllIn13DEffectConfig.IsEffectPropertyEnabled(effectProperty, ref enumIdx, matInfo);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
selectedIndex = enumIdx;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = res && (enumIdx == selectedIndex);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public bool AreAllMaterialsShaderVariant()
|
||||
{
|
||||
bool res = true;
|
||||
|
||||
for(int i = 0; i < targetMatInfos.Length; i++)
|
||||
{
|
||||
res = res && targetMatInfos[i].IsShaderVariant();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public bool AreAllMaterialsShaderGeneric()
|
||||
{
|
||||
bool res = true;
|
||||
|
||||
for (int i = 0; i < targetMatInfos.Length; i++)
|
||||
{
|
||||
res = res && !targetMatInfos[i].IsShaderVariant();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 42ff15ffadcc8ae42982fa48192469ea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/AllIn13DShaderInspectorReferences.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,42 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class CommonMaterialInfo : AbstractMaterialInfo
|
||||
{
|
||||
public CommonMaterialInfo(Material mat) : base(mat)
|
||||
{
|
||||
RefreshKeywords();
|
||||
}
|
||||
|
||||
public EffectsProfile effectProfile;
|
||||
|
||||
public override void RefreshKeywords()
|
||||
{
|
||||
this.enabledKeywords = new string[mat.enabledKeywords.Length];
|
||||
for (int i = 0; i < enabledKeywords.Length; i++)
|
||||
{
|
||||
this.enabledKeywords[i] = mat.enabledKeywords[i].name;
|
||||
}
|
||||
}
|
||||
|
||||
public override void EnableKeyword(string keyword)
|
||||
{
|
||||
mat.EnableKeyword(keyword);
|
||||
|
||||
RefreshKeywords();
|
||||
}
|
||||
|
||||
public override void DisableKeyword(string keyword)
|
||||
{
|
||||
mat.DisableKeyword(keyword);
|
||||
|
||||
RefreshKeywords();
|
||||
}
|
||||
|
||||
public override bool IsShaderVariant()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81dd06e6f7828b340ab17dfd17529a9b
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/CommonMaterialInfo.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public static class CommonMessages
|
||||
{
|
||||
public const string URP_PIPELINE_NOT_ASSIGNED = "URP installed, but Render Pipeline Asset not assigned\nPlease assign a URP Render Pipeline Asset \nOr remove URP in the Package Manager";
|
||||
public const string URP_PIPELINE_NOT_ASSIGNED_DOC_LINK = "https://seasidestudios.gitbook.io/seaside-studios/3d-shader/urp-and-post-processing-setup";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc117341064526c43aa23854ad769ab9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/CommonMessages.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,130 @@
|
||||
using System.IO;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public static class Constants
|
||||
{
|
||||
public static string VERSION = "2.72";
|
||||
|
||||
public const string EFFECT_ATTRIBUTE_PREFIX = "Effect(";
|
||||
public const string EFFECT_PROPERTY_ATTRIBUTE_PREFIX = "EffectProperty(";
|
||||
//public const string HEADER_PREFIX = "Header(";
|
||||
public const string SINGLE_PROPERTY_ATTRIBUTE = "SingleProperty";
|
||||
public const string ADVANCED_PROPERTY_ATTRIBUTE = "AdvancedProperty";
|
||||
|
||||
|
||||
public const string SHADER_ROOT = "AllIn13DShader";
|
||||
|
||||
public static string[] SHADERS_NAMES = new string[]
|
||||
{
|
||||
"AllIn13DShader",
|
||||
"AllIn13DShader_NoShadowCaster",
|
||||
"AllIn13DShaderOutline_NoShadowCaster",
|
||||
"AllIn13DShaderOutline",
|
||||
};
|
||||
|
||||
public static string MAIN_SHADER_NAME
|
||||
{
|
||||
get
|
||||
{
|
||||
return SHADERS_NAMES[0];
|
||||
}
|
||||
}
|
||||
|
||||
public static string SHADER_FULL_NAME_ALLIN13D
|
||||
{
|
||||
get
|
||||
{
|
||||
return SHADER_ROOT + "/" + MAIN_SHADER_NAME;
|
||||
}
|
||||
}
|
||||
|
||||
public static string SHADER_FULL_NAME_ALLIN13D_OUTLINE
|
||||
{
|
||||
get
|
||||
{
|
||||
return SHADER_ROOT + "/" + SHADERS_NAMES[3];
|
||||
}
|
||||
}
|
||||
|
||||
public static string SHADER_NAME_ALLIN13D_OUTLINE = "AllIn13DShaderOutline";
|
||||
|
||||
|
||||
|
||||
//=========== Paths ===========
|
||||
public static string SHADERS_FOLDER_PATH = Path.Combine(GlobalConfiguration.instance.RootPluginPath, "Shaders");/*"Assets/AllIn13DShader/Shaders";*/
|
||||
public static string SHADERS_GENERIC_FOLDER_PATH = Path.Combine(SHADERS_FOLDER_PATH, "Generic Shaders");
|
||||
public static string SHADER_LIBRARY_FOLDER_PATH = Path.Combine(SHADERS_FOLDER_PATH, "ShaderLibrary");
|
||||
//public static string SHADERS_PROPERTIES_FOLDER_PATH = /*"Assets/AllIn13DShader/Editor"*/Path.Combine(GlobalConfiguration.instance.RootPluginPath, "Editor");
|
||||
public static string TEMPLATES_FOLDER = Path.Combine(GlobalConfiguration.instance.RootPluginPath, "Editor/Templates");
|
||||
public const string STANDARD_EXAMPLES_MATERIALS_LOCAL_PATH = "Demo/Materials/StandardExamples";
|
||||
public static string DEMO_SHADERS_BAKED_FOLDER_PATH = Path.Combine(GlobalConfiguration.instance.RootPluginPath, "Demo/Baked Shaders Demo/Shaders");
|
||||
|
||||
/* Shader Passes Paths */
|
||||
public const string MAIN_PASS_PATH = "Shaders/ShaderLibrary/AllIn13DShader_BasePass.hlsl";
|
||||
public const string LIGHT_ADD_PASS_PATH = "Shaders/ShaderLibrary/AllIn13DShaderLightAddPass.hlsl";
|
||||
public const string SHADOW_CASTER_PASS_PATH = "Shaders/ShaderLibrary/AllIn13DShader_ShadowCasterPass.hlsl";
|
||||
public const string DEPTH_ONLY_PASS_PATH = "Shaders/ShaderLibrary/AllIn13DShader_URP_DepthOnlyPass.hlsl";
|
||||
public const string DEPTH_NORMALS_PASS_PATH = "Shaders/ShaderLibrary/AllIn13DShader_URP_DepthNormalsPass.hlsl";
|
||||
public const string META_PASS_PATH = "Shaders/ShaderLibrary/AllIn13DShader_URP_MetaPass.hlsl";
|
||||
public const string OUTLINE_PASS_PATH = "Shaders/ShaderLibrary/AllIn13DShader_OutlinePass.hlsl";
|
||||
|
||||
public const string BIRP_HELPER_PATH = "Shaders/ShaderLibrary/AllIn13DShaderHelper_BIRP.hlsl";
|
||||
public const string URP_HELPER_PATH = "Shaders/ShaderLibrary/AllIn13DShaderHelper_URP.hlsl";
|
||||
|
||||
//====================================
|
||||
|
||||
public const string KEYWORD_NONE = "NONE";
|
||||
|
||||
//Special Properties
|
||||
public const string MATPROPERTY_RENDERING_MODE = "_RenderPreset";
|
||||
public const string MATPROPERTY_BLEND_SRC = "_BlendSrc";
|
||||
public const string MATPROPERTY_BLEND_DST = "_BlendDst";
|
||||
public const string KEYWORD_ALLIN13D_SURFACE_TRANSPARENT = "_ALLIN13D_SURFACE_TRANSPARENT";
|
||||
|
||||
//Drawers IDs
|
||||
public const string GENERAL_EFFECT_DRAWER_ID = "GENERAL_EFFECT_DRAWER";
|
||||
public const string TRIPLANAR_EFFECT_DRAWER_ID = "TRIPLANAR_EFFECT_DRAWER";
|
||||
public const string COLOR_RAMP_EFFECT_DRAWER_ID = "COLOR_RAMP_EFFECT_DRAWER";
|
||||
public const string OUTLINE_DRAWER_ID = "OUTLINE_DRAWER_ID";
|
||||
public const string TEXTURE_BLENDING_EFFECT_DRAWER_ID = "TEXTURE_BLENDING_EFFECT_DRAWER";
|
||||
public const string NORMAL_MAP_EFFECT_DRAWER_ID = "NORMAL_MAP_EFFECT_DRAWER";
|
||||
|
||||
//Regex
|
||||
public const string REGEX_EFFECT = @"\(EffectID#([\w\s]+),.*GroupID#([\w\s]+)(?:,.*AllowReset#([\w\s]+))?(?:,.*DependentOn#([\w\s]+))?(?:,.*IncompatibleWith#([\w\s]+))?(?:,.*Doc#([\w\s\\\.]+))?(?:,.*CustomDrawer#([\w\s]+))?(?:,.*ExtraPasses#[\s]*\(([\w\s,]+)\))?\)";
|
||||
public const string REGEX_EFFECT_PROPERTY = @"EffectProperty\((.*)\)";
|
||||
//public const string REGEX_EFFECT_PROOPERTY_COMPLETE = @"EffectProperty\(ParentEffect# ([\w\s]+), Keywords\((.*)\)\)";
|
||||
public const string REGEX_EFFECT_PROOPERTY_COMPLETE = @"EffectProperty\(ParentEffect# ([\w\s]+)(?:,.*KeywordsOp# ([\w]+))?(?:,.*IncompatibleWithKws\(([\w]+)\))?, Keywords\((.*)\), AllowReset# ([\w]+)\)";
|
||||
public const string REGEX_PARENT_EFFECT_KEYWORDS = @".*\((.*)\)";
|
||||
public const string REGEX_KEYWORDS_ENUM = @"KeywordEnum\((.*)\)";
|
||||
public const string REGEX_TOGGLE = @"Toggle\((.*)\)";
|
||||
|
||||
//Editor Prefs Keys
|
||||
public const string LAST_TIME_SHADER_PROPERTIES_REBUILT_KEY = "AllIn13DShader_RebuiltTime";
|
||||
public const string LAST_RENDER_PIPELINE_CHECKED_KEY = "AllIn13DShader_LastRenderPipeline";
|
||||
|
||||
//Strings
|
||||
public const string HDR_STR = "HDR";
|
||||
public const string KEYWORD_ENUM_STR = "KeywordEnum";
|
||||
public const string ON_STR = "On";
|
||||
public const string OFF_STR = "Off";
|
||||
public const string DISABLED_ENUM_OPTION_STR = "None";
|
||||
|
||||
//Default Names
|
||||
public const string DEFAULT_NAME_EFFECTS_PROFILE = "EffectsProfile";
|
||||
|
||||
//
|
||||
public const string INCLUDE_LINE_FORMAT = @"#include ""{0}""";
|
||||
public const string DEFINE_LINE_FORMAT = @"#define {0}";
|
||||
|
||||
//Effect IDs
|
||||
public const string EFFECT_ID_TRIPLANAR_MAPPING = "TRIPLANAR_MAPPING";
|
||||
public const string EFFECT_ID_EMISSION = "EMISSION";
|
||||
|
||||
//Effect Group IDs
|
||||
public const string EFFECT_GROUP_ID_UV_EFFECTS = "UVEffects";
|
||||
|
||||
//Main Assembly Name
|
||||
public const string MAIN_ASSEMBLY_NAME = "AllIn13DShaderAssembly.asmdef";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 233adf119f33cfb40b410b4336a90123
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Constants.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 63d2b9e0902c63442b73dc870028b96a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+366
@@ -0,0 +1,366 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
[CustomEditor(typeof(AllIn13DShaderComponent))]
|
||||
[CanEditMultipleObjects]
|
||||
public class AllIn13DShaderComponentCustomEditor : Editor
|
||||
{
|
||||
private PropertiesConfigCollection propertiesConfigCollection;
|
||||
private GlobalConfiguration globalConfiguration;
|
||||
private Texture imageInspector;
|
||||
|
||||
private void RefreshReferences()
|
||||
{
|
||||
propertiesConfigCollection = EditorUtils.FindAsset<ScriptableObject>("PropertiesConfigCollection") as PropertiesConfigCollection;
|
||||
if(propertiesConfigCollection == null)
|
||||
{
|
||||
propertiesConfigCollection = PropertiesConfigCreator.CreateConfig();
|
||||
}
|
||||
|
||||
globalConfiguration = EditorUtils.FindAssetByName<GlobalConfiguration>("GlobalConfiguration");
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
RefreshReferences();
|
||||
|
||||
bool isValidComponents = CheckSelectedComponents();
|
||||
if (!isValidComponents)
|
||||
{
|
||||
EditorUtility.DisplayDialog("Missing Renderer", "Some of the selected game objects have no Renderer component. AllIn13DShaderComponent will be removed", "Ok");
|
||||
return;
|
||||
}
|
||||
|
||||
CheckMaterialReference();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
bool saveAssets = false;
|
||||
|
||||
serializedObject.Update();
|
||||
|
||||
DrawHeaderImage();
|
||||
|
||||
EditorGUI.BeginDisabledGroup(Application.isPlaying);
|
||||
if(GUILayout.Button("Deactivate All Effects"))
|
||||
{
|
||||
ExecuteActionAfterCheck(DeactivateAllEffects);
|
||||
saveAssets = true;
|
||||
}
|
||||
|
||||
if (GUILayout.Button("New Clean Material"))
|
||||
{
|
||||
ExecuteActionAfterCheck(NewCleanMaterial);
|
||||
}
|
||||
|
||||
if(GUILayout.Button("Create New Material With Same Properties (SEE DOC)"))
|
||||
{
|
||||
ExecuteActionAfterCheck(MakeCopyMaterial);
|
||||
}
|
||||
|
||||
if(GUILayout.Button("Save Material To Folder (SEE DOC)"))
|
||||
{
|
||||
ExecuteActionAfterCheck(SaveMaterialToFolder);
|
||||
}
|
||||
|
||||
if(GUILayout.Button("Apply Material To All Children"))
|
||||
{
|
||||
ExecuteActionAfterCheck(ApplyMaterialToAllChildren);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Render Material To Image"))
|
||||
{
|
||||
ExecuteActionAfterCheck(RenderMaterialToImage);
|
||||
}
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
|
||||
if (saveAssets)
|
||||
{
|
||||
AssetDatabase.SaveAssets();
|
||||
EditorSceneManager.SaveOpenScenes();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorUtils.DrawThinLine();
|
||||
|
||||
if (GUILayout.Button("Remove Component"))
|
||||
{
|
||||
RemoveComponent();
|
||||
}
|
||||
|
||||
if(GUILayout.Button("Remove Component and Material"))
|
||||
{
|
||||
RemoveComponentAndMaterial();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawHeaderImage()
|
||||
{
|
||||
if(imageInspector == null) imageInspector = AllIn13DShaderConfig.GetInspectorImage();
|
||||
Rect rect = EditorGUILayout.GetControlRect(GUILayout.Height(32));
|
||||
GUI.DrawTexture(rect, imageInspector, ScaleMode.ScaleToFit, true);
|
||||
}
|
||||
|
||||
private void CheckMaterialReference()
|
||||
{
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
{
|
||||
AllIn13DShaderComponent allIn13DShaderComponent = (AllIn13DShaderComponent)targets[i];
|
||||
|
||||
Material currMaterial = allIn13DShaderComponent.currMaterial;
|
||||
if (currMaterial == null || !propertiesConfigCollection.IsAllIn3DShaderMaterial(currMaterial))
|
||||
{
|
||||
Shader shader = GlobalConfiguration.instance.shStandard;
|
||||
//Shader shader = propertiesConfigCollection.shaderPropertiesConfig[0].shader;
|
||||
|
||||
Material oldMaterial = allIn13DShaderComponent.currMaterial;
|
||||
allIn13DShaderComponent.NewCleanMaterial(shader, globalConfiguration.defaultPreset);
|
||||
|
||||
MaterialConverterTool.ApplyConversion(oldMaterial, allIn13DShaderComponent.currMaterial);
|
||||
}
|
||||
}
|
||||
|
||||
EditorUtils.SetDirtyCurrentScene();
|
||||
}
|
||||
|
||||
private void DeactivateAllEffects()
|
||||
{
|
||||
bool successOperation = true;
|
||||
bool selectedComponentsAreValid = CheckSelectedComponents();
|
||||
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
{
|
||||
AllIn13DShaderComponent allIn13DShaderComponent = (AllIn13DShaderComponent)targets[i];
|
||||
successOperation = successOperation && allIn13DShaderComponent.CheckValidComponent();
|
||||
|
||||
Material mat = allIn13DShaderComponent.currMaterial;
|
||||
PropertiesConfig propertiesConfig = propertiesConfigCollection.FindPropertiesConfigByShader(mat.shader);
|
||||
|
||||
List<AllIn13DEffectConfig> effects = propertiesConfig.GetAllEffects();
|
||||
|
||||
for (int j = 0; j < effects.Count; j++)
|
||||
{
|
||||
mat.SetFloat(effects[j].keywordPropertyName, 0f);
|
||||
}
|
||||
|
||||
EditorUtility.SetDirty(allIn13DShaderComponent);
|
||||
EditorUtility.SetDirty(mat);
|
||||
}
|
||||
}
|
||||
|
||||
private void NewCleanMaterial()
|
||||
{
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
{
|
||||
AllIn13DShaderComponent allIn13DShaderComponent = (AllIn13DShaderComponent)targets[i];
|
||||
|
||||
Shader shader = GlobalConfiguration.instance.shStandard;
|
||||
//Shader shader = propertiesConfigCollection.shaderPropertiesConfig[0].shader;
|
||||
allIn13DShaderComponent.NewCleanMaterial(shader, globalConfiguration.defaultPreset);
|
||||
}
|
||||
}
|
||||
|
||||
public void MakeCopyMaterial()
|
||||
{
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
{
|
||||
AllIn13DShaderComponent allIn13DShaderComponent = (AllIn13DShaderComponent)targets[i];
|
||||
|
||||
Renderer currRenderer = allIn13DShaderComponent.currRenderer;
|
||||
Material currMat = currRenderer.sharedMaterial;
|
||||
|
||||
string materialName = "MAT_" + allIn13DShaderComponent.gameObject.name;
|
||||
Material copy = new Material(currMat);
|
||||
copy.name = materialName;
|
||||
|
||||
currRenderer.sharedMaterial = copy;
|
||||
|
||||
EditorUtility.SetDirty(allIn13DShaderComponent);
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveMaterialToFolder()
|
||||
{
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
{
|
||||
AllIn13DShaderComponent allIn13DShaderComponent = (AllIn13DShaderComponent)targets[i];
|
||||
SaveMaterialToFolder(allIn13DShaderComponent);
|
||||
}
|
||||
|
||||
EditorUtils.SetDirtyCurrentScene();
|
||||
}
|
||||
|
||||
private bool CheckSelectedComponents()
|
||||
{
|
||||
bool res = true;
|
||||
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
{
|
||||
AllIn13DShaderComponent allIn13DShaderComponent = (AllIn13DShaderComponent)targets[i];
|
||||
|
||||
bool isValid = allIn13DShaderComponent.CheckValidComponent();
|
||||
if (!isValid)
|
||||
{
|
||||
DestroyImmediate(allIn13DShaderComponent);
|
||||
}
|
||||
|
||||
res = res && isValid;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private void ExecuteActionAfterCheck(Action action)
|
||||
{
|
||||
bool selectedComponentsAreValid = CheckSelectedComponents();
|
||||
|
||||
if (selectedComponentsAreValid)
|
||||
{
|
||||
action();
|
||||
}
|
||||
else
|
||||
{
|
||||
SceneView.lastActiveSceneView.ShowNotification(new GUIContent("Some of the selected components are not valid"));
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveMaterialToFolder(AllIn13DShaderComponent comp)
|
||||
{
|
||||
Material matToSave = comp.currMaterial;
|
||||
bool isAlreadySaved = AssetDatabase.Contains(matToSave);
|
||||
if (isAlreadySaved)
|
||||
{
|
||||
matToSave = comp.DuplicateCurrentMaterial();
|
||||
}
|
||||
|
||||
string folderPath = GlobalConfiguration.instance.MaterialSavePath;
|
||||
if (!Directory.Exists(folderPath))
|
||||
{
|
||||
bool ok = EditorUtility.DisplayDialog("The desired save folder doesn't exist",
|
||||
"Go to Window -> AllIn13DShaderWindow and set a valid folder", "Set default values and save material", "Cancel");
|
||||
|
||||
if (ok)
|
||||
{
|
||||
Directory.CreateDirectory(folderPath);
|
||||
}
|
||||
}
|
||||
|
||||
if (Directory.Exists(folderPath))
|
||||
{
|
||||
string fullPath = Path.Combine(folderPath, matToSave.name + ".mat");
|
||||
fullPath = AssetDatabase.GenerateUniqueAssetPath(fullPath);
|
||||
|
||||
AssetDatabase.CreateAsset(matToSave, fullPath);
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
EditorGUIUtility.PingObject(matToSave);
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyMaterialToAllChildren()
|
||||
{
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
{
|
||||
AllIn13DShaderComponent allIn13DShaderComponent = (AllIn13DShaderComponent)targets[i];
|
||||
allIn13DShaderComponent.ApplyMaterialToChildren();
|
||||
|
||||
EditorUtility.SetDirty(allIn13DShaderComponent);
|
||||
}
|
||||
|
||||
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
|
||||
}
|
||||
|
||||
private void RenderMaterialToImage()
|
||||
{
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
{
|
||||
AllIn13DShaderComponent allIn13DShaderComponent = (AllIn13DShaderComponent)targets[i];
|
||||
RenderToImage(allIn13DShaderComponent);
|
||||
|
||||
EditorUtility.SetDirty(allIn13DShaderComponent);
|
||||
}
|
||||
}
|
||||
|
||||
public void RenderToImage(AllIn13DShaderComponent allIn13DShaderComponent)
|
||||
{
|
||||
Texture tex = allIn13DShaderComponent.currMaterial.GetTexture("_MainTex");
|
||||
if (tex != null)
|
||||
{
|
||||
string folderPath = GlobalConfiguration.instance.RenderImageSavePath;
|
||||
string fileName = allIn13DShaderComponent.gameObject.name + ".png";
|
||||
RenderMaterialToImageTool.RenderAndSaveTexture(allIn13DShaderComponent.currMaterial, tex, 4.0f, folderPath, fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorUtility.DisplayDialog("No valid target texture found",
|
||||
"All In 1 3DShader component couldn't find a valid Main Texture in this GameObject (" +
|
||||
allIn13DShaderComponent.gameObject.name +
|
||||
"). This means that the material you are using has no Main Texture or that the texture couldn't be reached through the Renderer component you are using." +
|
||||
" Please make sure to have a valid Main Texture in the Material", "Ok");
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoveComponent()
|
||||
{
|
||||
for (int i = targets.Length - 1; i >= 0; i--)
|
||||
{
|
||||
AllIn13DShaderComponent allIn13DShaderComponent = (AllIn13DShaderComponent)targets[i];
|
||||
DestroyImmediate(allIn13DShaderComponent);
|
||||
}
|
||||
|
||||
//EditorUtils.SetDirtyCurrentScene();
|
||||
|
||||
SetSceneDirty();
|
||||
EditorUtils.ShowNotification("AllIn3DShader: Component Removed");
|
||||
}
|
||||
|
||||
private void RemoveComponentAndMaterial()
|
||||
{
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
{
|
||||
AllIn13DShaderComponent allIn13DShaderComponent = (AllIn13DShaderComponent)targets[i];
|
||||
allIn13DShaderComponent.CleanMaterial();
|
||||
}
|
||||
|
||||
for (int i = targets.Length - 1; i >= 0; i--)
|
||||
{
|
||||
AllIn13DShaderComponent allIn13DShaderComponent = (AllIn13DShaderComponent)targets[i];
|
||||
DestroyImmediate(allIn13DShaderComponent);
|
||||
}
|
||||
|
||||
SetSceneDirty();
|
||||
}
|
||||
|
||||
public void SetSceneDirty()
|
||||
{
|
||||
if (!Application.isPlaying) EditorSceneManager.MarkAllScenesDirty();
|
||||
|
||||
//If you get an error here please delete the code block below
|
||||
#if UNITY_2021_2_OR_NEWER
|
||||
var prefabStage = UnityEditor.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage();
|
||||
#else
|
||||
var prefabStage = UnityEditor.Experimental.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage();
|
||||
#endif
|
||||
if (prefabStage != null)
|
||||
{
|
||||
EditorSceneManager.MarkSceneDirty(prefabStage.scene);
|
||||
}
|
||||
|
||||
//Until here
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 445b6f2ff4b09ff4993b2516859d0467
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/CustomEditors/AllIn13DShaderComponentCustomEditor.cs
|
||||
uploadId: 865720
|
||||
+416
@@ -0,0 +1,416 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
[CanEditMultipleObjects]
|
||||
public class AllIn13DShaderMaterialInspector : ShaderGUI
|
||||
{
|
||||
private PropertiesConfigCollection propertiesConfigCollection;
|
||||
|
||||
private PropertiesConfig currentPropertiesConfig;
|
||||
|
||||
private AllIn13DShaderInspectorReferences inspectorReferences;
|
||||
private AbstractEffectDrawer[] drawers;
|
||||
private GlobalPropertiesDrawer globalPropertiesDrawer;
|
||||
private AdvancedPropertiesDrawer advancedPropertiesDrawer;
|
||||
|
||||
private MaterialPresetCollection blendingModeCollection;
|
||||
|
||||
private MaterialProperty matPropertyRenderPreset;
|
||||
private MaterialProperty matPropertyBlendSrc;
|
||||
private MaterialProperty matPropertyBlendDst;
|
||||
private MaterialProperty matPropertyZWrite;
|
||||
|
||||
private int lastRenderQueue;
|
||||
|
||||
private static CommonStyles commonStyles;
|
||||
|
||||
private void RefreshReferences(MaterialEditor materialEditor, MaterialProperty[] properties)
|
||||
{
|
||||
if (inspectorReferences == null)
|
||||
{
|
||||
inspectorReferences = new AllIn13DShaderInspectorReferences();
|
||||
inspectorReferences.Setup(materialEditor, properties);
|
||||
|
||||
if (lastRenderQueue > 0)
|
||||
{
|
||||
for(int i = 0; i < inspectorReferences.targetMatInfos.Length; i++)
|
||||
{
|
||||
inspectorReferences.targetMatInfos[i].mat.renderQueue = lastRenderQueue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (propertiesConfigCollection == null)
|
||||
{
|
||||
string[] guids = AssetDatabase.FindAssets("PropertiesConfigCollection t:PropertiesConfigCollection");
|
||||
if(guids.Length == 0)
|
||||
{
|
||||
Debug.LogWarning("PropertiesConfigCollection not found in the project. Configuring...");
|
||||
this.propertiesConfigCollection = PropertiesConfigCreator.CreateConfig();
|
||||
Debug.LogWarning("AllIn13DShader configured");
|
||||
}
|
||||
else
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(guids[0]);
|
||||
propertiesConfigCollection = AssetDatabase.LoadAssetAtPath<PropertiesConfigCollection>(path);
|
||||
}
|
||||
|
||||
RefreshPropertiesConfig();
|
||||
}
|
||||
|
||||
if (blendingModeCollection == null)
|
||||
{
|
||||
blendingModeCollection = (MaterialPresetCollection)EditorUtils.FindAsset<ScriptableObject>("BlendingModeCollection");
|
||||
}
|
||||
|
||||
CreateDrawers();
|
||||
|
||||
matPropertyRenderPreset = inspectorReferences.matProperties[currentPropertiesConfig.renderPreset];
|
||||
matPropertyBlendSrc = inspectorReferences.matProperties[currentPropertiesConfig.blendSrcIdx];
|
||||
matPropertyBlendDst = inspectorReferences.matProperties[currentPropertiesConfig.blendDstIdx];
|
||||
matPropertyZWrite = inspectorReferences.matProperties[currentPropertiesConfig.zWriteIndex];
|
||||
|
||||
//We ensure that data is refreshed. Sometimes objects are not null but we need to refresh the references
|
||||
inspectorReferences.Setup(materialEditor, properties);
|
||||
|
||||
if(commonStyles == null)
|
||||
{
|
||||
commonStyles = new CommonStyles();
|
||||
}
|
||||
|
||||
RefreshDrawers();
|
||||
}
|
||||
|
||||
private void ResetReferences()
|
||||
{
|
||||
this.propertiesConfigCollection = null;
|
||||
this.currentPropertiesConfig = null;
|
||||
|
||||
inspectorReferences = null;
|
||||
drawers = null;
|
||||
|
||||
globalPropertiesDrawer = null;
|
||||
advancedPropertiesDrawer = null;
|
||||
}
|
||||
|
||||
private void CreateDrawers()
|
||||
{
|
||||
if (propertiesConfigCollection == null ||
|
||||
currentPropertiesConfig == null ||
|
||||
inspectorReferences == null ||
|
||||
drawers == null ||
|
||||
globalPropertiesDrawer == null ||
|
||||
advancedPropertiesDrawer == null)
|
||||
{
|
||||
drawers = new AbstractEffectDrawer[0];
|
||||
|
||||
GeneralEffectDrawer generalEffectDrawer = new GeneralEffectDrawer(inspectorReferences, currentPropertiesConfig);
|
||||
|
||||
EffectProperty mainNormalMapProperty = currentPropertiesConfig.FindEffectProperty("NORMAL_MAP", "_NormalMap");
|
||||
|
||||
TriplanarEffectDrawer triplanarEffectDrawer = new TriplanarEffectDrawer(mainNormalMapProperty, inspectorReferences, currentPropertiesConfig);
|
||||
ColorRampEffectDrawer colorRampEffectDrawer = new ColorRampEffectDrawer(inspectorReferences, currentPropertiesConfig);
|
||||
OutlineEffectDrawer outlineEffectDrawer = new OutlineEffectDrawer(inspectorReferences, currentPropertiesConfig);
|
||||
TextureBlendingEffectDrawer vertexColorEffectDrawer = new TextureBlendingEffectDrawer(mainNormalMapProperty, inspectorReferences, currentPropertiesConfig);
|
||||
NormalMapEffectDrawer normalMapEffectDrawer = new NormalMapEffectDrawer(inspectorReferences, currentPropertiesConfig);
|
||||
|
||||
drawers = new AbstractEffectDrawer[]
|
||||
{
|
||||
generalEffectDrawer,
|
||||
triplanarEffectDrawer,
|
||||
colorRampEffectDrawer,
|
||||
outlineEffectDrawer,
|
||||
vertexColorEffectDrawer,
|
||||
normalMapEffectDrawer
|
||||
};
|
||||
|
||||
advancedPropertiesDrawer = new AdvancedPropertiesDrawer(currentPropertiesConfig.advancedProperties, currentPropertiesConfig.blendSrcIdx, currentPropertiesConfig.blendDstIdx, inspectorReferences);
|
||||
}
|
||||
|
||||
if (globalPropertiesDrawer == null)
|
||||
{
|
||||
globalPropertiesDrawer = new GlobalPropertiesDrawer();
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshDrawers()
|
||||
{
|
||||
for(int i = 0; i < drawers.Length; i++)
|
||||
{
|
||||
drawers[i].Refresh(inspectorReferences);
|
||||
}
|
||||
}
|
||||
|
||||
private AbstractEffectDrawer FindEffectDrawerByID(string drawerID)
|
||||
{
|
||||
AbstractEffectDrawer res = null;
|
||||
|
||||
for (int i = 0; i < drawers.Length; i++)
|
||||
{
|
||||
if (drawers[i].ID == drawerID)
|
||||
{
|
||||
res = drawers[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)
|
||||
{
|
||||
base.AssignNewShaderToMaterial(material, oldShader, newShader);
|
||||
}
|
||||
|
||||
private void RefreshPropertiesConfig()
|
||||
{
|
||||
Shader shader = inspectorReferences.GetShader();
|
||||
currentPropertiesConfig = propertiesConfigCollection.FindPropertiesConfigByShader(shader);
|
||||
|
||||
inspectorReferences.SetOutlineEffect(currentPropertiesConfig);
|
||||
inspectorReferences.SetCastShadowsEffect(currentPropertiesConfig);
|
||||
}
|
||||
|
||||
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
|
||||
{
|
||||
if (inspectorReferences != null && drawers != null)
|
||||
{
|
||||
inspectorReferences.Setup(materialEditor, properties);
|
||||
}
|
||||
|
||||
RefreshReferences(materialEditor, properties);
|
||||
|
||||
commonStyles.InitStyles();
|
||||
|
||||
#if ALLIN13DSHADER_URP
|
||||
bool urpCorrectlyConfigured = URPConfigurator.IsURPCorrectlyConfigured();
|
||||
if (!urpCorrectlyConfigured)
|
||||
{
|
||||
EditorGUILayout.LabelField(CommonMessages.URP_PIPELINE_NOT_ASSIGNED, commonStyles.warningLabel);
|
||||
EditorUtils.DrawButtonLink(CommonMessages.URP_PIPELINE_NOT_ASSIGNED_DOC_LINK);
|
||||
|
||||
GUILayout.Space(50f);
|
||||
}
|
||||
|
||||
EditorGUI.BeginDisabledGroup(!urpCorrectlyConfigured);
|
||||
#endif
|
||||
|
||||
DrawPresetsTabs();
|
||||
DrawAdvancedProperties();
|
||||
DrawGlobalProperties();
|
||||
DrawEffects();
|
||||
|
||||
#if ALLIN13DSHADER_URP
|
||||
EditorGUI.EndDisabledGroup();
|
||||
#endif
|
||||
|
||||
CheckLightmapFlags();
|
||||
bool shaderChanged = false;
|
||||
for (int i = 0; i < inspectorReferences.targetMatInfos.Length; i++)
|
||||
{
|
||||
Material targetMat = inspectorReferences.targetMatInfos[i].mat;
|
||||
|
||||
lastRenderQueue = targetMat.renderQueue;
|
||||
|
||||
if (!inspectorReferences.targetMatInfos[i].IsShaderVariant())
|
||||
{
|
||||
shaderChanged = shaderChanged || MaterialUtils.CheckMaterialShader(targetMat);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
EditorGUILayout.Separator();
|
||||
EditorUtils.DrawLine(Color.grey, 1, 3);
|
||||
|
||||
if (inspectorReferences.AreAllMaterialsShaderGeneric())
|
||||
{
|
||||
if (GUILayout.Button("Bake Shader Keywords"))
|
||||
{
|
||||
for (int i = 0; i < inspectorReferences.targetMatInfos.Length; i++)
|
||||
{
|
||||
string variantName = Selection.objects[i].name;
|
||||
Shader newShader = ShaderVariantCreator.CreateVariantByMaterialInfo(currentPropertiesConfig, inspectorReferences.targetMatInfos[i], variantName);
|
||||
inspectorReferences.targetMatInfos[i].mat.shader = newShader;
|
||||
}
|
||||
//Shader newShader = ShaderVariantCreator.CreateVariantByMaterialInfo(currentPropertiesConfig, inspectorReferences.targetMatInfos[0], variantName);
|
||||
//materialEditor.SetShader(newShader);
|
||||
|
||||
shaderChanged = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GUILayout.Button("Revert To Generic Shader"))
|
||||
{
|
||||
Shader currentShader = inspectorReferences.GetShader();
|
||||
GlobalConfiguration.instance.effectsProfileCollection.RemoveEffectsProfileByShader(currentShader);
|
||||
|
||||
Shader newShader = Shader.Find(Constants.SHADER_FULL_NAME_ALLIN13D);
|
||||
materialEditor.SetShader(newShader);
|
||||
|
||||
shaderChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (shaderChanged)
|
||||
{
|
||||
ResetReferences();
|
||||
}
|
||||
}
|
||||
|
||||
//private void CheckPasses(Material targetMat)
|
||||
//{
|
||||
// if (targetMat.IsKeywordEnabled("_LIGHTMODEL_FASTLIGHTING") || targetMat.IsKeywordEnabled("_LIGHTMODEL_NONE"))
|
||||
// {
|
||||
// targetMat.SetShaderPassEnabled("ForwardAdd", false);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// targetMat.SetShaderPassEnabled("ForwardAdd", true);
|
||||
// }
|
||||
//}
|
||||
|
||||
private void DrawPresetsTabs()
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
string[] texts = blendingModeCollection.CreateStringsArray();
|
||||
|
||||
|
||||
int presetIndex = (int)matPropertyRenderPreset.floatValue;
|
||||
if (presetIndex >= blendingModeCollection.presets.Length)
|
||||
{
|
||||
presetIndex = 1;
|
||||
matPropertyRenderPreset.floatValue = presetIndex;
|
||||
}
|
||||
|
||||
BlendingMode previousPreset = blendingModeCollection[presetIndex];
|
||||
if(previousPreset == null)
|
||||
{
|
||||
previousPreset = blendingModeCollection[0];
|
||||
}
|
||||
|
||||
int newIndex = (int)matPropertyRenderPreset.floatValue;
|
||||
newIndex = GUILayout.SelectionGrid(newIndex, texts, 3, inspectorReferences.tabButtonStyle);
|
||||
matPropertyRenderPreset.floatValue = newIndex;
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
BlendingMode selectedPreset = blendingModeCollection[newIndex];
|
||||
for(int i = 0; i < inspectorReferences.targetMatInfos.Length; i++)
|
||||
{
|
||||
Material targetMat = inspectorReferences.targetMatInfos[i].mat;
|
||||
ApplyMaterialPreset(targetMat, previousPreset, selectedPreset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawAdvancedProperties()
|
||||
{
|
||||
//Security check
|
||||
if (advancedPropertiesDrawer != null)
|
||||
{
|
||||
advancedPropertiesDrawer.Draw();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawGlobalProperties()
|
||||
{
|
||||
globalPropertiesDrawer.Draw(currentPropertiesConfig.singleProperties, inspectorReferences);
|
||||
}
|
||||
|
||||
private void DrawEffects()
|
||||
{
|
||||
int globalEffectIndex = 0;
|
||||
for (int groupIdx = 0; groupIdx < currentPropertiesConfig.effectsGroups.Length; groupIdx++)
|
||||
{
|
||||
EffectGroup effectGroup = currentPropertiesConfig.effectsGroups[groupIdx];
|
||||
if (effectGroup.effects.Length <= 0) { continue; }
|
||||
|
||||
EditorGUILayout.Separator();
|
||||
EditorUtils.DrawLine(Color.grey, 1, 3);
|
||||
GUILayout.Label(effectGroup.DisplayName, inspectorReferences.bigLabelStyle);
|
||||
|
||||
for (int effectIdx = 0; effectIdx < effectGroup.effects.Length; effectIdx++)
|
||||
{
|
||||
AllIn13DEffectConfig effectConfig = effectGroup.effects[effectIdx];
|
||||
|
||||
globalEffectIndex++;
|
||||
|
||||
AbstractEffectDrawer drawer = FindEffectDrawerByID(effectConfig.effectDrawerID);
|
||||
drawer.Draw(currentPropertiesConfig, effectConfig, globalEffectIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckLightmapFlags()
|
||||
{
|
||||
for (int i = 0; i < inspectorReferences.targetMatInfos.Length; i++)
|
||||
{
|
||||
AbstractMaterialInfo matInfo = inspectorReferences.targetMatInfos[i];
|
||||
AllIn13DEffectConfig emissionEffectConfig = propertiesConfigCollection.propertiesConfig.FindEffectConfigByID(Constants.EFFECT_ID_EMISSION);
|
||||
bool emissionEnabled = AllIn13DEffectConfig.IsEffectEnabled(emissionEffectConfig, matInfo);
|
||||
if (emissionEnabled)
|
||||
{
|
||||
matInfo.mat.globalIlluminationFlags = MaterialGlobalIlluminationFlags.BakedEmissive;
|
||||
}
|
||||
else
|
||||
{
|
||||
matInfo.mat.globalIlluminationFlags = MaterialGlobalIlluminationFlags.EmissiveIsBlack;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyMaterialPreset(Material targetMat, BlendingMode previousPresset, BlendingMode newPreset)
|
||||
{
|
||||
matPropertyBlendSrc.floatValue = (float)newPreset.blendSrc;
|
||||
matPropertyBlendDst.floatValue = (float)newPreset.blendDst;
|
||||
matPropertyZWrite.floatValue = newPreset.depthWrite ? 1.0f : 0.0f;
|
||||
|
||||
|
||||
lastRenderQueue = (int)newPreset.renderQueue;
|
||||
targetMat.renderQueue = lastRenderQueue;
|
||||
|
||||
if (previousPresset != newPreset && previousPresset.defaultEnabledEffects != null)
|
||||
{
|
||||
for (int i = 0; i < previousPresset.defaultEnabledEffects.Length; i++)
|
||||
{
|
||||
string effectID = previousPresset.defaultEnabledEffects[i];
|
||||
AllIn13DEffectConfig effectConfig = currentPropertiesConfig.FindEffectConfigByID(effectID);
|
||||
|
||||
for(int matIdx = 0; matIdx < inspectorReferences.targetMatInfos.Length; matIdx++)
|
||||
{
|
||||
AbstractMaterialInfo matInfo = inspectorReferences.targetMatInfos[matIdx];
|
||||
AllIn13DEffectConfig.DisableEffectToggle(effectConfig, inspectorReferences, matInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (newPreset.defaultEnabledEffects != null)
|
||||
{
|
||||
for (int matIdx = 0; matIdx < inspectorReferences.targetMatInfos.Length; matIdx++)
|
||||
{
|
||||
AbstractMaterialInfo matInfo = inspectorReferences.targetMatInfos[matIdx];
|
||||
|
||||
if (newPreset.isTransparent)
|
||||
{
|
||||
matInfo.EnableKeyword(Constants.KEYWORD_ALLIN13D_SURFACE_TRANSPARENT);
|
||||
}
|
||||
else
|
||||
{
|
||||
matInfo.DisableKeyword(Constants.KEYWORD_ALLIN13D_SURFACE_TRANSPARENT);
|
||||
}
|
||||
|
||||
for (int i = 0; i < newPreset.defaultEnabledEffects.Length; i++)
|
||||
{
|
||||
string effectID = newPreset.defaultEnabledEffects[i];
|
||||
AllIn13DEffectConfig effectConfig = currentPropertiesConfig.FindEffectConfigByID(effectID);
|
||||
AllIn13DEffectConfig.EnableEffectToggle(effectConfig, inspectorReferences, matInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57331ffe54816494c92e6b25562e4ed5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/CustomEditors/AllIn13DShaderMaterialInspector.cs
|
||||
uploadId: 865720
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
using UnityEditor;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
[CustomEditor(typeof(AllIn1DepthColoringProperties))]
|
||||
public class AllIn1DepthColoringPropertiesCustomEditor : Editor
|
||||
{
|
||||
private AllIn1DepthColoringProperties depthColoringProperties;
|
||||
|
||||
private DepthColoringPropertiesDrawer drawer;
|
||||
|
||||
private void RefreshDrawer()
|
||||
{
|
||||
depthColoringProperties = (AllIn1DepthColoringProperties)target;
|
||||
|
||||
if (drawer == null)
|
||||
{
|
||||
drawer = new DepthColoringPropertiesDrawer(depthColoringProperties);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
RefreshDrawer();
|
||||
|
||||
drawer.Draw(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 40a4840e946197045b8663f3d968727f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/CustomEditors/AllIn1DepthColoringPropertiesCustomEditor.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,71 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
[CustomEditor(typeof(DepthColoringCamera))]
|
||||
public class DepthColoringCameraCustomEditor : Editor
|
||||
{
|
||||
private SerializedProperty spCam;
|
||||
private SerializedProperty spDepthColoringProperties;
|
||||
|
||||
private AllIn1DepthColoringProperties depthColoringProperties;
|
||||
private DepthColoringPropertiesDrawer depthColoringPropertiesDrawer;
|
||||
|
||||
private DepthColoringCamera depthColoringCamera;
|
||||
|
||||
private bool depthColoringFoldout;
|
||||
|
||||
private void RefreshReferences()
|
||||
{
|
||||
if(spCam == null)
|
||||
{
|
||||
spCam = serializedObject.FindProperty("cam");
|
||||
}
|
||||
|
||||
if(spDepthColoringProperties == null)
|
||||
{
|
||||
spDepthColoringProperties = serializedObject.FindProperty("depthColoringProperties");
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshDepthColoringPropertiesDrawer()
|
||||
{
|
||||
if(depthColoringPropertiesDrawer == null && depthColoringProperties != null)
|
||||
{
|
||||
depthColoringPropertiesDrawer = new DepthColoringPropertiesDrawer(depthColoringProperties);
|
||||
}
|
||||
else if(depthColoringPropertiesDrawer != null && depthColoringProperties != null)
|
||||
{
|
||||
depthColoringPropertiesDrawer.SetDepthColoringProperties(depthColoringProperties);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
RefreshReferences();
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(spCam);
|
||||
EditorGUILayout.PropertyField(spDepthColoringProperties);
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
if(spDepthColoringProperties.objectReferenceValue != null)
|
||||
{
|
||||
GUILayout.Space(25f);
|
||||
|
||||
depthColoringProperties = (AllIn1DepthColoringProperties)spDepthColoringProperties.objectReferenceValue;
|
||||
|
||||
RefreshDepthColoringPropertiesDrawer();
|
||||
|
||||
if(depthColoringPropertiesDrawer != null)
|
||||
{
|
||||
depthColoringPropertiesDrawer.Draw(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f455792fcb55c34d97cd0b478de36ba
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/CustomEditors/DepthColoringCameraCustomEditor.cs
|
||||
uploadId: 865720
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
using UnityEditor;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
[CustomEditor(typeof(EffectsProfileCollection))]
|
||||
public class EffectsProfileCollectionCustomEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df521890445440245b75e88c4fb4bd73
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/CustomEditors/EffectsProfileCollectionCustomEditor.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,13 @@
|
||||
using UnityEditor;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
[CustomEditor(typeof(GlobalConfiguration))]
|
||||
public class GlobalConfigurationCustomEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c57330f81e2eed441862d8a92a0e63cf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/CustomEditors/GlobalConfigurationCustomEditor.cs
|
||||
uploadId: 865720
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
using UnityEditor;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
[CustomEditor(typeof(PropertiesConfigCollection))]
|
||||
public class PropertiesConfigCollectionCustomEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 436434178bc9cbf449485b83a639cdbb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/CustomEditors/PropertiesConfigCollectionCustomEditor.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,14 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
[CustomEditor(typeof(URPSettingsUserPref))]
|
||||
public class URPSettingsUserPrefCustomEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8ff9df7e6f241e844821ae6d61fb8b20
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/CustomEditors/URPSettingsUserPrefCustomEditor.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fb3274d0917f10f4e932549862263caf
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,82 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 32438765f2955064bae29bed18ec5263, type: 3}
|
||||
m_Name: EffectsExtraData
|
||||
m_EditorClassIdentifier:
|
||||
effectsExtraData:
|
||||
- effectID: CUSTOM_SHADOW_COLOR
|
||||
docURL: https://seasidestudios.gitbook.io/seaside-studios/3d-shader/shadow-color
|
||||
customMessages:
|
||||
- message: "*You need to use ShadowsConfigurator.cs component\n in order to use
|
||||
this effect."
|
||||
keywords: []
|
||||
- effectID: DEPTH_COLORING
|
||||
docURL: https://seasidestudios.gitbook.io/seaside-studios/3d-shader/depth-coloring-stylized-fog
|
||||
customMessages:
|
||||
- message: "*You need to add DepthColoringCamera.cs component \nto the main camera
|
||||
in order to use this effect."
|
||||
keywords: []
|
||||
- effectID: LIGHTMODEL
|
||||
docURL: https://seasidestudios.gitbook.io/seaside-studios/3d-shader/fast-lighting
|
||||
customMessages:
|
||||
- message: "*You need to use FastLightConfigurator.cs component\n in order to
|
||||
use this effect."
|
||||
keywords:
|
||||
- _LIGHTMODEL_FASTLIGHTING
|
||||
- effectID: SHADINGMODEL
|
||||
docURL:
|
||||
customMessages:
|
||||
- message: '*Usually looks best paired with a Specular Model'
|
||||
keywords:
|
||||
- _SHADINGMODEL_PBR
|
||||
- effectID: RECALCULATE_NORMALS
|
||||
docURL:
|
||||
customMessages:
|
||||
- message: '*Dynamically reconstructs surface normals from vertex positions,
|
||||
ignoring mesh baked normals'
|
||||
keywords:
|
||||
- _SHADINGMODEL_PBR
|
||||
- effectID: INTERSECTION_GLOW
|
||||
docURL:
|
||||
customMessages:
|
||||
- message: '*You need to set the material to Transparent mode in order to use
|
||||
this effect correctly'
|
||||
keywords: []
|
||||
- effectID: INTERSECTION_FADE
|
||||
docURL:
|
||||
customMessages:
|
||||
- message: '*You need to set the material to Transparent mode in order to use
|
||||
this effect correctly'
|
||||
keywords: []
|
||||
- effectID: OUTLINETYPE
|
||||
docURL:
|
||||
customMessages:
|
||||
- message: '*If the material is transparent, you need to enable Depth Write.
|
||||
Otherwise, the mesh will look completely black
|
||||
|
||||
'
|
||||
keywords:
|
||||
- _OUTLINETYPE_SIMPLE
|
||||
- _OUTLINETYPE_CONSTANT
|
||||
- _OUTLINETYPE_FADEWITHDISTANCE
|
||||
- effectID: WIND
|
||||
docURL: https://seasidestudios.gitbook.io/seaside-studios/3d-shader/wind-effect-and-wind-controller
|
||||
customMessages:
|
||||
- message: "*You need to use WindController.cs component\n in order to use this
|
||||
effect."
|
||||
keywords: []
|
||||
- effectID: RECEIVE_SHADOWS
|
||||
docURL: https://seasidestudios.gitbook.io/seaside-studios/3d-shader/receive-shadows-and-stylized-shadows
|
||||
customMessages:
|
||||
- message: "*Additional lights will not be \naffected by this effect"
|
||||
keywords:
|
||||
- _RECEIVEDSHADOWSTYPE_STYLIZED
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab04b85ae78a31642964fa2facafc08b
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Data/EffectsExtraData.asset
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 20260d74bdf7b1543992369a55b37761
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5d4677818a6699f4c951378b8bbde688, type: 3}
|
||||
m_Name: EffectGroupGlobalConfigCollection
|
||||
m_EditorClassIdentifier:
|
||||
effectGroupGlobalConfigs:
|
||||
- {fileID: 11400000, guid: 05a6bce58cfc83a4293b054fcfc62a81, type: 2}
|
||||
- {fileID: 11400000, guid: fcdc7c904b0215f4aabfa8ced0068841, type: 2}
|
||||
- {fileID: 11400000, guid: d45649322d809684a8f280736df5ebc7, type: 2}
|
||||
- {fileID: 11400000, guid: 987f969d8d3fec24bbb35df7779ba52b, type: 2}
|
||||
- {fileID: 11400000, guid: 2f3fcb0996a83b64599ce17553aa6b13, type: 2}
|
||||
- {fileID: 11400000, guid: d29aa9c55e3576d4bad55ec71545fe82, type: 2}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0906b01f0f78cfc4dad64f8257ffaf66
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Data/EffectsGroups/EffectGroupGlobalConfigCollection.asset
|
||||
uploadId: 865720
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 6b755efcb87425049878cf9532c736c7, type: 3}
|
||||
m_Name: EffectGroup_AlphaEffects
|
||||
m_EditorClassIdentifier:
|
||||
groupID: AlphaEffects
|
||||
displayName: Alpha Effects
|
||||
libraryFileName: AllIn13DShader_AlphaEffects
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d45649322d809684a8f280736df5ebc7
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Data/EffectsGroups/EffectGroup_AlphaEffects.asset
|
||||
uploadId: 865720
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 6b755efcb87425049878cf9532c736c7, type: 3}
|
||||
m_Name: EffectGroup_ColorEffects
|
||||
m_EditorClassIdentifier:
|
||||
groupID: ColorEffects
|
||||
displayName: Color Effects
|
||||
libraryFileName: AllIn13DShader_FragmentEffects
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fcdc7c904b0215f4aabfa8ced0068841
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Data/EffectsGroups/EffectGroup_ColorEffects.asset
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,17 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 6b755efcb87425049878cf9532c736c7, type: 3}
|
||||
m_Name: EffectGroup_Lighting
|
||||
m_EditorClassIdentifier:
|
||||
groupID: Lighting
|
||||
displayName: Lighting
|
||||
libraryFileName:
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 05a6bce58cfc83a4293b054fcfc62a81
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Data/EffectsGroups/EffectGroup_Lighting.asset
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,17 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 6b755efcb87425049878cf9532c736c7, type: 3}
|
||||
m_Name: EffectGroup_MeshEffects
|
||||
m_EditorClassIdentifier:
|
||||
groupID: MeshEffects
|
||||
displayName: Mesh Effects
|
||||
libraryFileName: AllIn13DShader_VertexEffects
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 987f969d8d3fec24bbb35df7779ba52b
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Data/EffectsGroups/EffectGroup_MeshEffects.asset
|
||||
uploadId: 865720
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 6b755efcb87425049878cf9532c736c7, type: 3}
|
||||
m_Name: EffectGroup_OtherEffects
|
||||
m_EditorClassIdentifier:
|
||||
groupID: OtherEffects
|
||||
displayName: Other Effects
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d29aa9c55e3576d4bad55ec71545fe82
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Data/EffectsGroups/EffectGroup_OtherEffects.asset
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,17 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 6b755efcb87425049878cf9532c736c7, type: 3}
|
||||
m_Name: EffectGroup_UVEffects
|
||||
m_EditorClassIdentifier:
|
||||
groupID: UVEffects
|
||||
displayName: UV Effects
|
||||
libraryFileName: AllIn13DShader_UVEffects
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2f3fcb0996a83b64599ce17553aa6b13
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Data/EffectsGroups/EffectGroup_UVEffects.asset
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8da84111dbb07224ab02fcbcd7ad8a4c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,102 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class AdvancedPropertiesDrawer
|
||||
{
|
||||
private List<int> advancedPropertiesIndices;
|
||||
private int blendSrcIndex;
|
||||
private int blendDstIndex;
|
||||
|
||||
private AllIn13DShaderInspectorReferences references;
|
||||
|
||||
private MaterialProperty advancedPropertiesEnabledMatProperty;
|
||||
|
||||
private bool AdvancedPropertiesEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
bool res = advancedPropertiesEnabledMatProperty.floatValue > 0;
|
||||
return res;
|
||||
}
|
||||
set
|
||||
{
|
||||
float floatValue = value ? 1.0f : 0f;
|
||||
advancedPropertiesEnabledMatProperty.floatValue = floatValue;
|
||||
}
|
||||
}
|
||||
|
||||
public AdvancedPropertiesDrawer(List<int> advancedPropertiesIndices, int blendSrcIndex, int blendDstIndex, AllIn13DShaderInspectorReferences references)
|
||||
{
|
||||
this.advancedPropertiesIndices = advancedPropertiesIndices;
|
||||
this.blendSrcIndex = blendSrcIndex;
|
||||
this.blendDstIndex = blendDstIndex;
|
||||
|
||||
this.references = references;
|
||||
|
||||
advancedPropertiesEnabledMatProperty = references.matProperties[advancedPropertiesIndices[0]];
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
AdvancedPropertiesEnabled = GUILayout.Toggle(AdvancedPropertiesEnabled, new GUIContent("Show Advanced Configuration"), references.toggleButtonStyle);
|
||||
if (AdvancedPropertiesEnabled)
|
||||
{
|
||||
EditorGUILayout.BeginVertical(references.propertiesStyle);
|
||||
|
||||
MaterialProperty matPropertyBlendSrc = references.matProperties[blendSrcIndex];
|
||||
MaterialProperty matProeprtyBlendDst = references.matProperties[blendDstIndex];
|
||||
|
||||
EffectPropertyDrawer.DrawProperty(
|
||||
materialProperty: matPropertyBlendSrc,
|
||||
labelPrefix: string.Empty,
|
||||
displayName: matPropertyBlendSrc.displayName,
|
||||
customValue: string.Empty,
|
||||
allowReset: false,
|
||||
isKeywordProperty: false,
|
||||
propertyType: EffectProperty.PropertyType.BASIC,
|
||||
references);
|
||||
|
||||
EffectPropertyDrawer.DrawProperty(
|
||||
materialProperty: matProeprtyBlendDst,
|
||||
labelPrefix: string.Empty,
|
||||
displayName: matProeprtyBlendDst.displayName,
|
||||
customValue: string.Empty,
|
||||
allowReset: false,
|
||||
isKeywordProperty: false,
|
||||
propertyType: EffectProperty.PropertyType.BASIC,
|
||||
references);
|
||||
|
||||
EditorUtils.DrawThinLine();
|
||||
|
||||
for (int i = 1; i < advancedPropertiesIndices.Count; i++)
|
||||
{
|
||||
//if(i == blendSrcIndex || i == blendDstIndex) { continue; }
|
||||
MaterialProperty matProperty = references.matProperties[advancedPropertiesIndices[i]];
|
||||
EffectPropertyDrawer.DrawProperty(
|
||||
materialProperty: matProperty,
|
||||
labelPrefix: string.Empty,
|
||||
displayName: matProperty.displayName,
|
||||
customValue: string.Empty,
|
||||
allowReset: false,
|
||||
isKeywordProperty: false,
|
||||
propertyType: EffectProperty.PropertyType.BASIC,
|
||||
references: references);
|
||||
|
||||
EditorUtils.DrawThinLine();
|
||||
}
|
||||
|
||||
references.editorMat.EnableInstancingField();
|
||||
|
||||
Rect rect = EditorGUILayout.GetControlRect();
|
||||
rect.x += 3f;
|
||||
rect.width -= 3f;
|
||||
references.editorMat.RenderQueueField(rect);
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4877ef4771a6497458bd45402be12188
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Drawers/AdvancedPropertiesDrawer.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,130 @@
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class AtlasPackerDrawer
|
||||
{
|
||||
private AtlasPackerTool atlasPackerTool;
|
||||
|
||||
public AtlasPackerValues ToolValues => atlasPackerTool.values;
|
||||
|
||||
private CommonStyles commonStyles;
|
||||
private SerializedObject soAtlasPackerValues;
|
||||
|
||||
public AtlasPackerDrawer(AtlasPackerTool atlasPackerTool, CommonStyles commonStyles)
|
||||
{
|
||||
this.atlasPackerTool = atlasPackerTool;
|
||||
this.commonStyles = commonStyles;
|
||||
|
||||
RefreshAtlasPackerValues();
|
||||
}
|
||||
|
||||
private void RefreshAtlasPackerValues()
|
||||
{
|
||||
soAtlasPackerValues = new SerializedObject(ToolValues);
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
soAtlasPackerValues.Update();
|
||||
|
||||
if (ToolValues == null)
|
||||
{
|
||||
RefreshAtlasPackerValues();
|
||||
}
|
||||
|
||||
GUILayout.Label("Texture Atlas / Spritesheet Packer", commonStyles.bigLabel);
|
||||
GUILayout.Space(20);
|
||||
GUILayout.Label("Add Textures to the Atlas array", EditorStyles.boldLabel);
|
||||
|
||||
|
||||
SerializedProperty atlasProperty = soAtlasPackerValues.FindProperty("atlas");
|
||||
EditorGUILayout.PropertyField(atlasProperty, true, GUILayout.MaxWidth(200));
|
||||
soAtlasPackerValues.ApplyModifiedProperties();
|
||||
|
||||
//ToolValues.atlas = Atlas;
|
||||
|
||||
ToolValues.squareAtlas = EditorGUILayout.Toggle("Square Atlas?", ToolValues.squareAtlas, GUILayout.MaxWidth(200));
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
if (ToolValues.squareAtlas)
|
||||
{
|
||||
ToolValues.atlasXCount = EditorGUILayout.IntSlider("Column and Row Count", ToolValues.atlasXCount, 1, 8, GUILayout.MaxWidth(302));
|
||||
ToolValues.atlasYCount = ToolValues.atlasXCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
ToolValues.atlasXCount = EditorGUILayout.IntSlider("Column Count", ToolValues.atlasXCount, 1, 8, GUILayout.MaxWidth(302));
|
||||
GUILayout.Space(10);
|
||||
ToolValues.atlasYCount = EditorGUILayout.IntSlider("Row Count", ToolValues.atlasYCount, 1, 8, GUILayout.MaxWidth(302));
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
if (ToolValues.squareAtlas)
|
||||
{
|
||||
GUILayout.Label("Atlas Size:", GUILayout.MaxWidth(100));
|
||||
ToolValues.atlasSizesX = (TextureSizes)EditorGUILayout.EnumPopup(ToolValues.atlasSizesX, GUILayout.MaxWidth(200));
|
||||
ToolValues.atlasSizesY = ToolValues.atlasSizesX;
|
||||
}
|
||||
else
|
||||
{
|
||||
GUILayout.Label("Atlas Size X:", GUILayout.MaxWidth(100));
|
||||
ToolValues.atlasSizesX = (TextureSizes)EditorGUILayout.EnumPopup(ToolValues.atlasSizesX, GUILayout.MaxWidth(200));
|
||||
GUILayout.Space(10);
|
||||
GUILayout.Label("Atlas Size Y:", GUILayout.MaxWidth(100));
|
||||
ToolValues.atlasSizesY = (TextureSizes)EditorGUILayout.EnumPopup(ToolValues.atlasSizesY, GUILayout.MaxWidth(200));
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Label("Atlas Filtering: ", GUILayout.MaxWidth(100));
|
||||
ToolValues.atlasFiltering = (FilterMode)EditorGUILayout.EnumPopup(ToolValues.atlasFiltering, GUILayout.MaxWidth(200));
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
int atlasElements = atlasPackerTool.GetAtlasElements();
|
||||
int atlasWidth = (int)ToolValues.atlasSizesX;
|
||||
int atlasHeight = (int)ToolValues.atlasSizesY;
|
||||
GUILayout.Label("Output will be a " + ToolValues.atlasXCount + " X " + ToolValues.atlasYCount + " atlas, " + atlasElements + " elements in total. In a " +
|
||||
atlasWidth + "pixels X " + atlasHeight + "pixels texture", EditorStyles.boldLabel);
|
||||
|
||||
int usedAtlasSlots = 0;
|
||||
for (int i = 0; i < ToolValues.atlas.Length; i++)
|
||||
{
|
||||
if (ToolValues.atlas[i] != null)
|
||||
{
|
||||
usedAtlasSlots++;
|
||||
}
|
||||
}
|
||||
if (usedAtlasSlots > atlasElements)
|
||||
{
|
||||
GUILayout.Label("*Please reduce the Atlas texture slots by " + Mathf.Abs(atlasElements - ToolValues.atlas.Length) + " (extra textures will be ignored)", EditorStyles.boldLabel);
|
||||
}
|
||||
|
||||
if (atlasElements > usedAtlasSlots)
|
||||
{
|
||||
GUILayout.Label("*" + (atlasElements - usedAtlasSlots) + " atlas slots unused or null (it will be filled with black)", EditorStyles.boldLabel);
|
||||
}
|
||||
|
||||
GUILayout.Space(20);
|
||||
GUILayout.Label("Select the folder where new Atlases will be saved", EditorStyles.boldLabel);
|
||||
GlobalConfiguration.instance.AtlasesSavePath = EditorUtils.DrawSelectorFolder(GlobalConfiguration.instance.AtlasesSavePath, /*AllIn13DShaderConfig.ATLASES_SAVE_PATH_DEFAULT,*/ "Atlas");
|
||||
|
||||
|
||||
if (Directory.Exists(GlobalConfiguration.instance.AtlasesSavePath))
|
||||
{
|
||||
if (GUILayout.Button("Create And Save Atlas Texture", GUILayout.MaxWidth(CommonStyles.BUTTON_WIDTH)))
|
||||
{
|
||||
atlasPackerTool.CreateAtlas();
|
||||
EditorUtils.SaveTextureAsPNG(GlobalConfiguration.instance.AtlasesSavePath, "Atlas", "Texture Atlas", ToolValues.createdAtlas, ToolValues.atlasFiltering, TextureImporterType.Default, TextureWrapMode.Clamp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dca812f5788e4cb49942f0cb9072a9d3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Drawers/AtlasPackerDrawer.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,76 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class CommonStyles
|
||||
{
|
||||
public const int BUTTON_WIDTH = 600;
|
||||
public const int BIG_FONT_SIZE = 16;
|
||||
|
||||
public GUIStyle shaderPropertiesStyle;
|
||||
public GUIStyle wordWrappedStyle;
|
||||
public GUIStyle style;
|
||||
public GUIStyle bigLabel;
|
||||
public GUIStyle warningLabel;
|
||||
public GUIStyle okLabel;
|
||||
public GUIStyle linkStyle;
|
||||
public GUIStyle boxStyle;
|
||||
|
||||
public void InitStyles()
|
||||
{
|
||||
if(wordWrappedStyle == null)
|
||||
{
|
||||
wordWrappedStyle = new GUIStyle(EditorStyles.largeLabel);
|
||||
wordWrappedStyle.wordWrap = true;
|
||||
}
|
||||
|
||||
if(style == null)
|
||||
{
|
||||
style = new GUIStyle(EditorStyles.helpBox);
|
||||
style.margin = new RectOffset(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
if(bigLabel == null)
|
||||
{
|
||||
bigLabel = new GUIStyle(EditorStyles.boldLabel);
|
||||
bigLabel.fontSize = BIG_FONT_SIZE;
|
||||
}
|
||||
|
||||
if(okLabel == null)
|
||||
{
|
||||
okLabel = new GUIStyle(EditorStyles.label);
|
||||
okLabel.fontSize = BIG_FONT_SIZE;
|
||||
okLabel.normal.textColor = Color.green;
|
||||
okLabel.wordWrap = true;
|
||||
okLabel.richText = true;
|
||||
}
|
||||
|
||||
if(warningLabel == null)
|
||||
{
|
||||
warningLabel = new GUIStyle(EditorStyles.label);
|
||||
warningLabel.fontSize = BIG_FONT_SIZE;
|
||||
warningLabel.normal.textColor = Color.yellow;
|
||||
warningLabel.wordWrap = true;
|
||||
warningLabel.richText = true;
|
||||
}
|
||||
|
||||
if(linkStyle == null)
|
||||
{
|
||||
linkStyle = new GUIStyle(EditorStyles.linkLabel);
|
||||
}
|
||||
|
||||
if(boxStyle == null)
|
||||
{
|
||||
boxStyle = new GUIStyle(EditorStyles.helpBox);
|
||||
boxStyle.margin = new RectOffset(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
if(shaderPropertiesStyle == null)
|
||||
{
|
||||
shaderPropertiesStyle = new GUIStyle(EditorStyles.helpBox);
|
||||
shaderPropertiesStyle.margin = new RectOffset(25, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aba3dca1c691c3b4891e7a7e67ad55dc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Drawers/CommonStyles.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,111 @@
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class DepthColoringPropertiesDrawer
|
||||
{
|
||||
private AllIn1DepthColoringProperties depthColoringProperties;
|
||||
|
||||
private CommonStyles commonStyles;
|
||||
|
||||
private GradientEditorDrawer gradientDrawer;
|
||||
|
||||
private DepthColoringCamera depthColoringCamera;
|
||||
private bool isActive;
|
||||
|
||||
public DepthColoringPropertiesDrawer(AllIn1DepthColoringProperties depthColoringProperties)
|
||||
{
|
||||
SetDepthColoringProperties(depthColoringProperties);
|
||||
}
|
||||
|
||||
public void SetDepthColoringProperties(AllIn1DepthColoringProperties depthColoringProperties)
|
||||
{
|
||||
this.depthColoringProperties = depthColoringProperties;
|
||||
}
|
||||
|
||||
private void RefreshReferences()
|
||||
{
|
||||
if (gradientDrawer == null)
|
||||
{
|
||||
gradientDrawer = new GradientEditorDrawer();
|
||||
}
|
||||
|
||||
if (commonStyles == null)
|
||||
{
|
||||
commonStyles = new CommonStyles();
|
||||
commonStyles.InitStyles();
|
||||
}
|
||||
|
||||
if(depthColoringCamera == null)
|
||||
{
|
||||
depthColoringCamera = GameObject.FindFirstObjectByType<DepthColoringCamera>();
|
||||
}
|
||||
}
|
||||
|
||||
public void Draw(bool useBoxStyle = false)
|
||||
{
|
||||
RefreshReferences();
|
||||
|
||||
if (useBoxStyle)
|
||||
{
|
||||
EditorGUILayout.BeginVertical(commonStyles.boxStyle);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.BeginVertical();
|
||||
}
|
||||
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
Rect rect = EditorGUILayout.GetControlRect(true, gradientDrawer.GetPropertyHeight());
|
||||
|
||||
depthColoringProperties.depthColoringGradientTex = (Texture2D)gradientDrawer.Draw(rect, depthColoringProperties.depthColoringGradientTex);
|
||||
depthColoringProperties.depthZoneLength = EditorGUILayout.FloatField("Depth Zone Length", depthColoringProperties.depthZoneLength);
|
||||
depthColoringProperties.depthColoringMinDepth = EditorGUILayout.FloatField("Depth Min", depthColoringProperties.depthColoringMinDepth);
|
||||
depthColoringProperties.fallOff = EditorGUILayout.Slider("Fall Off", depthColoringProperties.fallOff, 0.1f, 1.5f);
|
||||
|
||||
GUILayout.Space(20f);
|
||||
if (depthColoringCamera == null)
|
||||
{
|
||||
EditorGUILayout.LabelField("Depth coloring camera not found in the scene. You need to add DepthColoringCamera.cs component to the main camera in order to use this effect.", commonStyles.warningLabel);
|
||||
isActive = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
isActive = depthColoringCamera.depthColoringProperties == depthColoringProperties;
|
||||
|
||||
if (isActive)
|
||||
{
|
||||
EditorGUILayout.LabelField("Active", commonStyles.okLabel);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.LabelField("This properties are not active", commonStyles.warningLabel);
|
||||
if (GUILayout.Button("Active"))
|
||||
{
|
||||
depthColoringCamera.depthColoringProperties = depthColoringProperties;
|
||||
isActive = true;
|
||||
|
||||
EditorUtils.SetDirtyCurrentScene();
|
||||
}
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
if (EditorGUI.EndChangeCheck() && isActive)
|
||||
{
|
||||
ApplyChanges();
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyChanges()
|
||||
{
|
||||
EditorUtility.SetDirty(depthColoringProperties);
|
||||
|
||||
depthColoringProperties.ApplyValues();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 605016f1af959104f98b4f8873abe8e0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Drawers/DepthColoringPropertiesDrawer.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 377339d02577eb24793e9b80a10ae599
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,339 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public abstract class AbstractEffectDrawer
|
||||
{
|
||||
private const float HEIGHT_PER_LINE = 12.5f;
|
||||
|
||||
protected string drawerID;
|
||||
protected PropertiesConfig propertiesConfig;
|
||||
protected AllIn13DEffectConfig effectConfig;
|
||||
protected AllIn13DShaderInspectorReferences references;
|
||||
protected int globalEffectIndex;
|
||||
|
||||
public string ID
|
||||
{
|
||||
get
|
||||
{
|
||||
return drawerID;
|
||||
}
|
||||
}
|
||||
|
||||
public AbstractEffectDrawer(AllIn13DShaderInspectorReferences references, PropertiesConfig propertiesConfig)
|
||||
{
|
||||
this.references = references;
|
||||
this.propertiesConfig = propertiesConfig;
|
||||
}
|
||||
|
||||
public void Draw(PropertiesConfig propertiesConfig, AllIn13DEffectConfig effectConfig, int globalEffectIndex)
|
||||
{
|
||||
this.propertiesConfig = propertiesConfig;
|
||||
this.effectConfig = effectConfig;
|
||||
this.globalEffectIndex = globalEffectIndex;
|
||||
|
||||
Draw();
|
||||
}
|
||||
|
||||
protected virtual void Draw()
|
||||
{
|
||||
bool isShaderVariant = references.IsShaderVariant();
|
||||
bool areDependenciesMet = AreDependenciesMet();
|
||||
bool isEffectAvailableOnGlobalConfig = references.effectsProfileCollection.generalProfile.IsEffectEnabled(effectConfig.effectName);
|
||||
bool isEffectAvailable = AllIn13DEffectConfig.IsEffectAvailable(effectConfig, references);
|
||||
|
||||
bool groupEnabled = isEffectAvailable;
|
||||
if (!isShaderVariant)
|
||||
{
|
||||
groupEnabled = groupEnabled && areDependenciesMet && isEffectAvailableOnGlobalConfig;
|
||||
}
|
||||
//bool groupEnabled = areDependenciesMet && isEffectAvailable && isEffectAvailableOnGlobalConfig /*|| (references.isShaderVariant && isEnabledInEffectsProfile)*/;
|
||||
|
||||
//bool disableGroup = !groupEnabled;
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUI.BeginDisabledGroup(!groupEnabled);
|
||||
EffectPropertyDrawer.DrawMainProperty(globalEffectIndex, effectConfig, references, isEffectAvailable, isEffectAvailableOnGlobalConfig);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
bool isAnyPropertyVisible = IsAnyPropertyVisible();
|
||||
|
||||
if (isAnyPropertyVisible)
|
||||
{
|
||||
EditorGUILayout.BeginVertical(references.propertiesStyle);
|
||||
DrawExtraData();
|
||||
DrawProperties();
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
|
||||
private void DrawExtraData()
|
||||
{
|
||||
if (IsParentPropertyEnabled())
|
||||
{
|
||||
string customMessage = effectConfig.GetCustomMessage(references.targetMatInfos);
|
||||
if (!string.IsNullOrEmpty(customMessage))
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
|
||||
int numLines = EditorUtils.GetNumLines(customMessage);
|
||||
float heightField = numLines * HEIGHT_PER_LINE;
|
||||
|
||||
if (!string.IsNullOrEmpty(effectConfig.docURL))
|
||||
{
|
||||
if (GUILayout.Button("?", GUILayout.Width(heightField), GUILayout.Height(heightField)))
|
||||
{
|
||||
Application.OpenURL(effectConfig.docURL);
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.LabelField(customMessage, references.smallLabelStyle, GUILayout.Height(heightField));
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void DrawProperties()
|
||||
{
|
||||
for (int i = 0; i < effectConfig.effectProperties.Count; i++)
|
||||
{
|
||||
EffectProperty effectProperty = effectConfig.effectProperties[i];
|
||||
DrawProperty(effectProperty, string.Empty, true);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void DrawProperty(EffectProperty effectProperty)
|
||||
{
|
||||
DrawProperty(effectProperty, true);
|
||||
}
|
||||
|
||||
protected virtual void DrawProperty(EffectProperty effectProperty, bool allowReset)
|
||||
{
|
||||
DrawProperty(effectProperty, string.Empty, allowReset);
|
||||
}
|
||||
|
||||
protected virtual void DrawProperty(EffectProperty effectProperty, string labelPrefix, bool allowReset)
|
||||
{
|
||||
if (IsEffectPropertyVisible(effectProperty, references.targetMatInfos))
|
||||
{
|
||||
EffectProperty.PropertyType propertyType = effectProperty.GetPropertyType();
|
||||
MaterialProperty matProperty = references.matProperties[effectProperty.propertyIndex];
|
||||
|
||||
string propertyCustomValue = string.Empty;
|
||||
if(references.IsShaderVariant() && effectProperty.IsPropertyWithKeywords())
|
||||
{
|
||||
int index = 0;
|
||||
bool isEnabled = references.IsEffectPropertyEnabled(effectProperty, ref index);
|
||||
|
||||
if (isEnabled)
|
||||
{
|
||||
if (effectProperty.IsEnumProperty())
|
||||
{
|
||||
propertyCustomValue = effectProperty.propertyKeywords[index];
|
||||
}
|
||||
else
|
||||
{
|
||||
propertyCustomValue = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EffectPropertyDrawer.DrawProperty(
|
||||
materialProperty: matProperty,
|
||||
labelPrefix: labelPrefix,
|
||||
displayName: effectProperty.displayName,
|
||||
customValue: propertyCustomValue,
|
||||
allowReset: allowReset,
|
||||
isKeywordProperty: effectProperty.IsPropertyWithKeywords(),
|
||||
propertyType: effectProperty.GetPropertyType(),
|
||||
references: references);
|
||||
|
||||
//EffectPropertyDrawer.DrawProperty(effectProperty, labelPrefix, effectProperty.displayName, allowReset, effectProperty.IsPropertyWithKeywords(), references);
|
||||
//EffectPropertyDrawer.DrawProperty(effectProperty, labelPrefix, allowReset, references);
|
||||
}
|
||||
}
|
||||
|
||||
protected bool IsParentPropertyEnabled()
|
||||
{
|
||||
bool res = true;
|
||||
|
||||
for (int matIdx = 0; matIdx < references.targetMatInfos.Length; matIdx++)
|
||||
{
|
||||
AbstractMaterialInfo targetMatInfo = references.targetMatInfos[matIdx];
|
||||
|
||||
bool thisMatParentPropertyEnabled = false;
|
||||
for (int kwIdx = 0; kwIdx < effectConfig.keywords.Count; kwIdx++)
|
||||
{
|
||||
string kw = effectConfig.keywords[kwIdx].keyword;
|
||||
if (targetMatInfo.IsKeywordEnabled(kw))
|
||||
{
|
||||
thisMatParentPropertyEnabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
res = res && thisMatParentPropertyEnabled;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
protected bool IsAnyPropertyVisible()
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
bool parentPropertyEnabled = IsParentPropertyEnabled();
|
||||
if (parentPropertyEnabled)
|
||||
{
|
||||
for (int propIdx = 0; propIdx < effectConfig.effectProperties.Count; propIdx++)
|
||||
{
|
||||
EffectProperty effectProperty = effectConfig.effectProperties[propIdx];
|
||||
|
||||
res = IsEffectPropertyVisible(effectProperty, references.targetMatInfos);
|
||||
if (res)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
res = res || (parentPropertyEnabled && !string.IsNullOrEmpty(effectConfig.GetCustomMessage(references.targetMatInfos)));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
protected bool IsEffectPropertyVisible(EffectProperty effectProperty, AbstractMaterialInfo[] targetMatInfos)
|
||||
{
|
||||
bool res = true;
|
||||
|
||||
for (int i = 0; i < targetMatInfos.Length; i++)
|
||||
{
|
||||
res = res && IsEffectPropertyVisible(effectProperty, targetMatInfos[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
protected bool IsEffectPropertyVisible(EffectProperty effectProperty, AbstractMaterialInfo targetMatInfo)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
bool anyIncompatibilities = false;
|
||||
|
||||
for (int i = 0; i < effectProperty.incompatibleKeywords.Count; i++)
|
||||
{
|
||||
string incompatibleKw = effectProperty.incompatibleKeywords[i];
|
||||
if (targetMatInfo.IsKeywordEnabled(incompatibleKw))
|
||||
{
|
||||
anyIncompatibilities = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!anyIncompatibilities)
|
||||
{
|
||||
if (effectProperty.keywordsOp == KeywordsOp.OR)
|
||||
{
|
||||
for (int i = 0; i < effectProperty.keywords.Count; i++)
|
||||
{
|
||||
string keyword = effectProperty.keywords[i];
|
||||
|
||||
if (targetMatInfo.IsKeywordEnabled(keyword))
|
||||
{
|
||||
res = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
res = true;
|
||||
for (int i = 0; i < effectProperty.keywords.Count; i++)
|
||||
{
|
||||
string keyword = effectProperty.keywords[i];
|
||||
if (!targetMatInfo.IsKeywordEnabled(keyword))
|
||||
{
|
||||
res = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
protected MaterialProperty FindPropertyByName(string propertyName)
|
||||
{
|
||||
MaterialProperty res = null;
|
||||
|
||||
for (int i = 0; i < references.matProperties.Length; i++)
|
||||
{
|
||||
if (references.matProperties[i].name == propertyName)
|
||||
{
|
||||
res = references.matProperties[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
protected int FindPropertyIndex(string propertyName)
|
||||
{
|
||||
int res = -1;
|
||||
|
||||
for (int i = 0; i < references.matProperties.Length; i++)
|
||||
{
|
||||
if (references.matProperties[i].name == propertyName)
|
||||
{
|
||||
res = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
protected bool AreDependenciesMet()
|
||||
{
|
||||
bool res = true;
|
||||
|
||||
if (!string.IsNullOrEmpty(effectConfig.dependentOnEffect))
|
||||
{
|
||||
AllIn13DEffectConfig dependentEffect = propertiesConfig.FindEffectConfigByID(effectConfig.dependentOnEffect);
|
||||
res = res && AllIn13DEffectConfig.IsEffectEnabled(dependentEffect, references);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(effectConfig.incompatibleWithEffectID))
|
||||
{
|
||||
AllIn13DEffectConfig dependentEffect = propertiesConfig.FindEffectConfigByID(effectConfig.incompatibleWithEffectID);
|
||||
res = res && !AllIn13DEffectConfig.IsEffectEnabled(dependentEffect, references);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
protected bool IsShaderVariant()
|
||||
{
|
||||
bool res = true;
|
||||
|
||||
for(int i = 0; i < references.targetMatInfos.Length; i++)
|
||||
{
|
||||
if (references.targetMatInfos[i].IsShaderVariant())
|
||||
{
|
||||
res = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public virtual void Refresh(AllIn13DShaderInspectorReferences references)
|
||||
{
|
||||
this.references = references;
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1fc7c21ef6e0e8b4c9333a9fdd7a4bb6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Drawers/EffectDrawers/AbstractEffectDrawer.cs
|
||||
uploadId: 865720
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class AllIn13DShaderGradientDrawer : MaterialPropertyDrawer
|
||||
{
|
||||
private GradientEditorDrawer gradientEditorDrawer;
|
||||
|
||||
private void RefreshReferences(MaterialProperty prop)
|
||||
{
|
||||
if(gradientEditorDrawer == null)
|
||||
{
|
||||
gradientEditorDrawer = new GradientEditorDrawer();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
|
||||
{
|
||||
RefreshReferences(prop);
|
||||
|
||||
Texture texValue = prop.textureValue;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
Texture newTex = gradientEditorDrawer.Draw(position, texValue);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
prop.textureValue = newTex;
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
float res = 0f;
|
||||
if(gradientEditorDrawer != null)
|
||||
{
|
||||
res = gradientEditorDrawer.GetPropertyHeight();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aaf7449ec0a51804980a5d076861735c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Drawers/EffectDrawers/AllIn13DShaderGradientDrawer.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,25 @@
|
||||
using UnityEditor;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class ColorRampEffectDrawer : AbstractEffectDrawer
|
||||
{
|
||||
public ColorRampEffectDrawer(AllIn13DShaderInspectorReferences references,
|
||||
PropertiesConfig propertiesConfig) : base(references, propertiesConfig)
|
||||
{
|
||||
this.drawerID = Constants.COLOR_RAMP_EFFECT_DRAWER_ID;
|
||||
}
|
||||
|
||||
protected override void DrawProperties()
|
||||
{
|
||||
for(int i = 0; i < effectConfig.effectProperties.Count; i++)
|
||||
{
|
||||
DrawProperty(effectConfig.effectProperties[i]);
|
||||
if (i == 2)
|
||||
{
|
||||
EditorGUILayout.LabelField("*Set the Color Ramp Texture to Repeat Wrap Mode if using Tiling and/or Scroll Speed", references.smallLabelStyle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 17130facc1b999348a0cbd8784766aba
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Drawers/EffectDrawers/ColorRampEffectDrawer.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class GeneralEffectDrawer : AbstractEffectDrawer
|
||||
{
|
||||
public GeneralEffectDrawer(AllIn13DShaderInspectorReferences references,
|
||||
PropertiesConfig propertiesConfig) : base(references, propertiesConfig)
|
||||
{
|
||||
this.drawerID = Constants.GENERAL_EFFECT_DRAWER_ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d0ce6e8dd172c346b1c817ec5065103
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Drawers/EffectDrawers/GeneralEffectDrawer.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,35 @@
|
||||
using UnityEditor;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class OutlineEffectDrawer : AbstractEffectDrawer
|
||||
{
|
||||
private MaterialProperty stencilRefMatProperty;
|
||||
|
||||
public OutlineEffectDrawer(AllIn13DShaderInspectorReferences references,
|
||||
PropertiesConfig propertiesConfig) : base(references, propertiesConfig)
|
||||
{
|
||||
this.drawerID = Constants.OUTLINE_DRAWER_ID;
|
||||
|
||||
stencilRefMatProperty = FindPropertyByName("_StencilRef");
|
||||
}
|
||||
|
||||
protected override void DrawProperties()
|
||||
{
|
||||
base.DrawProperties();
|
||||
|
||||
if (stencilRefMatProperty != null)
|
||||
{
|
||||
EffectPropertyDrawer.DrawProperty(
|
||||
materialProperty: stencilRefMatProperty,
|
||||
labelPrefix: string.Empty,
|
||||
displayName: stencilRefMatProperty.displayName,
|
||||
customValue: string.Empty,
|
||||
allowReset: true,
|
||||
isKeywordProperty: false,
|
||||
propertyType: EffectProperty.PropertyType.BASIC,
|
||||
references: references);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6cc036b9a5e6daf40895576180575dd3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Drawers/EffectDrawers/OutlineEffectDrawer.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,370 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public static class EffectPropertyDrawer
|
||||
{
|
||||
public static void DrawMainProperty(int globalEffectIndex,
|
||||
AllIn13DEffectConfig effectConfig, AllIn13DShaderInspectorReferences references,
|
||||
bool isEffectAvailable, bool isEffectAvailableOnGlobalConfig)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
|
||||
bool isShaderVariant = references.IsShaderVariant();
|
||||
string label = $"{globalEffectIndex}. {effectConfig.displayName}";
|
||||
|
||||
if (isEffectAvailableOnGlobalConfig || isShaderVariant)
|
||||
{
|
||||
switch (effectConfig.effectConfigType)
|
||||
{
|
||||
case EffectConfigType.EFFECT_TOGGLE:
|
||||
DrawMainPropertyToggle(label, effectConfig, references, isShaderVariant);
|
||||
break;
|
||||
case EffectConfigType.EFFECT_ENUM:
|
||||
DrawMainPropertyEnum(label, effectConfig, references, isEffectAvailable, isShaderVariant);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int keywordSelectedIndex = 0;
|
||||
references.IsEffectEnabled(effectConfig, ref keywordSelectedIndex);
|
||||
|
||||
GUIContent guiContent = effectConfig.CreateGUIContent(globalEffectIndex, keywordSelectedIndex);
|
||||
EditorGUILayout.LabelField(guiContent, GUILayout.Width(180f));
|
||||
EditorGUILayout.LabelField("Disabled in Active Effects List");
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
public static void DrawMainPropertyToggle(string label,
|
||||
AllIn13DEffectConfig effectConfig, AllIn13DShaderInspectorReferences references,
|
||||
bool isShaderVariant)
|
||||
{
|
||||
bool isEffectEnabled = AllIn13DEffectConfig.IsEffectEnabled(effectConfig, references);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
string tooltip = effectConfig.keywords[0].keyword + " (C#)";
|
||||
GUIContent guiContent = new GUIContent(label, tooltip);
|
||||
|
||||
bool effectEnabledInAllMaterials = true;
|
||||
bool effectDisabledInAllMaterials = true;
|
||||
bool allMaterialsAreVariants = true;
|
||||
for (int i = 0; i < references.targetMatInfos.Length; i++)
|
||||
{
|
||||
bool effectEnabledThisMat = AllIn13DEffectConfig.IsEffectEnabled(effectConfig, references.targetMatInfos[i]);
|
||||
|
||||
effectEnabledInAllMaterials = effectEnabledInAllMaterials && effectEnabledThisMat;
|
||||
effectDisabledInAllMaterials = effectDisabledInAllMaterials && !effectEnabledThisMat;
|
||||
allMaterialsAreVariants = allMaterialsAreVariants && references.targetMatInfos[i].IsShaderVariant();
|
||||
}
|
||||
|
||||
if (allMaterialsAreVariants)
|
||||
{
|
||||
GUILayout.Label(guiContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool mixedValue = (!(effectEnabledInAllMaterials || effectDisabledInAllMaterials)) && references.targetMatInfos.Length > 1;
|
||||
string style = mixedValue ? "ToggleMixed" : "Toggle";
|
||||
isEffectEnabled = GUILayout.Toggle(isEffectEnabled, guiContent, style);
|
||||
}
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
for(int i = 0; i < references.targetMatInfos.Length; i++)
|
||||
{
|
||||
AbstractMaterialInfo matInfo = references.targetMatInfos[i];
|
||||
|
||||
if (isEffectEnabled)
|
||||
{
|
||||
AllIn13DEffectConfig.EnableEffect(effectConfig, references, matInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
AllIn13DEffectConfig.DisableEffect(effectConfig, matInfo);
|
||||
}
|
||||
}
|
||||
|
||||
references.matProperties[effectConfig.keywordPropertyIndex].floatValue = isEffectEnabled ? 1f : 0f;
|
||||
|
||||
EditorUtils.SetDirtyCurrentScene();
|
||||
|
||||
references.SetMaterialsDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawMainPropertyEnum(string label,
|
||||
AllIn13DEffectConfig effectConfig, AllIn13DShaderInspectorReferences references,
|
||||
bool isEffectAvailable, bool isShaderVariant)
|
||||
{
|
||||
int selectedIndex = 0;
|
||||
//bool isEffectEnabled = AllIn13DEffectConfig.IsEffectEnabled(effectConfig, ref selectedIndex, references);
|
||||
|
||||
|
||||
bool sameEnumValueInAllMaterials = references.IsEffectEnabled(effectConfig, ref selectedIndex);
|
||||
//bool sameEnumValueInAllMaterials = true;
|
||||
//for(int i = 0; i < references.targetMatInfos.Length; i++)
|
||||
//{
|
||||
// int enumIdx = -1;
|
||||
// AbstractMaterialInfo matInfo = references.targetMatInfos[i];
|
||||
|
||||
// bool effectEnabled = AllIn13DEffectConfig.IsEffectEnabled(effectConfig, ref enumIdx, matInfo);
|
||||
|
||||
// if(i == 0)
|
||||
// {
|
||||
// selectedIndex = enumIdx;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// sameEnumValueInAllMaterials = sameEnumValueInAllMaterials && (enumIdx == selectedIndex);
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
string tooltip = effectConfig.keywords[selectedIndex].keyword + " (C#)";
|
||||
GUIContent guiContent = new GUIContent(label, tooltip);
|
||||
|
||||
|
||||
if (isShaderVariant)
|
||||
{
|
||||
if (isEffectAvailable)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal(references.propertiesStyle);
|
||||
EditorGUILayout.LabelField(guiContent);
|
||||
EditorGUILayout.LabelField(effectConfig.keywordsDisplayNames[selectedIndex]);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.LabelField(guiContent);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUI.showMixedValue = !sameEnumValueInAllMaterials;
|
||||
selectedIndex = EditorGUILayout.Popup(guiContent, selectedIndex, effectConfig.keywordsDisplayNames);
|
||||
EditorGUI.showMixedValue = false;
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
for (int i = 0; i < references.targetMatInfos.Length; i++)
|
||||
{
|
||||
AbstractMaterialInfo matInfo = references.targetMatInfos[i];
|
||||
|
||||
if (selectedIndex >= 0)
|
||||
{
|
||||
AllIn13DEffectConfig.EnableEffectByIndex(effectConfig, selectedIndex, references, matInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
AllIn13DEffectConfig.DisableEffect(effectConfig, matInfo);
|
||||
}
|
||||
}
|
||||
|
||||
references.matProperties[effectConfig.keywordPropertyIndex].floatValue = selectedIndex;
|
||||
|
||||
EditorUtils.SetDirtyCurrentScene();
|
||||
|
||||
references.SetMaterialsDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//public static void DrawProperty(int propertyIndex, string labelPrefix, bool allowReset, bool isKeywordProperty, AllIn13DShaderInspectorReferences references)
|
||||
//{
|
||||
// MaterialProperty targetProperty = references.matProperties[propertyIndex];
|
||||
// DrawProperty(
|
||||
// materialProperty: targetProperty,
|
||||
// labelPrefix: labelPrefix,
|
||||
// displayName: targetProperty.displayName,
|
||||
// allowReset: allowReset,
|
||||
// isKeywordProperty: isKeywordProperty,
|
||||
// references: references);
|
||||
//}
|
||||
|
||||
//public static void DrawProperty(EffectProperty effectProperty, string labelPrefix, bool allowReset, AllIn13DShaderInspectorReferences references)
|
||||
//{
|
||||
// DrawProperty(effectProperty.propertyIndex, labelPrefix, effectProperty.allowReset, effectProperty.IsPropertyWithKeywords(), references);
|
||||
//}
|
||||
|
||||
//public static void DrawProperty(EffectProperty effectProperty, AllIn13DShaderInspectorReferences references)
|
||||
//{
|
||||
// DrawProperty(propertyIndex: effectProperty.propertyIndex, isKeywordProperty: effectProperty.IsPropertyWithKeywords(), references: references);
|
||||
//}
|
||||
|
||||
//public static void DrawProperty(int propertyIndex, bool isKeywordProperty, AllIn13DShaderInspectorReferences references)
|
||||
//{
|
||||
// DrawProperty(propertyIndex, string.Empty, true, isKeywordProperty, references);
|
||||
//}
|
||||
|
||||
//public static void DrawProperty(MaterialProperty materialProperty, AllIn13DShaderInspectorReferences references)
|
||||
//{
|
||||
// DrawProperty(materialProperty, false, references);
|
||||
//}
|
||||
|
||||
//public static void DrawProperty(MaterialProperty materialProperty, bool isKeywordProperty, AllIn13DShaderInspectorReferences references)
|
||||
//{
|
||||
// DrawProperty(
|
||||
// materialProperty: materialProperty,
|
||||
// labelPrefix: string.Empty,
|
||||
// displayName: materialProperty.displayName,
|
||||
// allowReset: true,
|
||||
// isKeywordProperty: isKeywordProperty,
|
||||
// references: references);
|
||||
//}
|
||||
|
||||
//public static void DrawProperty(MaterialProperty materialProperty, bool allowReset, bool isKeywordProperty, AllIn13DShaderInspectorReferences references)
|
||||
//{
|
||||
// DrawProperty(
|
||||
// materialProperty: materialProperty,
|
||||
// labelPrefix: string.Empty,
|
||||
// displayName: materialProperty.displayName,
|
||||
// allowReset: allowReset,
|
||||
// isKeywordProperty: isKeywordProperty,
|
||||
// references: references);
|
||||
//}
|
||||
|
||||
//public static void DrawProperty(
|
||||
// MaterialProperty materialProperty,
|
||||
// string labelPrefix,
|
||||
// bool allowReset,
|
||||
// bool isKeywordProperty,
|
||||
// AllIn13DShaderInspectorReferences references)
|
||||
//{
|
||||
// DrawProperty(
|
||||
// materialProperty: materialProperty,
|
||||
// labelPrefix: labelPrefix,
|
||||
// displayName: materialProperty.displayName,
|
||||
// allowReset: allowReset,
|
||||
// isKeywordProperty: isKeywordProperty,
|
||||
// references: references);
|
||||
//}
|
||||
|
||||
//public static void DrawPropertyCustomValue(
|
||||
// EffectProperty effectProperty,
|
||||
// string labelPrefix,
|
||||
// string displayName,
|
||||
// bool allowReset,
|
||||
// bool isKeywordProperty,
|
||||
// AllIn13DShaderInspectorReferences references)
|
||||
//{
|
||||
// MaterialProperty materialProperty = references.matProperties[effectProperty.propertyIndex];
|
||||
// string label = $"{labelPrefix} {displayName}";
|
||||
// string tooltip = materialProperty.name + "(C#)";
|
||||
|
||||
// EditorGUILayout.BeginHorizontal();
|
||||
|
||||
// DrawShaderProperty(materialProperty: materialProperty, label: label, tooltip: tooltip, isKeywordProperty: isKeywordProperty, references: references);
|
||||
// if (allowReset)
|
||||
// {
|
||||
// DrawResetButton(materialProperty, references);
|
||||
// }
|
||||
|
||||
// EditorGUILayout.EndHorizontal();
|
||||
//}
|
||||
|
||||
public static void DrawProperty(
|
||||
MaterialProperty materialProperty,
|
||||
string labelPrefix,
|
||||
string displayName,
|
||||
string customValue,
|
||||
bool allowReset,
|
||||
bool isKeywordProperty,
|
||||
EffectProperty.PropertyType propertyType,
|
||||
AllIn13DShaderInspectorReferences references)
|
||||
{
|
||||
string label = $"{labelPrefix} {displayName}";
|
||||
string tooltip = materialProperty.name + "(C#)";
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
|
||||
bool isShaderVariant = references.IsShaderVariant();
|
||||
|
||||
if(isShaderVariant && isKeywordProperty)
|
||||
{
|
||||
DrawShaderPropertyCustomValue(label: label, tooltip: tooltip, customValue: customValue, isKeywordProperty: isKeywordProperty, propertyType: propertyType, references: references);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawShaderProperty(materialProperty: materialProperty, label: label, tooltip: tooltip, isKeywordProperty: isKeywordProperty, references: references);
|
||||
if (allowReset)
|
||||
{
|
||||
DrawResetButton(materialProperty, references);
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
private static void DrawShaderProperty(
|
||||
MaterialProperty materialProperty,
|
||||
string label,
|
||||
string tooltip,
|
||||
bool isKeywordProperty,
|
||||
AllIn13DShaderInspectorReferences references)
|
||||
{
|
||||
GUIContent propertyLabel = new GUIContent();
|
||||
propertyLabel.text = label;
|
||||
propertyLabel.tooltip = tooltip;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
references.editorMat.ShaderProperty(materialProperty, propertyLabel);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
if (isKeywordProperty)
|
||||
{
|
||||
references.RefreshMaterialKeywords();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void DrawShaderPropertyCustomValue(
|
||||
string label,
|
||||
string tooltip,
|
||||
string customValue,
|
||||
bool isKeywordProperty,
|
||||
EffectProperty.PropertyType propertyType,
|
||||
AllIn13DShaderInspectorReferences references)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
GUIContent propertyLabel = new GUIContent();
|
||||
propertyLabel.text = label;
|
||||
propertyLabel.tooltip = tooltip;
|
||||
|
||||
if(propertyType == EffectProperty.PropertyType.TOGGLE)
|
||||
{
|
||||
EditorGUILayout.Toggle(propertyLabel, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.LabelField(propertyLabel);
|
||||
EditorGUILayout.LabelField(customValue);
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
public static void DrawResetButton(MaterialProperty targetProperty, AllIn13DShaderInspectorReferences references)
|
||||
{
|
||||
GUIContent resetButtonLabel = new GUIContent();
|
||||
resetButtonLabel.text = "R";
|
||||
resetButtonLabel.tooltip = "Resets to default value";
|
||||
if (GUILayout.Button(resetButtonLabel, GUILayout.Width(20)))
|
||||
{
|
||||
for (int i = 0; i < references.targetMatInfos.Length; i++)
|
||||
{
|
||||
AbstractMaterialInfo matInfo = references.targetMatInfos[i];
|
||||
AllIn13DEffectConfig.ResetProperty(targetProperty, references, matInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: edd8e2faf4f408743829655503b71b17
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Drawers/EffectPropertyDrawer.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,42 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class GlobalPropertiesDrawer
|
||||
{
|
||||
private List<int> globalPropertiesIndices;
|
||||
private AllIn13DShaderInspectorReferences references;
|
||||
|
||||
public GlobalPropertiesDrawer()
|
||||
{
|
||||
}
|
||||
|
||||
public void Draw(List<int> globalPropertiesIndices, AllIn13DShaderInspectorReferences references)
|
||||
{
|
||||
this.globalPropertiesIndices = globalPropertiesIndices;
|
||||
this.references = references;
|
||||
|
||||
GUILayout.Label("Global Properties", references.bigLabelStyle);
|
||||
|
||||
EditorGUILayout.BeginVertical(references.propertiesStyle);
|
||||
for (int i = 0; i < globalPropertiesIndices.Count; i++)
|
||||
{
|
||||
MaterialProperty matProperty = references.matProperties[globalPropertiesIndices[i]];
|
||||
|
||||
EffectPropertyDrawer.DrawProperty(
|
||||
materialProperty: matProperty,
|
||||
labelPrefix: string.Empty,
|
||||
displayName: matProperty.displayName,
|
||||
customValue: string.Empty,
|
||||
allowReset: true,
|
||||
isKeywordProperty: false,
|
||||
propertyType: EffectProperty.PropertyType.BASIC,
|
||||
references: references);
|
||||
}
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 55fc5c9db4641f54a912ca07e7d764f8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Drawers/GlobalPropertiesDrawer.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,107 @@
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class GradientCreatorDrawer
|
||||
{
|
||||
private GradientCreatorTool gradientCreatorTool;
|
||||
private CommonStyles commonStyles;
|
||||
|
||||
private Texture2D GradientTex
|
||||
{
|
||||
get
|
||||
{
|
||||
return gradientCreatorTool.gradientTex;
|
||||
}
|
||||
set
|
||||
{
|
||||
gradientCreatorTool.gradientTex = value;
|
||||
}
|
||||
}
|
||||
|
||||
private Gradient Grad
|
||||
{
|
||||
get
|
||||
{
|
||||
return gradientCreatorTool.gradient;
|
||||
}
|
||||
set
|
||||
{
|
||||
gradientCreatorTool.gradient = value;
|
||||
}
|
||||
}
|
||||
|
||||
private TextureSizes GradientSizes
|
||||
{
|
||||
get
|
||||
{
|
||||
return gradientCreatorTool.gradientSizes;
|
||||
}
|
||||
set
|
||||
{
|
||||
gradientCreatorTool.gradientSizes = value;
|
||||
}
|
||||
}
|
||||
|
||||
private FilterMode GradientFiltering
|
||||
{
|
||||
get
|
||||
{
|
||||
return gradientCreatorTool.gradientFiltering;
|
||||
}
|
||||
set
|
||||
{
|
||||
gradientCreatorTool.gradientFiltering = value;
|
||||
}
|
||||
}
|
||||
|
||||
public GradientCreatorDrawer(GradientCreatorTool gradientCreatorTool, CommonStyles commonStyles)
|
||||
{
|
||||
this.gradientCreatorTool = gradientCreatorTool;
|
||||
this.commonStyles = commonStyles;
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
GUILayout.Label("Color Gradient Creator", commonStyles.bigLabel);
|
||||
GUILayout.Space(20);
|
||||
GUILayout.Label("This feature can be used to create textures for the Color Ramp Effect", EditorStyles.boldLabel);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
Grad = EditorGUILayout.GradientField("Color Gradient: ", Grad, GUILayout.Height(25), GUILayout.MaxWidth(CommonStyles.BUTTON_WIDTH));
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Label("Texture Size:", GUILayout.MaxWidth(145));
|
||||
GradientSizes = (TextureSizes)EditorGUILayout.EnumPopup(GradientSizes, GUILayout.MaxWidth(200));
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Label("New Textures Filtering: ", GUILayout.MaxWidth(145));
|
||||
GradientFiltering = (FilterMode)EditorGUILayout.EnumPopup(GradientFiltering, GUILayout.MaxWidth(200));
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
bool gradientChanged = EditorGUI.EndChangeCheck();
|
||||
if (gradientChanged)
|
||||
{
|
||||
gradientCreatorTool.CreateGradientTexture();
|
||||
}
|
||||
|
||||
GUILayout.Space(20);
|
||||
GUILayout.Label("Select the folder where new Color Gradient Textures will be saved", EditorStyles.boldLabel);
|
||||
|
||||
GlobalConfiguration.instance.GradientSavePath = EditorUtils.DrawSelectorFolder(GlobalConfiguration.instance.GradientSavePath, /*AllIn13DShaderConfig.GRADIENT_SAVE_PATH_DEFAULT,*/ "Gradients");
|
||||
if (Directory.Exists(GlobalConfiguration.instance.GradientSavePath))
|
||||
{
|
||||
if (GUILayout.Button("Save Color Gradient Texture", GUILayout.MaxWidth(CommonStyles.BUTTON_WIDTH)))
|
||||
{
|
||||
EditorUtils.SaveTextureAsPNG(GlobalConfiguration.instance.GradientSavePath, "ColorGradient", "Gradient", GradientTex, GradientFiltering,
|
||||
TextureImporterType.Default, TextureWrapMode.Clamp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 53d536ed22c0b4d4e8472402997463dd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Drawers/GradientCreatorDrawer.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,332 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class GradientEditorDrawer
|
||||
{
|
||||
private const float OFFSET = 5f;
|
||||
|
||||
private Gradient gradient;
|
||||
private Rect lastRect;
|
||||
private Texture2D previewTex;
|
||||
private GradientCreatorTool gradientCreatorTool;
|
||||
|
||||
private bool createGradientToggle;
|
||||
private bool textureSaved;
|
||||
private bool usingPreviewTex;
|
||||
private bool isModifyingExistingTexture;
|
||||
|
||||
private Texture lastSavedTexture;
|
||||
private Gradient lastGradient;
|
||||
|
||||
private GradientTexture gradientTextureAsset;
|
||||
|
||||
private void RefreshReferences(Texture lastTexture)
|
||||
{
|
||||
if (gradient == null)
|
||||
{
|
||||
gradient = new Gradient();
|
||||
}
|
||||
|
||||
if (previewTex == null)
|
||||
{
|
||||
previewTex = new Texture2D(128, 128);
|
||||
}
|
||||
|
||||
if (gradientCreatorTool == null)
|
||||
{
|
||||
gradientCreatorTool = new GradientCreatorTool();
|
||||
}
|
||||
|
||||
if (lastSavedTexture == null)
|
||||
{
|
||||
lastSavedTexture = lastTexture;
|
||||
}
|
||||
|
||||
if (lastGradient == null)
|
||||
{
|
||||
lastGradient = new Gradient();
|
||||
}
|
||||
}
|
||||
|
||||
private Texture RefreshGradientState(Texture texValue)
|
||||
{
|
||||
Texture res = texValue;
|
||||
|
||||
if (createGradientToggle)
|
||||
{
|
||||
lastSavedTexture = texValue;
|
||||
|
||||
isModifyingExistingTexture = EditorUtils.IsProjectAsset(lastSavedTexture);
|
||||
|
||||
this.gradientTextureAsset = GradientCreatorTool.FindGradientTexureByTex(texValue);
|
||||
if (this.gradientTextureAsset != null)
|
||||
{
|
||||
GradientCreatorTool.CopyGradient(gradientTextureAsset.gradient, gradient);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (texValue != null)
|
||||
{
|
||||
gradient = CreateGradientFromTexture(texValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
gradient = new Gradient();
|
||||
}
|
||||
}
|
||||
|
||||
previewTex = gradientCreatorTool.CreateGradientTexture(gradient);
|
||||
res = previewTex;
|
||||
}
|
||||
else
|
||||
{
|
||||
GradientCreatorTool.CopyGradient(gradient, lastGradient);
|
||||
previewTex = null;
|
||||
res = lastSavedTexture;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private Gradient CreateGradientFromTexture(Texture texSource)
|
||||
{
|
||||
int width = texSource.width;
|
||||
int height = texSource.height;
|
||||
|
||||
RenderTexture renderTex = RenderTexture.GetTemporary(
|
||||
width,
|
||||
height,
|
||||
0,
|
||||
RenderTextureFormat.Default,
|
||||
RenderTextureReadWrite.Linear);
|
||||
|
||||
Graphics.Blit(texSource, renderTex);
|
||||
RenderTexture previous = RenderTexture.active;
|
||||
RenderTexture.active = renderTex;
|
||||
Texture2D readableText = new Texture2D(texSource.width, texSource.height);
|
||||
readableText.filterMode = texSource.filterMode;
|
||||
readableText.wrapMode = texSource.wrapMode;
|
||||
readableText.ReadPixels(new Rect(0, 0, renderTex.width, renderTex.height), 0, 0);
|
||||
readableText.Apply();
|
||||
RenderTexture.active = previous;
|
||||
RenderTexture.ReleaseTemporary(renderTex);
|
||||
|
||||
|
||||
Gradient res = new Gradient();
|
||||
List<GradientColorKey> gradientColorKeys = new List<GradientColorKey>();
|
||||
|
||||
int numSamples = 5;
|
||||
float step = (((float)width) / numSamples) / width;
|
||||
|
||||
Vector2 sampleUV = Vector2.zero;
|
||||
sampleUV.y = renderTex.height * 0.5f;
|
||||
for (int i = 0; i < numSamples; i++)
|
||||
{
|
||||
Color col = readableText.GetPixelBilinear(sampleUV.x, sampleUV.y);
|
||||
gradientColorKeys.Add(new GradientColorKey(col, sampleUV.x));
|
||||
|
||||
sampleUV.x += step;
|
||||
}
|
||||
|
||||
Color lastCol = readableText.GetPixelBilinear(sampleUV.x, sampleUV.y);
|
||||
gradientColorKeys.Add(new GradientColorKey(lastCol, sampleUV.x));
|
||||
|
||||
res.colorKeys = gradientColorKeys.ToArray();
|
||||
res.mode = GradientMode.Blend;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public Texture Draw(Rect position, Texture gradientTexture)
|
||||
{
|
||||
RefreshReferences(gradientTexture);
|
||||
|
||||
lastRect = position;
|
||||
|
||||
Texture texValue = gradientTexture;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
if (createGradientToggle && texValue == null)
|
||||
{
|
||||
texValue = lastSavedTexture;
|
||||
createGradientToggle = false;
|
||||
}
|
||||
|
||||
texValue = DrawTextureField(texValue, 60f, "Color ramp texture");
|
||||
bool changes = EditorGUI.EndChangeCheck();
|
||||
if (changes)
|
||||
{
|
||||
createGradientToggle = false;
|
||||
lastSavedTexture = texValue;
|
||||
}
|
||||
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
DrawCreateGradientToggle(15f, "Create Gradient");
|
||||
bool createGradientToggleChanged = EditorGUI.EndChangeCheck();
|
||||
if (createGradientToggleChanged)
|
||||
{
|
||||
texValue = RefreshGradientState(texValue);
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
if (createGradientToggle)
|
||||
{
|
||||
texValue = DrawGradientField(40f, "Gradient", texValue);
|
||||
}
|
||||
|
||||
EditorGUI.showMixedValue = false;
|
||||
bool gradientFieldChanged = EditorGUI.EndChangeCheck();
|
||||
if (gradientFieldChanged && !textureSaved)
|
||||
{
|
||||
previewTex = gradientCreatorTool.CreateGradientTexture(TextureSizes._256, FilterMode.Bilinear, gradient);
|
||||
texValue = previewTex;
|
||||
|
||||
usingPreviewTex = true;
|
||||
}
|
||||
|
||||
textureSaved = false;
|
||||
|
||||
return texValue;
|
||||
}
|
||||
|
||||
private Texture DrawTextureField(Texture tex, float height, string label)
|
||||
{
|
||||
Rect rect = new Rect(lastRect);
|
||||
rect.height = height;
|
||||
|
||||
GUIStyle labelStyle = EditorStyles.label;
|
||||
labelStyle.alignment = TextAnchor.UpperLeft;
|
||||
|
||||
Rect labelRect = new Rect(rect);
|
||||
labelRect.width = 200f;
|
||||
EditorGUI.LabelField(labelRect, new GUIContent(label), labelStyle);
|
||||
|
||||
GUIStyle textureStyle = EditorStyles.objectField;
|
||||
textureStyle.alignment = TextAnchor.MiddleLeft;
|
||||
|
||||
Rect textureRect = new Rect(rect);
|
||||
textureRect.width = height;
|
||||
textureRect.height = height;
|
||||
textureRect.x = rect.width - textureRect.width - 10f;
|
||||
|
||||
Texture res = (Texture)EditorGUI.ObjectField(textureRect, tex, typeof(Texture), false);
|
||||
lastRect.y += height;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private Texture DrawGradientField(float height, string label, Texture texValue)
|
||||
{
|
||||
Texture res = texValue;
|
||||
|
||||
Rect rect = new Rect(lastRect);
|
||||
rect.height = height;
|
||||
rect.y += height * 0.5f;
|
||||
|
||||
float createButtonWidth = 100f;
|
||||
|
||||
GUIStyle labelStyle = EditorStyles.label;
|
||||
labelStyle.alignment = TextAnchor.UpperLeft;
|
||||
Rect labelRect = new Rect(rect);
|
||||
labelRect.width = 200f;
|
||||
EditorGUI.LabelField(labelRect, new GUIContent(label), labelStyle);
|
||||
|
||||
GUIStyle textureStyle = EditorStyles.objectField;
|
||||
textureStyle.alignment = TextAnchor.MiddleLeft;
|
||||
|
||||
Rect gradientAndButtonRect = new Rect(rect);
|
||||
gradientAndButtonRect.width = rect.width - labelRect.width;
|
||||
gradientAndButtonRect.height = rect.height;
|
||||
gradientAndButtonRect.x = labelRect.x + labelRect.width;
|
||||
|
||||
Rect gradientRect = new Rect(gradientAndButtonRect);
|
||||
gradientRect.width = gradientAndButtonRect.width * 0.5f;
|
||||
gradientRect.height = rect.height * 0.5f;
|
||||
gradientRect.x = rect.x + rect.width - gradientRect.width - (createButtonWidth * 2f) - 10f;
|
||||
gradient = EditorGUI.GradientField(gradientRect, gradient);
|
||||
|
||||
Rect createButtonRect = new Rect(gradientAndButtonRect);
|
||||
createButtonRect.width = createButtonWidth;
|
||||
createButtonRect.height = gradientRect.height;
|
||||
createButtonRect.x = gradientRect.x + gradientRect.width + 10f;
|
||||
|
||||
Rect modifyButtonRect = new Rect(createButtonRect);
|
||||
modifyButtonRect.x = createButtonRect.x + createButtonRect.width + 10f;
|
||||
|
||||
if (GUI.Button(createButtonRect, "Save Texture"))
|
||||
{
|
||||
res = ChangeTextureOnDisk(true);
|
||||
}
|
||||
|
||||
EditorGUI.BeginDisabledGroup(!isModifyingExistingTexture || gradientTextureAsset == null);
|
||||
if (GUI.Button(modifyButtonRect, "Overwrite"))
|
||||
{
|
||||
res = ChangeTextureOnDisk(false);
|
||||
}
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
lastRect.y += height + OFFSET;
|
||||
|
||||
if (usingPreviewTex && !textureSaved)
|
||||
{
|
||||
Rect helpBoxRect = new Rect(lastRect);
|
||||
helpBoxRect.height = 40f;
|
||||
EditorGUI.HelpBox(helpBoxRect, "Texture is not saved! Click on Save Texture to save it", MessageType.Warning);
|
||||
|
||||
lastRect.y += helpBoxRect.height + OFFSET;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private Texture ChangeTextureOnDisk(bool createNew)
|
||||
{
|
||||
gradientCreatorTool.CreateGradientTexture(gradient);
|
||||
Texture savedTex = gradientCreatorTool.SaveGradientTexture(gradientTextureAsset, createNew);
|
||||
|
||||
Texture res = savedTex;
|
||||
lastSavedTexture = savedTex;
|
||||
|
||||
textureSaved = true;
|
||||
usingPreviewTex = false;
|
||||
createGradientToggle = false;
|
||||
|
||||
gradientTextureAsset = null;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private void DrawCreateGradientToggle(float height, string label)
|
||||
{
|
||||
Rect rect = new Rect(lastRect);
|
||||
rect.height = height;
|
||||
|
||||
Rect toggleRect = new Rect(rect);
|
||||
|
||||
createGradientToggle = EditorGUI.ToggleLeft(toggleRect, label, createGradientToggle);
|
||||
|
||||
lastRect.y += height;
|
||||
}
|
||||
|
||||
public float GetPropertyHeight()
|
||||
{
|
||||
float res = 80f;
|
||||
|
||||
if (createGradientToggle)
|
||||
{
|
||||
res += 45f;
|
||||
if (usingPreviewTex)
|
||||
{
|
||||
res += 40f;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 42eeae2ae0fe6674786f324f6b74294c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Drawers/GradientEditorDrawer.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,124 @@
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using static AllIn13DShader.NoiseCreatorTool;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class NoiseCreatorDrawer
|
||||
{
|
||||
private NoiseCreatorTool noiseCreatorTool;
|
||||
private CommonStyles commonStyles;
|
||||
|
||||
private NoiseCreatorValues Values
|
||||
{
|
||||
get
|
||||
{
|
||||
return noiseCreatorTool.values;
|
||||
}
|
||||
}
|
||||
|
||||
public NoiseCreatorDrawer(NoiseCreatorTool noiseCreatorTool, CommonStyles commonStyles)
|
||||
{
|
||||
this.noiseCreatorTool = noiseCreatorTool;
|
||||
this.commonStyles = commonStyles;
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
GUILayout.Label("Tileable Noise Creator", commonStyles.bigLabel);
|
||||
GUILayout.Space(20);
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
EditorGUILayout.BeginVertical(GUILayout.MaxWidth(550));
|
||||
{
|
||||
if (Values.noisePreview == null)
|
||||
{
|
||||
GUILayout.Label("*Change a property to start editing a Noise texture", EditorStyles.boldLabel);
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Label("Noise Type:", GUILayout.MaxWidth(145));
|
||||
Values.noiseType = (NoiseTypes)EditorGUILayout.EnumPopup(Values.noiseType, GUILayout.MaxWidth(200));
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
noiseCreatorTool.NoiseSetMaterial();
|
||||
noiseCreatorTool.CheckCreationNoiseTextures();
|
||||
noiseCreatorTool.UpdateNoiseMatAndRender();
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
if (Values.isFractalNoise)
|
||||
{
|
||||
EditorUtils.TextureEditorFloatParameter("Scale X", ref Values.noiseScaleX, 0.1f, 50f, 4f);
|
||||
if (!Values.noiseSquareScale) EditorUtils.TextureEditorFloatParameter("Scale Y", ref Values.noiseScaleY, 0.1f, 50f, 4f);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorUtils.TextureEditorFloatParameter("Scale X", ref Values.noiseScaleX, 0.1f, 50f, 10f);
|
||||
if (!Values.noiseSquareScale) EditorUtils.TextureEditorFloatParameter("Scale Y", ref Values.noiseScaleY, 0.1f, 50f, 10f);
|
||||
}
|
||||
Values.noiseSquareScale = EditorGUILayout.Toggle("Square Scale?", Values.noiseSquareScale, GUILayout.MaxWidth(200));
|
||||
if (Values.noiseSquareScale) Values.noiseScaleY = Values.noiseScaleX;
|
||||
if (Values.noiseType == NoiseTypes.Fractal) EditorUtils.TextureEditorFloatParameter("Fractal Amount", ref Values.noiseFractalAmount, 1f, 10f, 8f);
|
||||
else if (Values.noiseType == NoiseTypes.Perlin) EditorUtils.TextureEditorFloatParameter("Fractal Amount", ref Values.noiseFractalAmount, 1f, 10f, 1f);
|
||||
else if (Values.noiseType == NoiseTypes.Billow) EditorUtils.TextureEditorFloatParameter("Fractal Amount", ref Values.noiseFractalAmount, 1f, 10f, 4f);
|
||||
else EditorUtils.TextureEditorFloatParameter("Jitter", ref Values.noiseJitter, 0.0f, 2f, 1f);
|
||||
EditorUtils.TextureEditorFloatParameter("Contrast", ref Values.noiseContrast, 0.1f, 10f, 1f);
|
||||
EditorUtils.TextureEditorFloatParameter("Brightness", ref Values.noiseBrightness, -1f, 1f, 0f);
|
||||
EditorUtils.TextureEditorIntParameter("Random Seed", ref Values.noiseSeed, 0, 100, 0);
|
||||
Values.noiseInverted = EditorGUILayout.Toggle("Inverted?", Values.noiseInverted);
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
if (Values.noiseMaterial == null)
|
||||
{
|
||||
noiseCreatorTool.NoiseSetMaterial();
|
||||
}
|
||||
noiseCreatorTool.CheckCreationNoiseTextures();
|
||||
|
||||
noiseCreatorTool.UpdateNoiseMatAndRender();
|
||||
}
|
||||
|
||||
GUILayout.Space(20);
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Label("Noise Size:", GUILayout.MaxWidth(145));
|
||||
Values.noiseSize = (TextureSizes)EditorGUILayout.EnumPopup(Values.noiseSize, GUILayout.MaxWidth(200));
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Label("New Noise Filtering: ", GUILayout.MaxWidth(145));
|
||||
Values.noiseFiltering = (FilterMode)EditorGUILayout.EnumPopup(Values.noiseFiltering, GUILayout.MaxWidth(200));
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
if (Values.noisePreview != null) GUILayout.Label(Values.noisePreview, GUILayout.MaxWidth(450), GUILayout.MaxHeight(450));
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
|
||||
GUILayout.Space(20);
|
||||
GUILayout.Label("Select the folder where new Noise Textures will be saved", EditorStyles.boldLabel);
|
||||
GlobalConfiguration.instance.NoiseSavePath = EditorUtils.DrawSelectorFolder(GlobalConfiguration.instance.NoiseSavePath, /*AllIn13DShaderConfig.NOISES_SAVE_PATH_DEFAULT,*/ "Noises");
|
||||
|
||||
if (Directory.Exists(GlobalConfiguration.instance.NoiseSavePath) && Values.noisePreview != null)
|
||||
{
|
||||
if (GUILayout.Button("Save Noise Texture", GUILayout.MaxWidth(CommonStyles.BUTTON_WIDTH)))
|
||||
{
|
||||
noiseCreatorTool.CreateNoiseTex();
|
||||
EditorUtils.SaveTextureAsPNG(GlobalConfiguration.instance.NoiseSavePath, "Noise", "Noises",
|
||||
Values.finalNoiseTex, Values.noiseFiltering, TextureImporterType.Default, TextureWrapMode.Clamp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f1d0e6ca131aebb45a4e398281fa7db3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Drawers/NoiseCreatorDrawer.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,62 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class NoiseCreatorValues
|
||||
{
|
||||
public Texture2D noisePreview = null;
|
||||
public Texture2D finalNoiseTex = null;
|
||||
|
||||
public RenderTexture noiseRenderTarget = null;
|
||||
public Material noiseMaterial;
|
||||
|
||||
public float noiseScaleX = 10f;
|
||||
public float noiseScaleY = 10f;
|
||||
public float noiseContrast = 1f;
|
||||
public float noiseBrightness = 0f;
|
||||
|
||||
public float noiseFractalAmount = 1f;
|
||||
public float noiseJitter = 1f;
|
||||
public int noiseSeed = 0;
|
||||
|
||||
public bool noiseSquareScale = false;
|
||||
public bool noiseInverted = false;
|
||||
public bool isFractalNoise = false;
|
||||
|
||||
public NoiseCreatorTool.NoiseTypes noiseType;
|
||||
|
||||
public TextureSizes noiseSize;
|
||||
public FilterMode noiseFiltering;
|
||||
|
||||
public NoiseCreatorValues()
|
||||
{
|
||||
SetDefault();
|
||||
}
|
||||
|
||||
public void SetDefault()
|
||||
{
|
||||
noisePreview = null;
|
||||
noiseRenderTarget = null;
|
||||
finalNoiseTex = null;
|
||||
|
||||
noiseMaterial = null;
|
||||
noiseScaleX = 10f;
|
||||
noiseScaleY = 10f;
|
||||
noiseContrast = 1f;
|
||||
noiseBrightness = 0f;
|
||||
|
||||
noiseFractalAmount = 1f;
|
||||
noiseJitter = 1f;
|
||||
noiseSeed = 0;
|
||||
|
||||
noiseSquareScale = false;
|
||||
noiseInverted = false;
|
||||
isFractalNoise = false;
|
||||
|
||||
noiseType = NoiseCreatorTool.NoiseTypes.Voronoi;
|
||||
|
||||
noiseSize = TextureSizes._512;
|
||||
noiseFiltering = FilterMode.Bilinear;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 14c147009aa5dae418a84b61107ada3c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Drawers/NoiseCreatorValues.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,138 @@
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class NormalMapCreatorDrawer
|
||||
{
|
||||
private NormalMapCreatorTool normalMapCreatorTool;
|
||||
private CommonStyles commonStyles;
|
||||
private Action repaintAction;
|
||||
|
||||
private Texture2D TargetNormalImage
|
||||
{
|
||||
get
|
||||
{
|
||||
return normalMapCreatorTool.targetNormalImage;
|
||||
}
|
||||
set
|
||||
{
|
||||
normalMapCreatorTool.targetNormalImage = value;
|
||||
}
|
||||
}
|
||||
|
||||
private float NormalStrength
|
||||
{
|
||||
get
|
||||
{
|
||||
return normalMapCreatorTool.normalStrength;
|
||||
}
|
||||
set
|
||||
{
|
||||
normalMapCreatorTool.normalStrength = value;
|
||||
}
|
||||
}
|
||||
|
||||
private int NormalSmoothing
|
||||
{
|
||||
get
|
||||
{
|
||||
return normalMapCreatorTool.normalSmoothing;
|
||||
}
|
||||
set
|
||||
{
|
||||
normalMapCreatorTool.normalSmoothing = value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool InvertNormals{ get; set; }
|
||||
|
||||
private int IsComputingNormals
|
||||
{
|
||||
get
|
||||
{
|
||||
return normalMapCreatorTool.isComputingNormals;
|
||||
}
|
||||
set
|
||||
{
|
||||
normalMapCreatorTool.isComputingNormals = value;
|
||||
}
|
||||
}
|
||||
|
||||
public NormalMapCreatorDrawer(NormalMapCreatorTool normalMapCreatorTool, CommonStyles commonStyles, Action repaintAction)
|
||||
{
|
||||
this.normalMapCreatorTool = normalMapCreatorTool;
|
||||
this.commonStyles = commonStyles;
|
||||
this.repaintAction = repaintAction;
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
GUILayout.Label("Normal/Distortion Map Creator", commonStyles.bigLabel);
|
||||
GUILayout.Space(20);
|
||||
|
||||
GUILayout.Label("Select the folder where new Normal Maps will be saved when the Create Normal Map button of the asset component is pressed", EditorStyles.boldLabel);
|
||||
|
||||
GlobalConfiguration.instance.NormalMapSavePath = EditorUtils.DrawSelectorFolder(GlobalConfiguration.instance.NormalMapSavePath, /*AllIn13DShaderConfig.NORMAL_MAP_SAVE_PATH_DEFAULT,*/ "Normal Maps Folder");
|
||||
|
||||
GUILayout.Label("Assign a texture you want to create a normal map from. Choose the normal map settings and press the 'Create And Save Normal Map' button", EditorStyles.boldLabel);
|
||||
TargetNormalImage = (Texture2D)EditorGUILayout.ObjectField("Target Image", TargetNormalImage, typeof(Texture2D), false, GUILayout.MaxWidth(225));
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Label("Normal Strength:", GUILayout.MaxWidth(150));
|
||||
NormalStrength = EditorGUILayout.Slider(NormalStrength, 1f, 20f, GUILayout.MaxWidth(400));
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Label("Normal Smoothing:", GUILayout.MaxWidth(150));
|
||||
NormalSmoothing = EditorGUILayout.IntSlider(NormalSmoothing, 0, 3, GUILayout.MaxWidth(400));
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Label("Invert Normal Direction:", GUILayout.MaxWidth(150));
|
||||
InvertNormals = EditorGUILayout.Toggle(InvertNormals, GUILayout.MaxWidth(400));
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
if (IsComputingNormals == 0)
|
||||
{
|
||||
if (TargetNormalImage != null)
|
||||
{
|
||||
if (GUILayout.Button("Create And Save Normal Map", GUILayout.MaxWidth(CommonStyles.BUTTON_WIDTH)))
|
||||
{
|
||||
IsComputingNormals = 1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GUILayout.Label("Add a Target Image to use this feature", EditorStyles.boldLabel);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GUILayout.Label("Normal Map is currently being created, be patient", EditorStyles.boldLabel, GUILayout.Height(40));
|
||||
repaintAction();
|
||||
|
||||
IsComputingNormals++;
|
||||
if(IsComputingNormals > 5)
|
||||
{
|
||||
EditorUtils.SetTextureReadWrite(AssetDatabase.GetAssetPath(TargetNormalImage), true);
|
||||
|
||||
Texture2D normalMapToSave = normalMapCreatorTool.CreateNormalMap(InvertNormals);
|
||||
EditorUtils.SaveTextureAsPNG(GlobalConfiguration.instance.NormalMapSavePath, "NormalMap", "Normal Map", normalMapToSave, FilterMode.Bilinear, TextureImporterType.NormalMap, TextureWrapMode.Repeat);
|
||||
|
||||
IsComputingNormals = 0;
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.Label("*This process will freeze the editor for some seconds, larger images will take longer", EditorStyles.boldLabel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6304f118428d4744c8f82a134c469288
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Drawers/NormalMapCreatorDrawer.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,67 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class NormalMapEffectDrawer : AbstractEffectDrawer
|
||||
{
|
||||
private int mainTexPropertyIndex;
|
||||
private EffectProperty effectPropNormalMap;
|
||||
private EffectProperty effectPropNormalStrength;
|
||||
|
||||
private bool invertNormalMapDirection = false;
|
||||
private float normalCreateStrength = 2.0f;
|
||||
private float normalCreateSmooth = 1.0f;
|
||||
|
||||
public NormalMapEffectDrawer(AllIn13DShaderInspectorReferences references,
|
||||
PropertiesConfig propertiesConfig) : base(references, propertiesConfig)
|
||||
{
|
||||
drawerID = Constants.NORMAL_MAP_EFFECT_DRAWER_ID;
|
||||
|
||||
effectConfig = propertiesConfig.FindEffectConfigByID("NORMAL_MAP");
|
||||
|
||||
mainTexPropertyIndex = FindPropertyIndex("_MainTex");
|
||||
effectPropNormalMap = effectConfig.FindEffectPropertyByName("_NormalMap");
|
||||
effectPropNormalStrength = effectConfig.FindEffectPropertyByName("_NormalStrength");
|
||||
}
|
||||
|
||||
protected override void DrawProperties()
|
||||
{
|
||||
DrawProperty(effectPropNormalMap);
|
||||
DrawProperty(effectPropNormalStrength);
|
||||
|
||||
EditorUtils.DrawLine(Color.grey, 1, 3);
|
||||
EditorGUILayout.LabelField("Normal Map Creation", EditorStyles.boldLabel);
|
||||
|
||||
EditorUtils.TextureEditorFloatParameter("Strength", ref normalCreateStrength, 0.1f, 8.0f, 2.0f);
|
||||
EditorUtils.TextureEditorFloatParameter("Smooth", ref normalCreateSmooth, 0.0f, 5.0f, 1.0f);
|
||||
invertNormalMapDirection = EditorGUILayout.Toggle("Invert Normal Direction", invertNormalMapDirection);
|
||||
|
||||
GUILayout.Space(2);
|
||||
if(GUILayout.Button("Create Normal Map Texture")) CreateNormalMap();
|
||||
}
|
||||
|
||||
private void CreateNormalMap()
|
||||
{
|
||||
Texture2D sourceTexture = references.matProperties[mainTexPropertyIndex].textureValue as Texture2D;
|
||||
if(sourceTexture == null)
|
||||
{
|
||||
EditorUtility.DisplayDialog("Error", "No Main Tex found. Please assign it first", "OK");
|
||||
return;
|
||||
}
|
||||
EditorUtils.SetTextureReadWrite(AssetDatabase.GetAssetPath(sourceTexture), true);
|
||||
NormalMapCreatorTool normalMapCreatorTool = new NormalMapCreatorTool
|
||||
{
|
||||
targetNormalImage = sourceTexture,
|
||||
normalStrength = normalCreateStrength,
|
||||
normalSmoothing = Mathf.RoundToInt(normalCreateSmooth),
|
||||
isComputingNormals = 1
|
||||
};
|
||||
Texture2D normalMapToSave = normalMapCreatorTool.CreateNormalMap(invertNormalMapDirection);
|
||||
Texture savedTex = EditorUtils.SaveTextureAsPNG(GlobalConfiguration.instance.NormalMapSavePath, "NormalMap", "Normal Map", normalMapToSave, FilterMode.Bilinear, TextureImporterType.NormalMap, TextureWrapMode.Repeat);
|
||||
normalMapCreatorTool.isComputingNormals = 0;
|
||||
|
||||
references.matProperties[effectPropNormalMap.propertyIndex].textureValue = savedTex;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 160bf870855ebf849b074fb395bf0e99
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Drawers/NormalMapEffectDrawer.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,131 @@
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class RGBAPackerDrawer
|
||||
{
|
||||
private const float LABEL_WIDTH = 70f;
|
||||
private const float TEXTURE_FIELD_WIDTH = 200f;
|
||||
private const float SPACING_BETWEEN_FIELDS = 20f;
|
||||
private const float BOOLEAN_LABEL_WIDTH = 100f;
|
||||
private const float SETTINGS_FIELD_WIDTH = 200f;
|
||||
|
||||
private RGBAPackerTool rgbaPackerTool;
|
||||
|
||||
public RGBAPackerValues ToolValues => rgbaPackerTool.values;
|
||||
|
||||
private CommonStyles commonStyles;
|
||||
|
||||
public RGBAPackerDrawer(RGBAPackerTool rgbaPackerTool, CommonStyles commonStyles)
|
||||
{
|
||||
this.rgbaPackerTool = rgbaPackerTool;
|
||||
this.commonStyles = commonStyles;
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
GUILayout.Label("RGBA Channel Packer", commonStyles.bigLabel);
|
||||
GUILayout.Space(20);
|
||||
GUILayout.Label("Pack red channels from 4 textures into RGBA channels", EditorStyles.boldLabel);
|
||||
GUILayout.Space(10);
|
||||
|
||||
// Channel texture slots
|
||||
EditorGUILayout.BeginVertical();
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Label("R Channel", GUILayout.Width(LABEL_WIDTH));
|
||||
ToolValues.rChannelTexture = (Texture2D)EditorGUILayout.ObjectField(ToolValues.rChannelTexture, typeof(Texture2D), false, GUILayout.Width(TEXTURE_FIELD_WIDTH));
|
||||
GUILayout.Space(SPACING_BETWEEN_FIELDS);
|
||||
GUILayout.Label("Default Is White?", GUILayout.Width(BOOLEAN_LABEL_WIDTH));
|
||||
ToolValues.rChannelDefaultWhite = EditorGUILayout.Toggle(ToolValues.rChannelDefaultWhite);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Label("G Channel", GUILayout.Width(LABEL_WIDTH));
|
||||
ToolValues.gChannelTexture = (Texture2D)EditorGUILayout.ObjectField(ToolValues.gChannelTexture, typeof(Texture2D), false, GUILayout.Width(TEXTURE_FIELD_WIDTH));
|
||||
GUILayout.Space(SPACING_BETWEEN_FIELDS);
|
||||
GUILayout.Label("Default Is White?", GUILayout.Width(BOOLEAN_LABEL_WIDTH));
|
||||
ToolValues.gChannelDefaultWhite = EditorGUILayout.Toggle(ToolValues.gChannelDefaultWhite);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Label("B Channel", GUILayout.Width(LABEL_WIDTH));
|
||||
ToolValues.bChannelTexture = (Texture2D)EditorGUILayout.ObjectField(ToolValues.bChannelTexture, typeof(Texture2D), false, GUILayout.Width(TEXTURE_FIELD_WIDTH));
|
||||
GUILayout.Space(SPACING_BETWEEN_FIELDS);
|
||||
GUILayout.Label("Default Is White?", GUILayout.Width(BOOLEAN_LABEL_WIDTH));
|
||||
ToolValues.bChannelDefaultWhite = EditorGUILayout.Toggle(ToolValues.bChannelDefaultWhite);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Label("A Channel", GUILayout.Width(LABEL_WIDTH));
|
||||
ToolValues.aChannelTexture = (Texture2D)EditorGUILayout.ObjectField(ToolValues.aChannelTexture, typeof(Texture2D), false, GUILayout.Width(TEXTURE_FIELD_WIDTH));
|
||||
GUILayout.Space(SPACING_BETWEEN_FIELDS);
|
||||
GUILayout.Label("Default Is White?", GUILayout.Width(BOOLEAN_LABEL_WIDTH));
|
||||
ToolValues.aChannelDefaultWhite = EditorGUILayout.Toggle(ToolValues.aChannelDefaultWhite);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
GUILayout.Space(15);
|
||||
|
||||
// Texture settings
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Label("Texture Size:", GUILayout.MaxWidth(100));
|
||||
ToolValues.textureSizes = (TextureSizes)EditorGUILayout.EnumPopup(ToolValues.textureSizes, GUILayout.MaxWidth(SETTINGS_FIELD_WIDTH));
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Label("Filtering:", GUILayout.MaxWidth(100));
|
||||
ToolValues.filtering = (FilterMode)EditorGUILayout.EnumPopup(ToolValues.filtering, GUILayout.MaxWidth(SETTINGS_FIELD_WIDTH));
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.Space(10);
|
||||
|
||||
// Info about input channels
|
||||
int channelCount = 0;
|
||||
if(ToolValues.rChannelTexture != null) channelCount++;
|
||||
if(ToolValues.gChannelTexture != null) channelCount++;
|
||||
if(ToolValues.bChannelTexture != null) channelCount++;
|
||||
if(ToolValues.aChannelTexture != null) channelCount++;
|
||||
|
||||
int textureSize = (int)ToolValues.textureSizes;
|
||||
GUILayout.Label($"Output will be a {textureSize}x{textureSize} RGBA texture with {channelCount}/4 channels assigned", EditorStyles.boldLabel);
|
||||
|
||||
if(channelCount == 0)
|
||||
{
|
||||
GUILayout.Label("*No input textures assigned - output will use default values", EditorStyles.boldLabel);
|
||||
}
|
||||
else if(channelCount < 4)
|
||||
{
|
||||
GUILayout.Label($"*{4 - channelCount} channels will use default values (black or white based on toggles)", EditorStyles.boldLabel);
|
||||
}
|
||||
|
||||
GUILayout.Space(20);
|
||||
GUILayout.Label("Select the folder where RGBA textures will be saved", EditorStyles.boldLabel);
|
||||
GlobalConfiguration.instance.AtlasesSavePath = EditorUtils.DrawSelectorFolder(GlobalConfiguration.instance.AtlasesSavePath, "RGBA");
|
||||
|
||||
if(Directory.Exists(GlobalConfiguration.instance.AtlasesSavePath))
|
||||
{
|
||||
if(GUILayout.Button("Create And Save RGBA Texture", GUILayout.MaxWidth(CommonStyles.BUTTON_WIDTH)))
|
||||
{
|
||||
rgbaPackerTool.CreateRGBATexture();
|
||||
EditorUtils.SaveTextureAsPNG(GlobalConfiguration.instance.AtlasesSavePath, "RGBA_Packed", "RGBA Channel Packed Texture", ToolValues.createdRGBATexture, ToolValues.filtering, TextureImporterType.Default, TextureWrapMode.Clamp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: abdebde6324c8434180274a2f8375efe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Drawers/RGBAPackerDrawer.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,168 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class TextureBlendingEffectDrawer : AbstractEffectDrawer
|
||||
{
|
||||
private int mainTexPropertyIndex;
|
||||
private EffectProperty mainNormalEffectProperty;
|
||||
|
||||
private EffectProperty effectPropBlendingSource;
|
||||
|
||||
private EffectProperty effectPropTexBlendingMask;
|
||||
private EffectProperty effectPropBlendingMaskCutoffG;
|
||||
private EffectProperty effectPropBlendingMaskSmoothnessG;
|
||||
private EffectProperty effectPropBlendingMaskCutoffB;
|
||||
private EffectProperty effectPropBlendingMaskSmoothnessB;
|
||||
|
||||
private EffectProperty effectPropBlendingMaskCutoffWhite;
|
||||
private EffectProperty effectPropBlendingMaskSmoothnessWhite;
|
||||
|
||||
private EffectProperty effectPropBlendingMode;
|
||||
|
||||
private EffectProperty effectPropBlendingTextureG;
|
||||
private EffectProperty effectPropBlendingTextureB;
|
||||
private EffectProperty effectPropBlendingTextureWhite;
|
||||
|
||||
private EffectProperty effectPropBlendingNormalMapG;
|
||||
private EffectProperty effectPropBlendingNormalMapB;
|
||||
private EffectProperty effectPropBlendingNormalMapWhite;
|
||||
|
||||
public TextureBlendingEffectDrawer(EffectProperty mainNormalMapEffectProperty, AllIn13DShaderInspectorReferences references,
|
||||
PropertiesConfig propertiesConfig) : base(references, propertiesConfig)
|
||||
{
|
||||
this.drawerID = Constants.TEXTURE_BLENDING_EFFECT_DRAWER_ID;
|
||||
|
||||
mainTexPropertyIndex = FindPropertyIndex("_MainTex");
|
||||
this.mainNormalEffectProperty = mainNormalMapEffectProperty;
|
||||
|
||||
this.effectConfig = propertiesConfig.FindEffectConfigByID("TEXTURE_BLENDING");
|
||||
|
||||
this.effectPropBlendingSource = effectConfig.FindEffectPropertyByName("_TextureBlendingSource");
|
||||
|
||||
this.effectPropTexBlendingMask = effectConfig.FindEffectPropertyByName("_TexBlendingMask");
|
||||
this.effectPropBlendingMaskCutoffG = effectConfig.FindEffectPropertyByName("_BlendingMaskCutoffG");
|
||||
this.effectPropBlendingMaskSmoothnessG = effectConfig.FindEffectPropertyByName("_BlendingMaskSmoothnessG");
|
||||
this.effectPropBlendingMaskCutoffB = effectConfig.FindEffectPropertyByName("_BlendingMaskCutoffB");
|
||||
this.effectPropBlendingMaskSmoothnessB = effectConfig.FindEffectPropertyByName("_BlendingMaskSmoothnessB");
|
||||
|
||||
this.effectPropBlendingMaskCutoffWhite = effectConfig.FindEffectPropertyByName("_BlendingMaskCutoffWhite");
|
||||
this.effectPropBlendingMaskSmoothnessWhite = effectConfig.FindEffectPropertyByName("_BlendingMaskSmoothnessWhite");
|
||||
|
||||
this.effectPropBlendingMode = effectConfig.FindEffectPropertyByName("_TextureBlendingMode");
|
||||
|
||||
this.effectPropBlendingTextureG = effectConfig.FindEffectPropertyByName("_BlendingTextureG");
|
||||
this.effectPropBlendingTextureB = effectConfig.FindEffectPropertyByName("_BlendingTextureB");
|
||||
this.effectPropBlendingTextureWhite = effectConfig.FindEffectPropertyByName("_BlendingTextureWhite");
|
||||
|
||||
this.effectPropBlendingNormalMapG = effectConfig.FindEffectPropertyByName("_BlendingNormalMapG");
|
||||
this.effectPropBlendingNormalMapB = effectConfig.FindEffectPropertyByName("_BlendingNormalMapB");
|
||||
this.effectPropBlendingNormalMapWhite = effectConfig.FindEffectPropertyByName("_BlendingNormalMapWhite");
|
||||
}
|
||||
|
||||
protected override void DrawProperties()
|
||||
{
|
||||
bool isRGBMode = references.IsKeywordEnabled("_TEXTUREBLENDINGMODE_RGB");
|
||||
bool isBlendingSourceTexture = references.IsKeywordEnabled("_TEXTUREBLENDINGSOURCE_TEXTURE");
|
||||
bool isNormalEnabled = references.IsKeywordEnabled("_NORMAL_MAP_ON");
|
||||
|
||||
DrawProperty(effectPropBlendingSource);
|
||||
if(IsEffectPropertyVisible(effectPropTexBlendingMask, references.targetMatInfos))
|
||||
{
|
||||
DrawProperty(effectPropTexBlendingMask);
|
||||
}
|
||||
|
||||
|
||||
DrawProperty(effectPropBlendingMode);
|
||||
|
||||
GUILayout.Space(20f);
|
||||
|
||||
MaterialProperty matPropertyMainNormalMap = references.matProperties[mainNormalEffectProperty.propertyIndex];
|
||||
if (isRGBMode)
|
||||
{
|
||||
EffectPropertyDrawer.DrawProperty(
|
||||
materialProperty: references.matProperties[mainTexPropertyIndex],
|
||||
labelPrefix: string.Empty,
|
||||
displayName: $"{references.matProperties[mainTexPropertyIndex].displayName} (R)",
|
||||
customValue: string.Empty,
|
||||
allowReset: true,
|
||||
isKeywordProperty: false,
|
||||
propertyType: EffectProperty.PropertyType.BASIC,
|
||||
references: references);
|
||||
|
||||
if (isNormalEnabled)
|
||||
{
|
||||
EffectPropertyDrawer.DrawProperty(
|
||||
materialProperty: matPropertyMainNormalMap,
|
||||
labelPrefix: string.Empty,
|
||||
displayName: $"{matPropertyMainNormalMap.displayName} (R)",
|
||||
customValue: string.Empty,
|
||||
allowReset: true,
|
||||
isKeywordProperty: false,
|
||||
propertyType: EffectProperty.PropertyType.BASIC,
|
||||
references: references);
|
||||
}
|
||||
|
||||
GUILayout.Space(20f);
|
||||
|
||||
DrawProperty(effectPropBlendingTextureG);
|
||||
if (isNormalEnabled)
|
||||
{
|
||||
DrawProperty(effectPropBlendingNormalMapG);
|
||||
}
|
||||
|
||||
DrawProperty(effectPropBlendingMaskCutoffG);
|
||||
DrawProperty(effectPropBlendingMaskSmoothnessG);
|
||||
GUILayout.Space(20f);
|
||||
|
||||
DrawProperty(effectPropBlendingTextureB);
|
||||
if (isNormalEnabled)
|
||||
{
|
||||
DrawProperty(effectPropBlendingNormalMapB);
|
||||
}
|
||||
|
||||
DrawProperty(effectPropBlendingMaskCutoffB);
|
||||
DrawProperty(effectPropBlendingMaskSmoothnessB);
|
||||
GUILayout.Space(20f);
|
||||
}
|
||||
else
|
||||
{
|
||||
EffectPropertyDrawer.DrawProperty(
|
||||
materialProperty: references.matProperties[mainTexPropertyIndex],
|
||||
labelPrefix: string.Empty,
|
||||
displayName: $"{references.matProperties[mainTexPropertyIndex].displayName} (Black)",
|
||||
customValue: string.Empty,
|
||||
allowReset: true,
|
||||
isKeywordProperty: false,
|
||||
propertyType: EffectProperty.PropertyType.BASIC,
|
||||
references: references);
|
||||
|
||||
if (isNormalEnabled)
|
||||
{
|
||||
EffectPropertyDrawer.DrawProperty(
|
||||
materialProperty: matPropertyMainNormalMap,
|
||||
labelPrefix: string.Empty,
|
||||
displayName: $"{matPropertyMainNormalMap.displayName} (R)",
|
||||
customValue: string.Empty,
|
||||
allowReset: true,
|
||||
isKeywordProperty: false,
|
||||
propertyType: EffectProperty.PropertyType.BASIC,
|
||||
references: references);
|
||||
}
|
||||
|
||||
DrawProperty(effectPropBlendingTextureWhite);
|
||||
if (isNormalEnabled)
|
||||
{
|
||||
DrawProperty(effectPropBlendingNormalMapWhite);
|
||||
}
|
||||
|
||||
if (isBlendingSourceTexture)
|
||||
{
|
||||
DrawProperty(effectPropBlendingMaskCutoffWhite);
|
||||
DrawProperty(effectPropBlendingMaskSmoothnessWhite);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 081c5e8bfd291a145abf082e4835e2b2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Drawers/TextureBlendingEffectDrawer.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,172 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class TextureEditorValuesDrawer
|
||||
{
|
||||
private TextureEditorTool textureEditorTool;
|
||||
|
||||
|
||||
private TextureEditorValues values
|
||||
{
|
||||
get
|
||||
{
|
||||
return textureEditorTool.values;
|
||||
}
|
||||
}
|
||||
|
||||
private Texture2D editorTexInput
|
||||
{
|
||||
get
|
||||
{
|
||||
return textureEditorTool.editorTexInput;
|
||||
}
|
||||
}
|
||||
|
||||
private Texture2D editorTex
|
||||
{
|
||||
get
|
||||
{
|
||||
return textureEditorTool.editorTex;
|
||||
}
|
||||
}
|
||||
|
||||
private Texture2D cleanEditorTex
|
||||
{
|
||||
get
|
||||
{
|
||||
return textureEditorTool.cleanEditorTex;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private const int BUTTON_WIDTH = 600;
|
||||
|
||||
|
||||
public void Setup(TextureEditorTool textureEditorTool)
|
||||
{
|
||||
this.textureEditorTool = textureEditorTool;
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
|
||||
if (!values.showOriginalImage)
|
||||
{
|
||||
GUILayout.Label(editorTex);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUILayout.Label(cleanEditorTex);
|
||||
}
|
||||
|
||||
EditorGUILayout.BeginVertical();
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorUtils.TextureEditorColorParameter("Color Tint", ref values.editorColorTint, Color.white);
|
||||
EditorUtils.TextureEditorFloatParameter("Brightness", ref values.brightness, -1f, 5f);
|
||||
EditorUtils.TextureEditorFloatParameter("Contrast", ref values.contrast, 0.0f, 5.0f, 1f);
|
||||
EditorUtils.TextureEditorFloatParameter("Gamma", ref values.gamma, 0.0f, 10f, 1f);
|
||||
EditorUtils.TextureEditorFloatParameter("Exposure", ref values.exposure, -5f, 5f, 0f);
|
||||
EditorUtils.TextureEditorFloatParameter("Saturation", ref values.saturation, 0f, 5f, 1f);
|
||||
EditorUtils.TextureEditorFloatParameter("Hue", ref values.hue, 0f, 360f, 0f);
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
values.invert = EditorGUILayout.Toggle("Invert", values.invert, GUILayout.Width(253));
|
||||
values.greyscale = EditorGUILayout.Toggle("Greyscale", values.greyscale);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
values.fullWhite = EditorGUILayout.Toggle("Fully white", values.fullWhite, GUILayout.Width(253));
|
||||
values.blackBackground = EditorGUILayout.Toggle("Black background", values.blackBackground);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
values.alphaGreyscale = EditorGUILayout.Toggle("Greyscale is alpha", values.alphaGreyscale, GUILayout.Width(253));
|
||||
values.alphaIsOne = EditorGUILayout.Toggle("Alpha to 1", values.alphaIsOne);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
textureEditorTool.RecalculateEditorTexture();
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
if (GUILayout.Button("Rotate Left 90°", GUILayout.MaxWidth(210)))
|
||||
{
|
||||
textureEditorTool.RotateEditorTextureLeft();
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Rotate Right 90°", GUILayout.MaxWidth(210)))
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
textureEditorTool.RotateEditorTextureLeft();
|
||||
}
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
if (GUILayout.Button("Flip Horizontal", GUILayout.MaxWidth(210)))
|
||||
{
|
||||
textureEditorTool.FlipEditorTexture(true);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Flip Vertical", GUILayout.MaxWidth(210)))
|
||||
{
|
||||
textureEditorTool.FlipEditorTexture(false);
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.Space();
|
||||
if (!values.showOriginalImage)
|
||||
{
|
||||
if (GUILayout.Button("Press to show Original Image", GUILayout.MaxWidth(425)))
|
||||
{
|
||||
values.showOriginalImage = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Color backgroundColor = GUI.backgroundColor;
|
||||
GUI.backgroundColor = Color.red;
|
||||
if (GUILayout.Button("Press to show Editor Image", GUILayout.MaxWidth(425)))
|
||||
{
|
||||
values.showOriginalImage = false;
|
||||
}
|
||||
GUI.backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.Label("*Preview is locked to 256px maximum (bigger textures are scaled down), but the image will be saved to its full resolution", EditorStyles.boldLabel);
|
||||
|
||||
EditorUtils.DrawThinLine();
|
||||
EditorGUILayout.Space();
|
||||
EditorUtils.TextureEditorFloatParameter("Export Scale", ref values.exportScale, 0.01f, 2f, 1f);
|
||||
int currWidth = Mathf.ClosestPowerOfTwo((int)(editorTexInput.width * values.exportScale));
|
||||
int currHeight = Mathf.ClosestPowerOfTwo((int)(editorTexInput.height * values.exportScale));
|
||||
GUILayout.Label("Current export size is: " + currWidth + " x " + currHeight + " (size snaps to the closest power of 2)", EditorStyles.boldLabel);
|
||||
|
||||
if (GUILayout.Button("Save Resulting Image as PNG file", GUILayout.MaxWidth(BUTTON_WIDTH)))
|
||||
{
|
||||
textureEditorTool.SaveAsPNG();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d9909526746655a4a9be1aaef56a41b9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Drawers/TextureEditorValuesDrawer.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,63 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class TriplanarEffectDrawer : AbstractEffectDrawer
|
||||
{
|
||||
private int mainTexPropertyIndex;
|
||||
private EffectProperty mainNormalMapProperty;
|
||||
|
||||
public TriplanarEffectDrawer(EffectProperty mainNormalMapProperty, AllIn13DShaderInspectorReferences references,
|
||||
PropertiesConfig propertiesConfig) : base(references, propertiesConfig)
|
||||
{
|
||||
this.drawerID = Constants.TRIPLANAR_EFFECT_DRAWER_ID;
|
||||
this.mainNormalMapProperty = mainNormalMapProperty;
|
||||
|
||||
mainTexPropertyIndex = FindPropertyIndex("_MainTex");
|
||||
}
|
||||
|
||||
protected override void DrawProperties()
|
||||
{
|
||||
bool isTriplanarNoiseTransitionEnabled = references.IsKeywordEnabled("_TRIPLANAR_NOISE_TRANSITION_ON");
|
||||
|
||||
MaterialProperty matProperty = references.matProperties[mainTexPropertyIndex];
|
||||
|
||||
EffectPropertyDrawer.DrawProperty(
|
||||
materialProperty: matProperty,
|
||||
labelPrefix: string.Empty,
|
||||
displayName: matProperty.displayName,
|
||||
customValue: string.Empty,
|
||||
allowReset: true,
|
||||
isKeywordProperty: false,
|
||||
propertyType: EffectProperty.PropertyType.BASIC,
|
||||
references: references);
|
||||
|
||||
EffectProperty triplanarNoiseTransitionToggleProperty = effectConfig.effectProperties[6];
|
||||
|
||||
DrawProperty(effectConfig.effectProperties[0]);
|
||||
DrawProperty(effectConfig.effectProperties[1]);
|
||||
|
||||
if (IsEffectPropertyVisible(mainNormalMapProperty, references.targetMatInfos))
|
||||
{
|
||||
EditorUtils.DrawLine(Color.grey, 1, 3);
|
||||
DrawProperty(mainNormalMapProperty, false);
|
||||
DrawProperty(effectConfig.effectProperties[2]);
|
||||
}
|
||||
|
||||
EditorUtils.DrawLine(Color.grey, 1, 3);
|
||||
DrawProperty(effectConfig.effectProperties[3]);
|
||||
DrawProperty(effectConfig.effectProperties[4]);
|
||||
|
||||
EditorUtils.DrawLine(Color.grey, 1, 3);
|
||||
DrawProperty(effectConfig.effectProperties[5]);
|
||||
DrawProperty(triplanarNoiseTransitionToggleProperty);
|
||||
|
||||
if (isTriplanarNoiseTransitionEnabled)
|
||||
{
|
||||
DrawProperty(effectConfig.effectProperties[7]);
|
||||
DrawProperty(effectConfig.effectProperties[8]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 580ede76f9fd8d844ab570643abe14cd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Drawers/TriplanarEffectDrawer.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,40 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class Vector2Drawer : MaterialPropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
AllIn1ShaderPropertyType propType = EditorUtils.GetShaderTypeByMaterialProperty(prop);
|
||||
if (propType != AllIn1ShaderPropertyType.Vector)
|
||||
{
|
||||
EditorGUI.LabelField(position, label, "Vector3Drawer only works with Vector properties.");
|
||||
return;
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
// Get current vector4 value
|
||||
Vector4 vec4Value = prop.vectorValue;
|
||||
|
||||
// Convert to Vector2 for editing
|
||||
Vector2 vec2Value = new Vector2(vec4Value.x, vec4Value.y);
|
||||
|
||||
// Create property field for Vector3
|
||||
vec2Value = EditorGUI.Vector2Field(position, label, vec2Value);
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
// Convert back to Vector4, preserving the w component
|
||||
prop.vectorValue = new Vector4(vec2Value.x, vec2Value.y, vec4Value.z, vec4Value.w);
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
return EditorGUIUtility.singleLineHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 87a63d9b7f80f9f4bbbe3ae4dc5b0e2a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Drawers/Vector2Drawer.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,38 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class Vector3Drawer : MaterialPropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
AllIn1ShaderPropertyType propType = EditorUtils.GetShaderTypeByMaterialProperty(prop);
|
||||
if (propType != AllIn1ShaderPropertyType.Vector) {
|
||||
EditorGUI.LabelField(position, label, "Vector3Drawer only works with Vector properties.");
|
||||
return;
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
// Get current vector4 value
|
||||
Vector4 vec4Value = prop.vectorValue;
|
||||
|
||||
// Convert to Vector3 for editing
|
||||
Vector3 vec3Value = new Vector3(vec4Value.x, vec4Value.y, vec4Value.z);
|
||||
|
||||
// Create property field for Vector3
|
||||
vec3Value = EditorGUI.Vector3Field(position, label, vec3Value);
|
||||
|
||||
if(EditorGUI.EndChangeCheck()) {
|
||||
// Convert back to Vector4, preserving the w component
|
||||
prop.vectorValue = new Vector4(vec3Value.x, vec3Value.y, vec3Value.z, vec4Value.w);
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
return EditorGUIUtility.singleLineHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba6a058864ddc094aa1e321cab78ebd2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Drawers/Vector3Drawer.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,76 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class EditorEventManager : AssetPostprocessor
|
||||
{
|
||||
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths, bool didDomainReload)
|
||||
{
|
||||
bool assetImportedForTheFirstTime = IsAssetImportedForTheFirstTime(importedAssets);
|
||||
if (assetImportedForTheFirstTime)
|
||||
{
|
||||
Debug.Log("Setting up AllIn13DShader for the first time...");
|
||||
}
|
||||
|
||||
#if ALLIN13DSHADER_URP
|
||||
URPConfigurator.CheckURPRemoved(deletedAssets, didDomainReload);
|
||||
#endif
|
||||
GlobalConfiguration.InitIfNeeded();
|
||||
|
||||
PropertiesConfigCollection propertiesConfigCollection = PropertiesConfigCreator.InitIfNeeded(importedAssets, deletedAssets, movedAssets, movedFromAssetPaths, didDomainReload);
|
||||
//GlobalConfiguration.SetPropertiesConfigCollection(propertiesConfigCollection);
|
||||
GlobalConfiguration.SetupShadersReferences();
|
||||
|
||||
EffectsProfileCollection effectsProfileCollection = EditorUtils.FindAsset<EffectsProfileCollection>(EffectsProfileCollection.ASSET_NAME);
|
||||
if (effectsProfileCollection == null)
|
||||
{
|
||||
effectsProfileCollection = EffectsProfileCollection.CreateAsset(propertiesConfigCollection);
|
||||
}
|
||||
|
||||
effectsProfileCollection.BindEffectConfigs(propertiesConfigCollection.propertiesConfig);
|
||||
|
||||
effectsProfileCollection.CleanInvalidProfiles();
|
||||
effectsProfileCollection.CheckBakedShadersFolder(propertiesConfigCollection.propertiesConfig);
|
||||
|
||||
for (int i = 0; i < deletedAssets.Length; i++)
|
||||
{
|
||||
if (deletedAssets[i].EndsWith(".shader"))
|
||||
{
|
||||
effectsProfileCollection.CheckRemovedShader(deletedAssets[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (assetImportedForTheFirstTime)
|
||||
{
|
||||
ShaderFeaturesFileCreator.CreateFile(effectsProfileCollection.generalProfile);
|
||||
}
|
||||
|
||||
GlobalConfiguration.instance.SetEffectsProfileCollection(effectsProfileCollection);
|
||||
GlobalConfiguration.instance.shaderPassCollection = EditorUtils.FindAsset<ShaderPassCollection>("ShaderPassCollection");
|
||||
|
||||
URPSettingsUserPref urpSettingsUserPrefs = URPSettingsUserPref.InitIfNeeded();
|
||||
GlobalConfiguration.instance.urpSettingsUserPref = urpSettingsUserPrefs;
|
||||
|
||||
#if ALLIN13DSHADER_URP
|
||||
URPConfigurator.AllAssetProcessed();
|
||||
AllIn13DShaderWindow.AllAssetProcessed();
|
||||
#endif
|
||||
}
|
||||
|
||||
private static bool IsAssetImportedForTheFirstTime(string[] importedAssets)
|
||||
{
|
||||
bool res = false;
|
||||
for(int i = 0; i < importedAssets.Length; i++)
|
||||
{
|
||||
if (importedAssets[i].EndsWith(Constants.MAIN_ASSEMBLY_NAME))
|
||||
{
|
||||
res = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user