/// <summary> /// Render list of custom settings part of a InteractableThemePropertySettings object /// </summary> /// <param name="customProperties">SerializedProperty for InteractableThemePropertySettings.CustomSettings</param> private static void RenderCustomProperties(SerializedProperty customProperties) { for (int p = 0; p < customProperties.arraySize; p++) { SerializedProperty item = customProperties.GetArrayElementAtIndex(p); SerializedProperty name = item.FindPropertyRelative("Name"); SerializedProperty propType = item.FindPropertyRelative("Type"); SerializedProperty value = item.FindPropertyRelative("Value"); ThemePropertyTypes type = (ThemePropertyTypes)propType.intValue; RenderValue(value, name.stringValue, type); } }
private static ShaderUtil.ShaderPropertyType[] GetShaderPropertyFilter(ThemePropertyTypes shaderPropertyType) { ShaderUtil.ShaderPropertyType[] shaderTypes = null; switch (shaderPropertyType) { case ThemePropertyTypes.Color: shaderTypes = new ShaderUtil.ShaderPropertyType[] { ShaderUtil.ShaderPropertyType.Color }; break; case ThemePropertyTypes.Texture: shaderTypes = new ShaderUtil.ShaderPropertyType[] { ShaderUtil.ShaderPropertyType.TexEnv }; break; case ThemePropertyTypes.ShaderFloat: case ThemePropertyTypes.ShaderRange: shaderTypes = new ShaderUtil.ShaderPropertyType[] { ShaderUtil.ShaderPropertyType.Float, ShaderUtil.ShaderPropertyType.Range }; break; } return(shaderTypes); }
/// <summary> /// Utility function that determines if the passed property type is supported for shader targeting /// </summary> /// <param name="type">type of property value</param> /// <returns>true if property type supports shader targeting, false otherwise</returns> public static bool IsShaderPropertyType(ThemePropertyTypes type) { return(ShaderTypes.Contains(type)); }
/// <summary> /// Render a single property value /// </summary> public static void RenderValue(SerializedProperty item, GUIContent label, ThemePropertyTypes type) { SerializedProperty floatValue = item.FindPropertyRelative("Float"); SerializedProperty vector2Value = item.FindPropertyRelative("Vector2"); SerializedProperty stringValue = item.FindPropertyRelative("String"); switch (type) { case ThemePropertyTypes.Float: floatValue.floatValue = EditorGUILayout.FloatField(label, floatValue.floatValue); break; case ThemePropertyTypes.Int: SerializedProperty intValue = item.FindPropertyRelative("Int"); intValue.intValue = EditorGUILayout.IntField(label, intValue.intValue); break; case ThemePropertyTypes.Color: SerializedProperty colorValue = item.FindPropertyRelative("Color"); colorValue.colorValue = EditorGUILayout.ColorField(label, colorValue.colorValue); break; case ThemePropertyTypes.ShaderFloat: floatValue.floatValue = EditorGUILayout.FloatField(label, floatValue.floatValue); break; case ThemePropertyTypes.ShaderRange: vector2Value.vector2Value = EditorGUILayout.Vector2Field(label, vector2Value.vector2Value); break; case ThemePropertyTypes.Vector2: vector2Value.vector2Value = EditorGUILayout.Vector2Field(label, vector2Value.vector2Value); break; case ThemePropertyTypes.Vector3: SerializedProperty vector3Value = item.FindPropertyRelative("Vector3"); vector3Value.vector3Value = EditorGUILayout.Vector3Field(label, vector3Value.vector3Value); break; case ThemePropertyTypes.Vector4: SerializedProperty vector4Value = item.FindPropertyRelative("Vector4"); vector4Value.vector4Value = EditorGUILayout.Vector4Field(label, vector4Value.vector4Value); break; case ThemePropertyTypes.Quaternion: SerializedProperty quaternionValue = item.FindPropertyRelative("Quaternion"); Vector4 vect4 = new Vector4(quaternionValue.quaternionValue.x, quaternionValue.quaternionValue.y, quaternionValue.quaternionValue.z, quaternionValue.quaternionValue.w); vect4 = EditorGUILayout.Vector4Field(label, vect4); quaternionValue.quaternionValue = new Quaternion(vect4.x, vect4.y, vect4.z, vect4.w); break; case ThemePropertyTypes.Texture: SerializedProperty texture = item.FindPropertyRelative("Texture"); EditorGUILayout.PropertyField(texture, label, false); break; case ThemePropertyTypes.Material: SerializedProperty material = item.FindPropertyRelative("Material"); EditorGUILayout.PropertyField(material, label, false); break; case ThemePropertyTypes.AudioClip: SerializedProperty audio = item.FindPropertyRelative("AudioClip"); EditorGUILayout.PropertyField(audio, label, false); break; case ThemePropertyTypes.Animaiton: SerializedProperty animation = item.FindPropertyRelative("Animation"); EditorGUILayout.PropertyField(animation, label, false); break; case ThemePropertyTypes.GameObject: SerializedProperty gameObjectValue = item.FindPropertyRelative("GameObject"); EditorGUILayout.PropertyField(gameObjectValue, label, false); break; case ThemePropertyTypes.String: stringValue.stringValue = EditorGUILayout.TextField(label, stringValue.stringValue); break; case ThemePropertyTypes.Bool: SerializedProperty boolValue = item.FindPropertyRelative("Bool"); boolValue.boolValue = EditorGUILayout.Toggle(label, boolValue.boolValue); break; case ThemePropertyTypes.AnimatorTrigger: stringValue.stringValue = EditorGUILayout.TextField(label, stringValue.stringValue); break; case ThemePropertyTypes.Shader: SerializedProperty shaderObjectValue = item.FindPropertyRelative("Shader"); EditorGUILayout.PropertyField(shaderObjectValue, label, false); break; default: break; } }