static TemplateActionItem CreateActionItem(string[] optionItems)
        {
            TemplateActionItem actionItem = new TemplateActionItem();

            actionItem.ActionType = AseOptionsActionTypeDict[optionItems[1]];
            actionItem.ActionData = optionItems[2];
            return(actionItem);
        }
        //Method used by template options
        // As such. Render Queue will have value and offset separated by ,
        public void AddSpecialTag(TemplateSpecialTags tag, TemplateActionItem item)
        {
            if (tag == TemplateSpecialTags.None)
            {
                return;
            }

            int count = m_availableTags.Count;

            for (int i = 0; i < count; i++)
            {
                if (m_availableTags[i].SpecialTag == tag)
                {
                    switch (tag)
                    {
                    case TemplateSpecialTags.RenderType:
                    {
                        m_availableTags[i].RenderType = TemplateHelperFunctions.StringToRenderType[item.ActionData];
                        return;
                    }

                    case TemplateSpecialTags.Queue:
                    {
                        m_availableTags[i].RenderQueue       = TemplateHelperFunctions.StringToRenderQueue[item.ActionData];
                        m_availableTags[i].RenderQueueOffset = item.ActionDataIdx;
                        m_availableTags[i].BuildQueueTagValue();
                        return;
                    }
                    }
                }
            }

            CustomTagData data = new CustomTagData();

            switch (tag)
            {
            case TemplateSpecialTags.RenderType:
            {
                data.SpecialTag = TemplateSpecialTags.RenderType;
                data.TagName    = "RenderType";
                data.RenderType = TemplateHelperFunctions.StringToRenderType[item.ActionData];
            }
            break;

            case TemplateSpecialTags.Queue:
            {
                data.SpecialTag        = TemplateSpecialTags.Queue;
                data.TagName           = "Queue";
                data.RenderQueue       = TemplateHelperFunctions.StringToRenderQueue[item.ActionData];
                data.RenderQueueOffset = item.ActionDataIdx;
                data.BuildQueueTagValue();
            }
            break;
            }
            m_availableTags.Add(data);
        }
Esempio n. 3
0
		//Method used by template options
		// As such. Render Queue will have value and offset separated by ,
		public void AddSpecialTag( TemplateSpecialTags tag, TemplateActionItem item )
		{
			if( tag == TemplateSpecialTags.None )
				return:

			int count = m_availableTags.Count:
			for( int i = 0: i < count: i++ )
			{
				if( m_availableTags[ i ].SpecialTag == tag )
				{
					switch( tag )
					{
						case TemplateSpecialTags.RenderType:
						{
							m_availableTags[ i ].RenderType = TemplateHelperFunctions.StringToRenderType[ item.ActionData ]:
							return:
						}
						case TemplateSpecialTags.Queue:
						{
							
							m_availableTags[ i ].RenderQueue = TemplateHelperFunctions.StringToRenderQueue[ item.ActionData ]:
							m_availableTags[ i ].RenderQueueOffset = item.ActionDataIdx:
							m_availableTags[ i ].BuildQueueTagValue():
							return:
						}
					}
				}
			}

			CustomTagData data = new CustomTagData():
			switch( tag )
			{
				case TemplateSpecialTags.RenderType:
				{
					data.RenderType = TemplateHelperFunctions.StringToRenderType[ item.ActionData ]:
				}
				break:
				case TemplateSpecialTags.Queue:
				{
					data.RenderQueue = TemplateHelperFunctions.StringToRenderQueue[ item.ActionData ]:
					data.RenderQueueOffset = item.ActionDataIdx:
					data.BuildQueueTagValue():
				}
				break:
			}
			m_availableTags.Add( data ):
		}
