public static dynamic GetTSObject(PropertyTypeEnum dynEnum) { var tsType = TSActivator.CreateInstance("Tekla.Structures.PropertyTypeEnum").GetType(); switch (dynEnum) { case PropertyTypeEnum.TYPE_INT: return(System.Enum.Parse(tsType, "TYPE_INT")); case PropertyTypeEnum.TYPE_DOUBLE: return(System.Enum.Parse(tsType, "TYPE_DOUBLE")); case PropertyTypeEnum.TYPE_STRING: return(System.Enum.Parse(tsType, "TYPE_STRING")); default: throw new DynamicAPIException(dynEnum.ToString() + "- enum value is not implemented"); } }
private static string MaterialPropertyName(string property, Material mat, PropertyTypeEnum type, bool allowNone, string defaultProperty, string labelName) { Color tColor = GUI.color; // Create a list of available color and value properties List <string> props = new List <string>(); int selectedPropIndex = 0; if (allowNone) { props.Add("(None)"); } if (mat != null) { int propertyCount = ShaderUtil.GetPropertyCount(mat.shader); string propName = string.Empty; for (int i = 0; i < propertyCount; i++) { if (ShaderUtil.GetPropertyType(mat.shader, i).ToString() == type.ToString()) { propName = ShaderUtil.GetPropertyName(mat.shader, i); if (propName == property) { // We've found our current property selectedPropIndex = props.Count; } props.Add(propName); } } if (string.IsNullOrEmpty(labelName)) { labelName = type.ToString(); } int newPropIndex = EditorGUILayout.Popup(labelName, selectedPropIndex, props.ToArray()); if (allowNone) { property = (newPropIndex > 0 ? props[newPropIndex] : string.Empty); } else { if (props.Count > 0) { property = props[newPropIndex]; } else { property = defaultProperty; } } return(property); } else { GUI.color = Color.Lerp(tColor, Color.gray, 0.5f); // Draw an empty property EditorGUILayout.Popup(labelName, selectedPropIndex, props.ToArray()); GUI.color = tColor; return(string.Empty); } }