This commit is contained in:
2025-11-26 21:34:22 +08:00
parent a2dc1f199a
commit be99a8ce1d
606 changed files with 8256 additions and 2685 deletions

View File

@@ -0,0 +1,75 @@
// Cristian Pop - https://boxophobic.com/
using UnityEngine;
using UnityEditor;
using System;
namespace Boxophobic.StyledGUI
{
public class StyledKeywordInvertedDrawer : MaterialPropertyDrawer
{
public string parentsStr = "";
public string propertiesStr = "";
public string keywordsStr = "";
public StyledKeywordInvertedDrawer(string propertiesStr, string keywordsStr)
{
this.propertiesStr = propertiesStr;
this.keywordsStr = keywordsStr;
}
public StyledKeywordInvertedDrawer(string parentsStr, string propertiesStr, string keywordsStr)
{
this.propertiesStr = propertiesStr;
this.keywordsStr = keywordsStr;
this.parentsStr = parentsStr;
}
public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor materialEditor)
{
Material material = materialEditor.target as Material;
var parents = keywordsStr.Split(" ");
var properties = propertiesStr.Split(" ");
var keywords = keywordsStr.Split(" ");
var parentCount = parents.Length;
var propertiesCount = properties.Length;
var keywordsCount = keywords.Length;
if (parentCount == 0)
{
if (propertiesCount == 0)
{
if (keywordsCount == 0)
{
SetMaterialKeywordInverted(material, properties[0], keywords[0]);
}
}
}
}
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
{
return -2;
}
void SetMaterialKeywordInverted(Material material, string property, string keyword)
{
if (material.HasFloat(property))
{
var mode = material.GetFloat(property);
if (mode == 0)
{
material.EnableKeyword(keyword);
}
else
{
material.DisableKeyword(keyword);
}
}
}
}
}