From b82da95b5181ac8bbae38efb13e950d5e88a4caa Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 23 Oct 2020 13:08:43 +0800 Subject: =?UTF-8?q?*=E7=A7=BB=E5=8A=A8amplify=20shader=20editor=E5=88=B0th?= =?UTF-8?q?ird=20party=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Plugins/Editor/Templates/TemplateDataParent.cs | 217 +++++++++++++++++++++ 1 file changed, 217 insertions(+) create mode 100644 Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Templates/TemplateDataParent.cs (limited to 'Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Templates/TemplateDataParent.cs') diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Templates/TemplateDataParent.cs b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Templates/TemplateDataParent.cs new file mode 100644 index 00000000..b7c3fd02 --- /dev/null +++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Templates/TemplateDataParent.cs @@ -0,0 +1,217 @@ +// Amplify Shader Editor - Visual Shader Editing Tool +// Copyright (c) Amplify Creations, Lda + +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace AmplifyShaderEditor +{ + public enum TemplateDataType + { + LegacySinglePass, + MultiPass + } + + [Serializable] + public class TemplateIncludePragmaContainter + { + [SerializeField] + private int m_nativeTopIndex = -1; + + [SerializeField] + private List m_nativeDirectivesList = new List(); + + [SerializeField] + private List m_includesList = new List(); + private Dictionary m_includesDict = new Dictionary(); + + [SerializeField] + private List m_pragmasList = new List(); + private Dictionary m_pragmasDict = new Dictionary(); + + [SerializeField] + private List m_definesList = new List(); + private Dictionary m_definesDict = new Dictionary(); + + public void RefreshIncludesList() + { + if ( m_includesDict.Count != m_includesList.Count ) + { + m_includesDict.Clear(); + int count = m_includesList.Count; + for ( int i = 0; i < count; i++ ) + { + m_includesDict.Add( m_includesList[ i ], m_includesList[ i ] ); + } + } + } + + public void RefreshPragmasList() + { + if ( m_pragmasDict.Count != m_pragmasList.Count ) + { + m_pragmasDict.Clear(); + int count = m_pragmasList.Count; + for ( int i = 0; i < count; i++ ) + { + m_pragmasDict.Add( m_pragmasList[ i ], m_pragmasList[ i ] ); + } + } + } + + + public void RefreshDefinesList() + { + if ( m_definesDict.Count != m_definesList.Count ) + { + m_definesDict.Clear(); + int count = m_definesList.Count; + for ( int i = 0; i < count; i++ ) + { + m_definesDict.Add( m_definesList[ i ], m_definesList[ i ] ); + } + } + } + + public bool HasInclude( string include ) + { + RefreshIncludesList(); + return m_includesDict.ContainsKey( include ); + } + + public bool HasPragma( string pragma ) + { + RefreshPragmasList(); + return m_pragmasDict.ContainsKey( pragma ); + } + + public bool HasDefine( string pragma ) + { + RefreshDefinesList(); + return m_definesDict.ContainsKey( pragma ); + } + + public void AddInclude( string include ) + { + RefreshIncludesList(); + if ( !m_includesDict.ContainsKey( include ) ) + { + m_includesList.Add( include ); + m_includesDict.Add( include, include ); + } + } + + public void AddPragma( string pragma ) + { + RefreshPragmasList(); + if ( !m_pragmasDict.ContainsKey( pragma ) ) + { + m_pragmasList.Add( pragma ); + m_pragmasDict.Add( pragma, pragma ); + } + } + + public void AddDefine( string define ) + { + RefreshDefinesList(); + if ( !m_definesDict.ContainsKey( define ) ) + { + m_definesList.Add( define ); + m_definesDict.Add( define, define ); + } + } + + public void AddNativeDirective( string native, int topIndex ) + { + m_nativeTopIndex = topIndex; + m_nativeDirectivesList.Add( native ); + } + + public void Destroy() + { + m_nativeDirectivesList.Clear(); + m_nativeDirectivesList = null; + + + m_includesList.Clear(); + m_includesDict.Clear(); + m_includesList = null; + m_includesDict = null; + + m_pragmasList.Clear(); + m_pragmasDict.Clear(); + m_pragmasList = null; + m_pragmasDict = null; + + m_definesList.Clear(); + m_definesDict.Clear(); + m_definesList = null; + m_definesDict = null; + } + + public List IncludesList { get { return m_includesList; } } + public List PragmasList { get { return m_pragmasList; } } + public List DefinesList { get { return m_definesList; } } + public List NativeDirectivesList { get { return m_nativeDirectivesList; } } + public int NativeTopIndex { get { return m_nativeTopIndex; } } + + } + + [Serializable] + public class TemplateInfoContainer + { + public string Id = string.Empty; + public string Data = string.Empty; + public int Index = -1; + public bool IsValid { get { return Index > -1; } } + public void Reset() + { + Id = string.Empty; + Data = string.Empty; + Index = -1; + } + } + + [Serializable] + public class TemplateDataParent : ScriptableObject + { + [SerializeField] + protected TemplateDataType m_templateType; + + [SerializeField] + protected string m_name; + + [SerializeField] + protected string m_guid; + + [SerializeField] + protected int m_orderId; + + [SerializeField] + protected string m_defaultShaderName = string.Empty; + + [SerializeField] + protected bool m_isValid = true; + + [SerializeField] + protected bool m_communityTemplate = false; + + public virtual void Destroy() { } + public virtual bool Reload() { return true; } + public string Name + { + get { return m_name; } + set + { + m_name = value.StartsWith( "Hidden/" ) ? value.Replace( "Hidden/", string.Empty ) : value; + } + } + public string GUID { get { return m_guid; } set { m_guid = value; } } + public int OrderId { get { return m_orderId; } set { m_orderId = value; } } + public string DefaultShaderName { get { return m_defaultShaderName; } set { m_defaultShaderName = value; } } + public bool IsValid { get { return m_isValid; } } + public TemplateDataType TemplateType { get { return m_templateType; } } + public virtual void Init( string name, string guid, bool isCommunity ) { m_communityTemplate = isCommunity; } + } +} -- cgit v1.1-26-g67d0