public void Init() { if (_isInit) { return; } _hasConstantValue = true; if (type == DefineableConditionType.NONE) { _constantValue = true; } else if (type == DefineableConditionType.TRUE) { _constantValue = true; } else if (type == DefineableConditionType.FALSE) { _constantValue = false; } else { var(compareType, compareString) = GetComparetor(); _compareType = compareType; string[] parts = Regex.Split(data, compareString); _obj = parts[0]; _value = parts[parts.Length - 1]; _floatValue = Parser.ParseFloat(_value); if (ShaderEditor.Active != null && ShaderEditor.Active.PropertyDictionary.ContainsKey(_obj)) { _propertyObj = ShaderEditor.Active.PropertyDictionary[_obj]; } if (type == DefineableConditionType.EDITOR_VERSION) { InitEditorVersion(); } else if (type == DefineableConditionType.VRC_SDK_VERSION) { InitVRCSDKVersion(); } else { _hasConstantValue = false; } } _isInit = true; }
public bool Test() { switch (type) { case DefineableConditionType.NONE: return(true); case DefineableConditionType.TRUE: return(true); case DefineableConditionType.FALSE: return(false); } string comparator = GetComparetor(); string[] parts = Regex.Split(data, comparator); string obj = parts[0]; string value = parts[parts.Length - 1]; switch (type) { case DefineableConditionType.PROPERTY_BOOL: ShaderProperty prop = ShaderEditor.active.propertyDictionary[obj]; if (prop == null) { return(false); } if (comparator == "##") { return(prop.materialProperty.floatValue == 1); } float f = Parser.ParseFloat(parts[1]); if (comparator == "==") { return(prop.materialProperty.floatValue == f); } if (comparator == "!=") { return(prop.materialProperty.floatValue != f); } if (comparator == "<") { return(prop.materialProperty.floatValue < f); } if (comparator == ">") { return(prop.materialProperty.floatValue > f); } if (comparator == ">=") { return(prop.materialProperty.floatValue >= f); } if (comparator == "<=") { return(prop.materialProperty.floatValue <= f); } break; case DefineableConditionType.EDITOR_VERSION: int c_ev = Helper.compareVersions(Config.Singleton.verion, value); if (comparator == "==") { return(c_ev == 0); } if (comparator == "!=") { return(c_ev != 0); } if (comparator == "<") { return(c_ev == 1); } if (comparator == ">") { return(c_ev == -1); } if (comparator == ">=") { return(c_ev == -1 || c_ev == 0); } if (comparator == "<=") { return(c_ev == 1 || c_ev == 0); } break; case DefineableConditionType.VRC_SDK_VERSION: if (VRCInterface.Get().sdk_information.type == VRCInterface.VRC_SDK_Type.NONE) { return(false); } int c_vrc = Helper.compareVersions(VRCInterface.Get().sdk_information.installed_version, value); if (comparator == "==") { return(c_vrc == 0); } if (comparator == "!=") { return(c_vrc != 0); } if (comparator == "<") { return(c_vrc == 1); } if (comparator == ">") { return(c_vrc == -1); } if (comparator == ">=") { return(c_vrc == -1 || c_vrc == 0); } if (comparator == "<=") { return(c_vrc == 1 || c_vrc == 0); } break; case DefineableConditionType.TEXTURE_SET: ShaderProperty shaderProperty = ShaderEditor.active.propertyDictionary[data]; if (shaderProperty == null) { return(false); } return(shaderProperty.materialProperty.textureValue != null); case DefineableConditionType.DROPDOWN: ShaderProperty dropdownProperty = ShaderEditor.active.propertyDictionary[obj]; if (dropdownProperty == null) { return(false); } if (comparator == "##") { return(dropdownProperty.materialProperty.floatValue == 1); } if (comparator == "==") { return("" + dropdownProperty.materialProperty.floatValue == parts[1]); } if (comparator == "!=") { return("" + dropdownProperty.materialProperty.floatValue != parts[1]); } break; case DefineableConditionType.AND: if (condition1 != null && condition2 != null) { return(condition1.Test() && condition2.Test()); } break; case DefineableConditionType.OR: if (condition1 != null && condition2 != null) { return(condition1.Test() || condition2.Test()); } break; } return(true); }