Ejemplo n.º 1
0
        /// <summary>
        ///     Override this method to make your own GUI for the property
        /// </summary>
        /// <param name="position">Position</param>
        /// <param name="prop">Property</param>
        /// <param name="label">Label</param>
        public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label)
        {
            label = EditorGUI.BeginProperty(position, label, prop);

            position.height = EditorGUIUtility.singleLineHeight;
            Rect contents = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

            FindProperties(prop);

            // Draw the preview texture
            Rect textureRect = new Rect(contents);

            textureRect.x     += textureRect.width - PREVIEW_TEXTURE_SIZE;
            textureRect.width  = PREVIEW_TEXTURE_SIZE;
            textureRect.height = PREVIEW_TEXTURE_SIZE;

            EditorGUI.BeginChangeCheck();

            HydraEditorUtils.DrawUnindented(
                () => HydraEditorUtils.TextureField(textureRect, GUIContent.none, m_TextureProp, true));

            // Draw the fields
            Rect contentRect = new Rect(contents);

            contentRect.width -= textureRect.width + HydraEditorUtils.STANDARD_HORIZONTAL_SPACING * 2.0f;
            HydraEditorUtils.DrawUnindented(
                () =>
                HydraEditorUtils.EnumPopupField <Texture2DAttribute.Wrap>(contentRect, GUIContent.none, m_WrapProp,
                                                                          HydraEditorGUIStyles.enumStyle));

            // Clear the cache if the texture changes
            if (EditorGUI.EndChangeCheck())
            {
                m_WrappedTextureProp.objectReferenceValue = null;
            }

            EditorGUI.EndProperty();
        }