public void Destroy()
        {
            m_passNameContainer = null;
#if CUSTOM_OPTIONS_AVAILABLE
            m_customOptionsContainer = null;
#endif
            if (m_templateProperties != null)
            {
                m_templateProperties.Destroy();
            }

            m_templateProperties = null;

            if (m_modules != null)
            {
                m_modules.Destroy();
            }

            m_modules = null;

            if (m_inputDataList != null)
            {
                m_inputDataList.Clear();
            }

            m_inputDataList = null;

            if (m_inputDataDict != null)
            {
                m_inputDataDict.Clear();
            }

            m_inputDataDict = null;

            m_vertexFunctionData   = null;
            m_fragmentFunctionData = null;

            if (m_vertexDataContainer != null)
            {
                m_vertexDataContainer.Destroy();
            }

            m_vertexDataContainer = null;

            m_tessVControlTag = null;

            m_tessControlData = null;

            m_tessDomainData = null;

            if (m_interpolatorDataContainer != null)
            {
                m_interpolatorDataContainer.Destroy();
            }

            if (m_localVarsList != null)
            {
                m_localVarsList.Clear();
                m_localVarsList = null;
            }

            m_interpolatorDataContainer = null;

            if (m_availableShaderGlobals != null)
            {
                m_availableShaderGlobals.Clear();
            }

            m_availableShaderGlobals = null;
        }
Example #2
0
        public void Destroy()
        {
            if (m_vertexData != null)
            {
                m_vertexData.Clear();
                m_vertexData = null;
            }

            if (m_interpolatorData != null)
            {
                m_interpolatorData.Destroy();
                m_interpolatorData = null;
            }

            if (m_availableShaderProperties != null)
            {
                m_availableShaderProperties.Clear();
                m_availableShaderProperties = null;
            }

            if (m_propertyDict != null)
            {
                m_propertyDict.Clear();
                m_propertyDict = null;
            }

            if (m_propertyList != null)
            {
                m_propertyList.Clear();
                m_propertyList = null;
            }

            if (m_inputDataDict != null)
            {
                m_inputDataDict.Clear();
                m_inputDataDict = null;
            }

            if (m_inputDataList != null)
            {
                m_inputDataList.Clear();
                m_inputDataList = null;
            }

            if (m_snippetElementsDict != null)
            {
                m_snippetElementsDict.Clear();
                m_snippetElementsDict = null;
            }

            if (m_snippetElementsList != null)
            {
                for (int i = 0; i < m_snippetElementsList.Count; i++)
                {
                    GameObject.DestroyImmediate(m_snippetElementsList[i]);
                    m_snippetElementsList[i] = null;
                }
                m_snippetElementsList.Clear();
                m_snippetElementsList = null;
            }
        }
Example #3
0
        public void Destroy()
        {
            if (m_vertexData != null)
            {
                m_vertexData.Clear();
                m_vertexData = null;
            }

            if (m_interpolatorData != null)
            {
                m_interpolatorData.Destroy();
                m_interpolatorData = null;
            }

            if (m_availableShaderProperties != null)
            {
                m_availableShaderProperties.Clear();
                m_availableShaderProperties = null;
            }

            if (m_propertyDict != null)
            {
                m_propertyDict.Clear();
                m_propertyDict = null;
            }

            if (m_propertyList != null)
            {
                m_propertyList.Clear();
                m_propertyList = null;
            }

            if (m_inputDataDict != null)
            {
                m_inputDataDict.Clear();
                m_inputDataDict = null;
            }

            if (m_inputDataList != null)
            {
                m_inputDataList.Clear();
                m_inputDataList = null;
            }

            if (m_snippetElementsDict != null)
            {
                m_snippetElementsDict.Clear();
                m_snippetElementsDict = null;
            }

            if (m_snippetElementsList != null)
            {
                for (int i = 0; i < m_snippetElementsList.Count; i++)
                {
                    GameObject.DestroyImmediate(m_snippetElementsList[i]);
                    m_snippetElementsList[i] = null;
                }
                m_snippetElementsList.Clear();
                m_snippetElementsList = null;
            }
#if TEMPLATE_MODULES
            m_cullModeData  = null;
            m_blendData     = null;
            m_colorMaskData = null;
            m_stencilData   = null;
#endif
        }
