using System.Collections.Generic; using System.Linq; using System.Text; namespace UnityEngine.MaterialGraph { public class PropertyGenerator { public struct TextureInfo { public string name; public int textureId; public TexturePropertyChunk.ModifiableState modifiable; } private readonly List m_Properties = new List(); public void AddShaderProperty(PropertyChunk chunk) { m_Properties.Add(chunk); } public string GetShaderString(int baseIndentLevel) { var sb = new StringBuilder(); foreach (var prop in m_Properties) { for (var i = 0; i < baseIndentLevel; i++) sb.Append("\t"); sb.AppendLine(prop.GetPropertyString()); } return sb.ToString(); } public List GetConfiguredTexutres() { var result = new List(); foreach (var prop in m_Properties.OfType()) { if (prop.propertyName != null) { var textureInfo = new TextureInfo { name = prop.propertyName, textureId = prop.defaultTexture != null ? prop.defaultTexture.GetInstanceID() : 0, modifiable = prop.modifiableState }; result.Add(textureInfo); } } return result; } } }