public static void DrawTextureControls(SerializedProperty scroll, SerializedProperty spinProp, SerializedProperty uvProp) { if (scroll != null) { AlloyGUI.Vector2Field(scroll, "Scroll"); } float old = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 75.0f; if (spinProp != null) { EditorGUI.BeginProperty(new Rect(), new GUIContent(), spinProp); EditorGUI.BeginChangeCheck(); float spin = spinProp.floatValue * Mathf.Rad2Deg; spin = EditorGUILayout.FloatField(new GUIContent("Spin"), spin, GUILayout.Width(180.0f)); if (EditorGUI.EndChangeCheck()) { spinProp.floatValue = spin * Mathf.Deg2Rad; } EditorGUI.EndProperty(); } if (uvProp != null) { EditorGUI.BeginProperty(new Rect(), new GUIContent(), uvProp); EditorGUI.BeginChangeCheck(); float newVal = EditorGUILayout.Popup(new GUIContent("UV Set"), (int)uvProp.floatValue, s_uvModes, GUILayout.Width(180.0f)); if (EditorGUI.EndChangeCheck()) { uvProp.floatValue = newVal; } } EditorGUIUtility.labelWidth = old; }
public override void Draw(AlloyFieldDrawerArgs args) { m_inst = args.MatInst; bool isOpen = m_tabGroup.Foldout(DisplayName, SaveName, GUILayout.Width(10.0f)); m_tabOpen.target = isOpen; if (m_tabOpen.value) { EditorGUILayout.BeginFadeGroup(m_tabOpen.faded); AlloyGUI.Vector2Field(Serialized, "Tiling", true); AlloyGUI.Vector2Field(Serialized, "Offset", false); AlloyTextureFieldDrawer.DrawTextureControls(m_scrollProp, m_spinProp, m_uvProp); EditorGUILayout.EndFadeGroup(); } if (m_tabOpen.isAnimating) { args.Editor.MatEditor.Repaint(); } }
public override void Draw(AlloyFieldDrawerArgs args) { m_inst = args.MatInst; if (m_firstDraw) { OnFirstDraw(); m_firstDraw = false; } var texture = Serialized.FindPropertyRelative(TextureProp); var curTex = texture.objectReferenceValue as Texture; GUILayout.Space(9.0f); GUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); float oldWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 80.0f; bool drewOpen = false; if (m_hasParentTexture || !Controls) { GUILayout.Label(DisplayName); } else { bool isOpen = m_tabGroup.Foldout(DisplayName, SaveName, GUILayout.Width(10.0f)); m_tabOpen.target = isOpen; if (EditorGUILayout.BeginFadeGroup(m_tabOpen.faded)) { drewOpen = true; AlloyGUI.Vector2Field(m_scale, "Tiling"); AlloyGUI.Vector2Field(m_offset, "Offset"); DrawTextureControls(m_velocityProp, m_spinProp, m_uvProp); } EditorGUILayout.EndFadeGroup(); } if ((EditorGUILayout.BeginFadeGroup(1.0f - m_tabOpen.faded) || !Controls) && curTex != null && !texture.hasMultipleDifferentValues) { if (!DrawWarningString(texture)) { var oldCol = GUI.color; GUI.color = EditorGUIUtility.isProSkin ? Color.gray : new Color(0.3f, 0.3f, 0.3f); string name = curTex.name; if (name.Length > 17) { name = name.Substring(0, 14) + ".."; } GUILayout.Label(name + " (" + curTex.width + "x" + curTex.height + ")", EditorStyles.whiteLabel); GUI.color = oldCol; } } EditorGUILayout.EndFadeGroup(); if (curTex != null && (!m_hasParentTexture || Controls) && !texture.hasMultipleDifferentValues) { DrawVisualizeButton(); } if (drewOpen) { EditorGUILayout.EndVertical(); TextureField(Mathf.Lerp(74.0f, 100.0f, m_tabOpen.faded), texture, args); } else { GUILayout.EndVertical(); GUILayout.FlexibleSpace(); TextureField(74.0f, texture, args); } EditorGUIUtility.labelWidth = oldWidth; GUILayout.EndHorizontal(); if (IsOpen) { GUILayout.Space(10.0f); } if (m_tabOpen.isAnimating) { args.Editor.MatEditor.Repaint(); } }