Esempio n. 4
0
        static TemplateActionItem CreateActionItem(bool isSubshader, string[] optionItems)
        {
            TemplateActionItem actionItem = new TemplateActionItem();

            try
            {
                actionItem.ActionType = AseOptionsActionTypeDict[optionItems[1]];
                int optionsIdx = 2;
                if (optionItems.Length > 3)
                {
                    optionsIdx          = 3;
                    actionItem.PassName = optionItems[2];
                }
                else
                {
                    actionItem.AllPasses = isSubshader;
                }

                actionItem.ActionData = optionItems[optionsIdx];

                switch (actionItem.ActionType)
                {
                case AseOptionsActionType.ShowOption:
                case AseOptionsActionType.HideOption:
                {
                    string[] arr = optionItems[optionsIdx].Split(OptionsDataSeparator);
                    if (arr.Length > 1)
                    {
                        actionItem.ActionData = arr[0];
                        if (!int.TryParse(arr[1], out actionItem.ActionDataIdx))
                        {
                            actionItem.ActionDataIdx = -1;
                        }
                    }
                }
                break;

                case AseOptionsActionType.SetOption:
                {
                    string[] arr = optionItems[optionsIdx].Split(OptionsDataSeparator);
                    if (arr.Length > 1)
                    {
                        actionItem.ActionData = arr[0];
                        if (!int.TryParse(arr[1], out actionItem.ActionDataIdx))
                        {
                            Debug.LogWarning("SetOption value must be a the selection index");
                        }
                    }
                }
                break;

                case AseOptionsActionType.HidePort:
                case AseOptionsActionType.ShowPort:
                {
                    if (!int.TryParse(actionItem.ActionData, out actionItem.ActionDataIdx))
                    {
                        actionItem.ActionDataIdx = -1;
                    }
                }
                break;

                case AseOptionsActionType.SetPortName:
                {
                    string[] arr = optionItems[optionsIdx].Split(OptionsDataSeparator);
                    if (arr.Length > 1)
                    {
                        int.TryParse(arr[0], out actionItem.ActionDataIdx);
                        actionItem.ActionData = arr[1];
                    }
                }
                break;

                case AseOptionsActionType.SetDefine:
                case AseOptionsActionType.RemoveDefine:
                case AseOptionsActionType.SetUndefine:
                case AseOptionsActionType.RemoveUndefine:
                case AseOptionsActionType.ExcludePass:
                case AseOptionsActionType.IncludePass:
                    break;

                case AseOptionsActionType.SetShaderProperty:
                {
                    int optIndex = optionItems[optionsIdx].IndexOf(OptionsDataSeparator);
                    if (optIndex > -1)
                    {
                        actionItem.ActionData   = optionItems[optionsIdx].Substring(0, optIndex);
                        actionItem.ActionBuffer = optionItems[optionsIdx].Substring(optIndex + 1, optionItems[optionsIdx].Length - optIndex - 1);
                    }
                } break;

                case AseOptionsActionType.SetPropertyOnPass:
                case AseOptionsActionType.SetPropertyOnSubShader:
                {
                    string[] arr = optionItems[optionsIdx].Split(OptionsDataSeparator);
                    actionItem.PropertyAction = (PropertyActionsEnum)Enum.Parse(typeof(PropertyActionsEnum), arr[0]);
                    if (arr.Length == 1 && actionItem.ActionType == AseOptionsActionType.SetPropertyOnPass)
                    {
                        actionItem.CopyFromSubShader = true;
                    }
                    else
                    {
                        switch (actionItem.PropertyAction)
                        {
                        case PropertyActionsEnum.CullMode:
                        {
                            if (arr.Length > 1)
                            {
                                actionItem.ActionCullMode = (CullMode)Enum.Parse(typeof(CullMode), arr[1]);
                            }
                        }
                        break;

                        case PropertyActionsEnum.ColorMask:
                        {
                            if (arr.Length > 4)
                            {
                                actionItem.ColorMask[0] = Convert.ToBoolean(arr[1]);
                                actionItem.ColorMask[1] = Convert.ToBoolean(arr[2]);
                                actionItem.ColorMask[2] = Convert.ToBoolean(arr[3]);
                                actionItem.ColorMask[3] = Convert.ToBoolean(arr[4]);
                            }
                        }
                        break;

                        case PropertyActionsEnum.ZWrite:
                        {
                            if (arr.Length > 1)
                            {
                                actionItem.ActionZWrite = (ZWriteMode)Enum.Parse(typeof(ZWriteMode), arr[1]);
                            }
                        }
                        break;

                        case PropertyActionsEnum.ZTest:
                        {
                            if (arr.Length > 1)
                            {
                                actionItem.ActionZTest = (ZTestMode)Enum.Parse(typeof(ZTestMode), arr[1]);
                            }
                        }
                        break;

                        case PropertyActionsEnum.ZOffsetFactor:
                        {
                            if (arr.Length > 1)
                            {
                                actionItem.ActionZOffsetFactor = Convert.ToSingle(arr[1]);
                            }
                        }
                        break;

                        case PropertyActionsEnum.ZOffsetUnits:
                        {
                            if (arr.Length > 1)
                            {
                                actionItem.ActionZOffsetUnits = Convert.ToSingle(arr[1]);
                            }
                        }
                        break;

                        case PropertyActionsEnum.BlendRGB:
                        {
                            if (arr.Length > 2)
                            {
                                actionItem.ActionBlendRGBSource = (AvailableBlendFactor)Enum.Parse(typeof(AvailableBlendFactor), arr[1]);
                                actionItem.ActionBlendRGBDest   = (AvailableBlendFactor)Enum.Parse(typeof(AvailableBlendFactor), arr[2]);
                            }
                        }
                        break;

                        case PropertyActionsEnum.BlendAlpha:
                        {
                            if (arr.Length > 2)
                            {
                                actionItem.ActionBlendAlphaSource = (AvailableBlendFactor)Enum.Parse(typeof(AvailableBlendFactor), arr[1]);
                                actionItem.ActionBlendAlphaDest   = (AvailableBlendFactor)Enum.Parse(typeof(AvailableBlendFactor), arr[2]);
                            }
                        }
                        break;

                        case PropertyActionsEnum.BlendOpRGB:
                        {
                            if (arr.Length > 1)
                            {
                                actionItem.ActionBlendOpRGB = (AvailableBlendOps)Enum.Parse(typeof(AvailableBlendOps), arr[1]);
                            }
                        }
                        break;

                        case PropertyActionsEnum.BlendOpAlpha:
                        {
                            if (arr.Length > 1)
                            {
                                actionItem.ActionBlendOpAlpha = (AvailableBlendOps)Enum.Parse(typeof(AvailableBlendOps), arr[1]);
                            }
                        }
                        break;

                        case PropertyActionsEnum.StencilReference:
                        {
                            if (arr.Length > 1)
                            {
                                int.TryParse(arr[1], out actionItem.ActionStencilReference);
                            }
                        }
                        break;

                        case PropertyActionsEnum.StencilReadMask:
                        {
                            if (arr.Length > 1)
                            {
                                int.TryParse(arr[1], out actionItem.ActionStencilReadMask);
                            }
                        }
                        break;

                        case PropertyActionsEnum.StencilWriteMask:
                        {
                            if (arr.Length > 1)
                            {
                                int.TryParse(arr[1], out actionItem.ActionStencilWriteMask);
                            }
                        }
                        break;

                        case PropertyActionsEnum.StencilComparison:
                        {
                            if (arr.Length > 1)
                            {
                                actionItem.ActionStencilComparison = StencilBufferOpHelper.StencilComparisonValuesDict[arr[1]];
                            }
                        }
                        break;

                        case PropertyActionsEnum.StencilPass:
                        {
                            if (arr.Length > 1)
                            {
                                actionItem.ActionStencilPass = StencilBufferOpHelper.StencilOpsValuesDict[arr[1]];
                            }
                        }
                        break;

                        case PropertyActionsEnum.StencilFail:
                        {
                            if (arr.Length > 1)
                            {
                                actionItem.ActionStencilFail = StencilBufferOpHelper.StencilOpsValuesDict[arr[1]];
                            }
                        }
                        break;

                        case PropertyActionsEnum.StencilZFail:
                        {
                            if (arr.Length > 1)
                            {
                                actionItem.ActionStencilZFail = StencilBufferOpHelper.StencilOpsValuesDict[arr[1]];
                            }
                        }
                        break;

                        case PropertyActionsEnum.RenderType:
                        {
                            if (arr.Length > 1)
                            {
                                actionItem.ActionData = arr[1];
                            }
                        }
                        break;

                        case PropertyActionsEnum.RenderQueue:
                        {
                            if (arr.Length > 1)
                            {
                                actionItem.ActionData = arr[1];
                            }
                            if (arr.Length > 2)
                            {
                                int.TryParse(arr[2], out actionItem.ActionDataIdx);
                            }
                            else
                            {
                                actionItem.ActionDataIdx = 0;
                            }
                        }
                        break;
                        }
                    }
                }
                break;
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
            return(actionItem);
        }