From 917e9e0b320775634dc2e710f7deac74fd0822f0 Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 22 Oct 2020 23:30:02 +0800 Subject: * amplify shader editor --- .../Plugins/Editor/Menu/AutoPanData.cs | 94 ++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 Assets/AmplifyShaderEditor/Plugins/Editor/Menu/AutoPanData.cs (limited to 'Assets/AmplifyShaderEditor/Plugins/Editor/Menu/AutoPanData.cs') diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Menu/AutoPanData.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Menu/AutoPanData.cs new file mode 100644 index 00000000..9f028f3f --- /dev/null +++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Menu/AutoPanData.cs @@ -0,0 +1,94 @@ +// Amplify Shader Editor - Visual Shader Editing Tool +// Copyright (c) Amplify Creations, Lda + +using UnityEngine; + +namespace AmplifyShaderEditor +{ + public enum AutoPanLocation + { + TOP = 0, + BOTTOM, + LEFT, + RIGHT + } + + public class AutoPanData + { + private Rect m_area; + private float m_size; + private Vector2 m_velocity; + + private GUIStyle m_style; + private Color m_color = new Color( 1f, 0f, 0f, 0.5f ); + + private AutoPanLocation m_location; + private float m_adjustWidth = 0; + private float m_adjustInitialX = 0; + + public AutoPanData( AutoPanLocation location, float size, Vector2 vel ) + { + m_area = new Rect(); + m_size = size; + m_velocity = vel; + m_location = location; + } + + public bool CheckArea( Vector2 mousePosition, Rect window, bool draw ) + { + float totalSize = m_size + m_adjustWidth; + switch ( m_location ) + { + case AutoPanLocation.TOP: + { + m_area.x = m_adjustInitialX; + m_area.y = 0; + m_area.width = window.width; + m_area.height = totalSize; + } + break; + case AutoPanLocation.BOTTOM: + { + m_area.x = m_adjustInitialX; + m_area.y = window.height - totalSize; + m_area.width = window.width; + m_area.height = totalSize; + } + break; + case AutoPanLocation.LEFT: + { + m_area.x = m_adjustInitialX; + m_area.y = 0; + m_area.width = totalSize; + m_area.height = window.height; + } + break; + case AutoPanLocation.RIGHT: + { + m_area.x = m_adjustInitialX + window.width - totalSize; + m_area.y = 0; + m_area.width = totalSize; + m_area.height = window.height; + } + break; + } + + if ( draw ) + { + if ( m_style == null ) + { + m_style = UIUtils.Box; + } + Color bufferedColor = GUI.color; + GUI.color = m_color; + GUI.Label( m_area, string.Empty, m_style ); + GUI.color = bufferedColor; + } + return m_area.Contains( mousePosition ); + } + + public float AdjustWidth { set { m_adjustWidth = value; } } + public float AdjustInitialX { set { m_adjustInitialX = value; } } + public Vector2 Velocity { get { return m_velocity; } } + } +} -- cgit v1.1-26-g67d0