public static bool IsModeMatched(UnitMaterialEditor gui, JSONObject args) { String mode; var modeMatched = true; if (args != null && args.GetField(out mode, UnitMaterialEditor.Cfg.ArgsKey_Mode, String.Empty)) { var renderMode = gui.FindPropEditor <ShaderGUI_RenderMode>(); if (renderMode != null && !String.IsNullOrEmpty(mode)) { var names = mode.Split('|'); modeMatched = false; for (int i = 0; i < names.Length; ++i) { var name = names[i].Trim(); if (name.Equals(renderMode._Mode.ToString(), StringComparison.OrdinalIgnoreCase)) { modeMatched = true; break; } } } } return(modeMatched); }
public static int EvalLogicOpArg(UnitMaterialEditor gui, String express, out String returnValue) { returnValue = null; if (!String.IsNullOrEmpty(express)) { var m = UnitMaterialEditor.Reg_LogicRef.Match(express); if (m.Success && m.Groups.Count > 2) { var rev = m.Groups[1].ToString().Trim() == "!"; var id = m.Groups[2].ToString().Trim(); if (!String.IsNullOrEmpty(id)) { var ui = gui.FindPropEditor <UnitMaterialEditor>(id); if (ui != null) { var b = ui.GetLogicOpResult(out returnValue); if (rev) { b = !b; } return(b ? 1 : 0); } return(0); } } else { returnValue = express; } } return(-1); }
public static int EvalLogicOpArg(UnitMaterialEditor gui, String express, MaterialProperty[] props, out String returnValue) { returnValue = null; if (!String.IsNullOrEmpty(express)) { var m = UnitMaterialEditor.Reg_LogicRef.Match(express); if (m.Success && m.Groups.Count > 2) { var rev = m.Groups[1].ToString().Trim() == "!"; var id = m.Groups[2].ToString().Trim(); if (!String.IsNullOrEmpty(id)) { var ui = gui.FindPropEditor <UnitMaterialEditor>(id); if (ui != null) { var b = ui.GetLogicOpResult(out returnValue, props); if (rev) { b = !b; } return(b ? 1 : 0); } else { var result = false; var material = gui.materialEditor.target as Material; if (material != null && material.shader != null) { var shader = material.shader; for (int i = 0; i < ShaderUtil.GetPropertyCount(shader); ++i) { var name = ShaderUtil.GetPropertyName(shader, i); if (name == id) { switch (ShaderUtil.GetPropertyType(shader, i)) { case ShaderUtil.ShaderPropertyType.Color: result = ShaderGUIHelper.Compare(">", material.GetColor(name), new Color(0, 0, 0, 0)); break; case ShaderUtil.ShaderPropertyType.Float: case ShaderUtil.ShaderPropertyType.Range: result = material.GetFloat(name) > 0; break; case ShaderUtil.ShaderPropertyType.TexEnv: result = material.GetTexture(name) != null; break; case ShaderUtil.ShaderPropertyType.Vector: result = ShaderGUIHelper.Compare(">", material.GetVector(name), new Vector4(0, 0, 0, 0)); break; } if (rev) { result = !result; } return(result ? 1 : 0); } } } } return(0); } } else { returnValue = express; } } return(-1); }