Example #4
0
        void FetchCommonTags()
        {
            // Name
            try
            {
                int nameBegin = m_templateBody.IndexOf(TemplatesManager.TemplateShaderNameBeginTag);
                if (nameBegin < 0)
                {
                    // Not a template
                    return;
                }

                int nameEnd       = m_templateBody.IndexOf(TemplatesManager.TemplateFullEndTag, nameBegin);
                int defaultBegin  = nameBegin + TemplatesManager.TemplateShaderNameBeginTag.Length;
                int defaultLength = nameEnd - defaultBegin;
                m_defaultShaderName = m_templateBody.Substring(defaultBegin, defaultLength);
                int[] nameIdx = m_defaultShaderName.AllIndexesOf("\"");
                nameIdx[0]         += 1; // Ignore the " character from the string
                m_defaultShaderName = m_defaultShaderName.Substring(nameIdx[0], nameIdx[1] - nameIdx[0]);
                m_shaderNameId      = m_templateBody.Substring(nameBegin, nameEnd + TemplatesManager.TemplateFullEndTag.Length - nameBegin);
                AddId(m_shaderNameId, false);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                m_isValid = false;
            }
            // Vertex Data
            {
                int vertexDataTagBegin = m_templateBody.IndexOf(TemplatesManager.TemplateVertexDataTag);
                if (vertexDataTagBegin > -1)
                {
                    int vertexDataTagEnd = m_templateBody.IndexOf(TemplatesManager.TemplateEndOfLine, vertexDataTagBegin);
                    m_vertexDataId = m_templateBody.Substring(vertexDataTagBegin, vertexDataTagEnd + TemplatesManager.TemplateEndOfLine.Length - vertexDataTagBegin);
                    int    dataBeginIdx = m_templateBody.LastIndexOf('{', vertexDataTagBegin, vertexDataTagBegin);
                    string vertexData   = m_templateBody.Substring(dataBeginIdx + 1, vertexDataTagBegin - dataBeginIdx);

                    int    parametersBegin = vertexDataTagBegin + TemplatesManager.TemplateVertexDataTag.Length;
                    string parameters      = m_templateBody.Substring(parametersBegin, vertexDataTagEnd - parametersBegin);
                    m_vertexData = TemplateHelperFunctions.CreateVertexDataList(vertexData, parameters);
                    AddId(m_vertexDataId);
                }
            }

            // Available interpolators
            try
            {
                int interpDataBegin = m_templateBody.IndexOf(TemplatesManager.TemplateInterpolatorBeginTag);
                if (interpDataBegin > -1)
                {
                    int interpDataEnd = m_templateBody.IndexOf(TemplatesManager.TemplateEndOfLine, interpDataBegin);
                    m_interpDataId = m_templateBody.Substring(interpDataBegin, interpDataEnd + TemplatesManager.TemplateEndOfLine.Length - interpDataBegin);

                    int    dataBeginIdx = m_templateBody.LastIndexOf('{', interpDataBegin, interpDataBegin);
                    string interpData   = m_templateBody.Substring(dataBeginIdx + 1, interpDataBegin - dataBeginIdx);

                    m_interpolatorData = TemplateHelperFunctions.CreateInterpDataList(interpData, m_interpDataId);
                    AddId(m_interpDataId);
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                m_isValid = false;
            }

            try
            {
                Dictionary <string, TemplateShaderPropertyData> duplicatesHelper = new Dictionary <string, TemplateShaderPropertyData>();
                m_availableShaderProperties = new List <TemplateShaderPropertyData>();
                // Common Tags
                for (int i = 0; i < TemplatesManager.CommonTags.Length; i++)
                {
                    int idx = m_templateBody.IndexOf(TemplatesManager.CommonTags[i].Id);
                    if (idx > -1)
                    {
                        //properties
                        if (i == (int)TemplateCommonTagId.Property)
                        {
                            TemplateHelperFunctions.CreateShaderPropertiesList(m_templateBody.Substring(0, idx + TemplatesManager.CommonTags[i].Id.Length), ref m_availableShaderProperties, ref duplicatesHelper);
                        }
                        // globals
                        if (i == (int)TemplateCommonTagId.Global)
                        {
                            TemplateHelperFunctions.CreateShaderGlobalsList(m_templateBody.Substring(0, idx + TemplatesManager.CommonTags[i].Id.Length), ref m_availableShaderProperties, ref duplicatesHelper);
                        }
                        AddId(TemplatesManager.CommonTags[i]);
                        if (i == (int)TemplateCommonTagId.Tag)
                        {
                            m_propertyList[m_propertyList.Count - 1].Indentation = " ";
                        }
                    }
                }
                duplicatesHelper.Clear();
                duplicatesHelper = null;
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                m_isValid = false;
            }
        }
Example #5
0
        void FetchCommonTags()
        {
            // Name
            try
            {
                int nameBegin = m_templateBody.IndexOf(TemplatesManager.TemplateShaderNameBeginTag);
                if (nameBegin < 0)
                {
                    // Not a template
                    return;
                }

                int nameEnd       = m_templateBody.IndexOf(TemplatesManager.TemplateFullEndTag, nameBegin);
                int defaultBegin  = nameBegin + TemplatesManager.TemplateShaderNameBeginTag.Length;
                int defaultLength = nameEnd - defaultBegin;
                m_defaultShaderName = m_templateBody.Substring(defaultBegin, defaultLength);
                int[] nameIdx = m_defaultShaderName.AllIndexesOf("\"");
                nameIdx[0]         += 1; // Ignore the " character from the string
                m_defaultShaderName = m_defaultShaderName.Substring(nameIdx[0], nameIdx[1] - nameIdx[0]);
                m_shaderNameId      = m_templateBody.Substring(nameBegin, nameEnd + TemplatesManager.TemplateFullEndTag.Length - nameBegin);
                AddId(m_shaderNameId, false);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                m_isValid = false;
            }

#if TEMPLATE_MODULES
            FetchSubShaderProperties();
#endif
            // Vertex Data
            {
                int vertexDataTagBegin = m_templateBody.IndexOf(TemplatesManager.TemplateVertexDataTag);
                if (vertexDataTagBegin > -1)
                {
                    int vertexDataTagEnd = m_templateBody.IndexOf(TemplatesManager.TemplateEndOfLine, vertexDataTagBegin);
                    m_vertexDataId = m_templateBody.Substring(vertexDataTagBegin, vertexDataTagEnd + TemplatesManager.TemplateEndOfLine.Length - vertexDataTagBegin);
                    int    dataBeginIdx = m_templateBody.LastIndexOf('{', vertexDataTagBegin, vertexDataTagBegin);
                    string vertexData   = m_templateBody.Substring(dataBeginIdx + 1, vertexDataTagBegin - dataBeginIdx);

                    int    parametersBegin = vertexDataTagBegin + TemplatesManager.TemplateVertexDataTag.Length;
                    string parameters      = m_templateBody.Substring(parametersBegin, vertexDataTagEnd - parametersBegin);
                    m_vertexData = TemplateHelperFunctions.CreateVertexDataList(vertexData, parameters);
                    AddId(m_vertexDataId);
                }
            }

            // Available interpolators
            try
            {
                int interpDataBegin = m_templateBody.IndexOf(TemplatesManager.TemplateInterpolatorBeginTag);
                if (interpDataBegin > -1)
                {
                    int interpDataEnd = m_templateBody.IndexOf(TemplatesManager.TemplateEndOfLine, interpDataBegin);
                    m_interpDataId = m_templateBody.Substring(interpDataBegin, interpDataEnd + TemplatesManager.TemplateEndOfLine.Length - interpDataBegin);

                    int    dataBeginIdx = m_templateBody.LastIndexOf('{', interpDataBegin, interpDataBegin);
                    string interpData   = m_templateBody.Substring(dataBeginIdx + 1, interpDataBegin - dataBeginIdx);

                    m_interpolatorData = TemplateHelperFunctions.CreateInterpDataList(interpData, m_interpDataId);
                    AddId(m_interpDataId);
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                m_isValid = false;
            }

            try
            {
                Dictionary <string, TemplateShaderPropertyData> duplicatesHelper = new Dictionary <string, TemplateShaderPropertyData>();
                m_availableShaderProperties = new List <TemplateShaderPropertyData>();

                // Common Tags
                for (int i = 0; i < TemplatesManager.CommonTags.Length; i++)
                {
                    int idx = m_templateBody.IndexOf(TemplatesManager.CommonTags[i].Id);
                    if (idx > -1)
                    {
                        string currentId = TemplatesManager.CommonTags[i].Id;

                        TemplateCommonTagId commonTagId = (TemplateCommonTagId)i;
                        switch (commonTagId)
                        {
                        // Properties
                        case TemplateCommonTagId.Property:
                        {
                            TemplateHelperFunctions.CreateShaderPropertiesList(m_templateBody.Substring(0, idx + TemplatesManager.CommonTags[i].Id.Length), ref m_availableShaderProperties, ref duplicatesHelper);
                        }
                        break;

                        // Globals
                        case TemplateCommonTagId.Global:
                        {
                            TemplateHelperFunctions.CreateShaderGlobalsList(m_templateBody.Substring(0, idx + TemplatesManager.CommonTags[i].Id.Length), ref m_availableShaderProperties, ref duplicatesHelper);
                        }
                        break;

                            //Tags
                            //case TemplateCommonTagId.Tag:
                            //{
                            //	m_propertyList[ m_propertyList.Count - 1 ].Indentation = " ";
                            //}
                            //break;
#if TEMPLATE_MODULES
                            //case TemplateCommonTagId.CullMode:
                            //{
                            //	int newId = idx + TemplatesManager.CommonTags[ i ].Id.Length;
                            //	int end = m_templateBody.IndexOf( TemplatesManager.TemplateNewLine, newId );
                            //	string cullParams = m_templateBody.Substring( newId, end - newId );
                            //	currentId = m_templateBody.Substring( idx, end - idx );
                            //	m_cullModeData.CullModeId = currentId;
                            //	TemplateHelperFunctions.CreateCullMode( cullParams, ref m_cullModeData );
                            //}
                            //break;
                            //Blend Mode
                            //case TemplateCommonTagId.BlendMode:
                            //{
                            //	int newId = idx + TemplatesManager.CommonTags[ i ].Id.Length;
                            //	int end = m_templateBody.IndexOf( TemplatesManager.TemplateNewLine, newId );
                            //	string blendParams = m_templateBody.Substring( newId, end - newId );
                            //	currentId = m_templateBody.Substring( idx, end - idx );
                            //	m_blendData.BlendModeId = currentId;
                            //	TemplateHelperFunctions.CreateBlendMode( blendParams, ref m_blendData );
                            //}break;
                            //case TemplateCommonTagId.BlendOp:
                            //{
                            //	int newId = idx + TemplatesManager.CommonTags[ i ].Id.Length;
                            //	int end = m_templateBody.IndexOf( TemplatesManager.TemplateNewLine, newId );
                            //	currentId = m_templateBody.Substring( idx, end - idx );
                            //	BlendData.BlendOpId = currentId;
                            //	TemplateHelperFunctions.CreateBlendOp( m_templateBody.Substring( newId, end - newId ), ref m_blendData );
                            //}break;
                            //case TemplateCommonTagId.ColorMask:
                            //{
                            //	int newId = idx + TemplatesManager.CommonTags[ i ].Id.Length;
                            //	int end = m_templateBody.IndexOf( TemplatesManager.TemplateNewLine, newId );
                            //	string colorMaskParams = m_templateBody.Substring( newId, end - newId );
                            //	currentId = m_templateBody.Substring( idx, end - idx );
                            //	m_colorMaskData.ColorMaskId = currentId;
                            //	TemplateHelperFunctions.CreateColorMask( colorMaskParams, ref m_colorMaskData );
                            //}
                            //break;
                            //case TemplateCommonTagId.StencilOp:
                            //{
                            //    int id = m_templateBody.LastIndexOf( "Stencil" );
                            //    if( id > -1 )
                            //    {
                            //        string stencilParams = m_templateBody.Substring( id, idx - id );
                            //        currentId = stencilParams + TemplatesManager.TemplateStencilOpTag;
                            //        m_stencilData.StencilBufferId = currentId;
                            //        TemplateHelperFunctions.CreateStencilOps( stencilParams, ref m_stencilData );
                            //    }

                            //}
                            //break;
#endif
                        default:
                            break;
                        }

                        //AddId( TemplatesManager.CommonTags[ i ] );
                        AddId(currentId, TemplatesManager.CommonTags[i].SearchIndentation, TemplatesManager.CommonTags[i].CustomIndentation);
                    }
                }

                duplicatesHelper.Clear();
                duplicatesHelper = null;
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                m_isValid = false;
            }
        }