mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-23 10:05:14 +00:00
Merge pull request #124 from minenice55/responsive-editor
Scale-responsive editor
This commit is contained in:
commit
a8f87c079c
21 changed files with 4292 additions and 1102 deletions
File diff suppressed because one or more lines are too long
|
@ -10,7 +10,9 @@ TrueTypeFontImporter:
|
|||
includeFontData: 1
|
||||
fontNames:
|
||||
- FOT-Rodin Pro
|
||||
fallbackFontReferences: []
|
||||
fallbackFontReferences:
|
||||
- {fileID: 12800000, guid: d9b391ecd583bd54fa458814fbcad7be, type: 3}
|
||||
- {fileID: 12800000, guid: 6d457cf9900bba748b3250de2e990fa2, type: 3}
|
||||
customCharacters:
|
||||
fontRenderingMode: 0
|
||||
ascentCalculationMode: 1
|
||||
|
|
105
Assets/Resources/Fonts/rodin/FOT-Rodin Pro DB Entity.mat
Normal file
105
Assets/Resources/Fonts/rodin/FOT-Rodin Pro DB Entity.mat
Normal file
|
@ -0,0 +1,105 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: FOT-Rodin Pro DB Entity
|
||||
m_Shader: {fileID: 4800000, guid: 68e6db2ebdc24f95958faec2be5558d6, type: 3}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _Cube:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _FaceTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 3307759631967023827, guid: 8597c35f18a008c428fc5870aec75766, type: 2}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OutlineTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _Ambient: 1
|
||||
- _Bevel: 0.5
|
||||
- _BevelClamp: 0
|
||||
- _BevelOffset: 0
|
||||
- _BevelRoundness: 0
|
||||
- _BevelWidth: 0
|
||||
- _BumpFace: 0
|
||||
- _BumpOutline: 0
|
||||
- _ColorMask: 15
|
||||
- _CullMode: 0
|
||||
- _Diffuse: 0.5
|
||||
- _FaceDilate: 0.4
|
||||
- _FaceUVSpeedX: 0
|
||||
- _FaceUVSpeedY: 0
|
||||
- _GlowInner: 0.659
|
||||
- _GlowOffset: -1
|
||||
- _GlowOuter: 1
|
||||
- _GlowPower: 0.558
|
||||
- _GradientScale: 10
|
||||
- _LightAngle: 3.1416
|
||||
- _MaskSoftnessX: 0
|
||||
- _MaskSoftnessY: 0
|
||||
- _OutlineSoftness: 0
|
||||
- _OutlineUVSpeedX: 0
|
||||
- _OutlineUVSpeedY: 0
|
||||
- _OutlineWidth: 0.2
|
||||
- _PerspectiveFilter: 0.875
|
||||
- _Reflectivity: 10
|
||||
- _ScaleRatioA: 0.9
|
||||
- _ScaleRatioB: 0.37125
|
||||
- _ScaleRatioC: 0.37125
|
||||
- _ScaleX: 1
|
||||
- _ScaleY: 1
|
||||
- _ShaderFlags: 0
|
||||
- _Sharpness: 0
|
||||
- _SpecularPower: 2
|
||||
- _Stencil: 0
|
||||
- _StencilComp: 8
|
||||
- _StencilOp: 0
|
||||
- _StencilReadMask: 255
|
||||
- _StencilWriteMask: 255
|
||||
- _TextureHeight: 1024
|
||||
- _TextureWidth: 1024
|
||||
- _UnderlayDilate: 1
|
||||
- _UnderlayOffsetX: 0
|
||||
- _UnderlayOffsetY: 0
|
||||
- _UnderlaySoftness: 0
|
||||
- _VertexOffsetX: 0
|
||||
- _VertexOffsetY: 0
|
||||
- _WeightBold: 0.75
|
||||
- _WeightNormal: 0
|
||||
m_Colors:
|
||||
- _ClipRect: {r: -32767, g: -32767, b: 32767, a: 32767}
|
||||
- _EnvMatrixRotation: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _FaceColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _GlowColor: {r: 0, g: 1, b: 0, a: 0.5}
|
||||
- _MaskCoord: {r: 0, g: 0, b: 32767, a: 32767}
|
||||
- _OutlineColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _ReflectFaceColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _ReflectOutlineColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _SpecularColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _UnderlayColor: {r: 1, g: 0, b: 0, a: 0.78039217}
|
||||
m_BuildTextureStacks: []
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 147c28f2f84477044b69d3cbf70ee556
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load diff
|
@ -23,6 +23,9 @@ namespace HeavenStudio.Editor
|
|||
private bool clickedInTimeline = false;
|
||||
|
||||
private TMPro.TMP_Text sizeText;
|
||||
private RectTransform text;
|
||||
|
||||
private float timelineLastX;
|
||||
|
||||
public static BoxSelection instance { get; private set; }
|
||||
|
||||
|
@ -40,10 +43,19 @@ namespace HeavenStudio.Editor
|
|||
boxVisual.transform.GetChild(0).GetComponent<Image>().color = EditorTheme.theme.properties.BoxSelectionOutlineCol.Hex2RGB();
|
||||
|
||||
sizeText = boxVisual.transform.GetChild(1).GetComponent<TMPro.TMP_Text>();
|
||||
text = boxVisual.transform.GetChild(1).GetComponent<RectTransform>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
float deltaTimelineX = timelineContent.transform.localPosition.x - timelineLastX;
|
||||
|
||||
Camera camera = Editor.instance.EditorCamera;
|
||||
Vector3 scale = Editor.instance.MainCanvas.transform.localScale;
|
||||
|
||||
boxVisual.transform.localScale = new Vector2(0.01f/scale.x, 1f/scale.y);
|
||||
text.transform.localScale = scale;
|
||||
|
||||
if (Selections.instance.eventsSelected.Count > 0 && Timeline.instance.InteractingWithEvents())
|
||||
{
|
||||
startPosition = Vector2.zero;
|
||||
|
@ -60,10 +72,11 @@ namespace HeavenStudio.Editor
|
|||
return;
|
||||
}
|
||||
|
||||
if (boxVisual.rect.width * boxVisual.transform.localScale.x >= 0.5f)
|
||||
sizeText.text = $"{string.Format("{0:0.000}", boxVisual.rect.width * boxVisual.transform.localScale.x)}";
|
||||
float beatLen = boxVisual.rect.width * boxVisual.transform.localScale.x;
|
||||
if (beatLen >= 0.5f)
|
||||
sizeText.text = $"{string.Format("{0:0.000}", beatLen)}";
|
||||
else
|
||||
sizeText.text = string.Empty; // i'm lazy
|
||||
sizeText.text = string.Empty;
|
||||
|
||||
|
||||
// click
|
||||
|
@ -78,9 +91,11 @@ namespace HeavenStudio.Editor
|
|||
// dragging
|
||||
if (Input.GetMouseButton(0) && clickedInTimeline)
|
||||
{
|
||||
startPosition.x += deltaTimelineX * scale.x;
|
||||
endPosition = MousePosition();
|
||||
DrawVisual();
|
||||
DrawSelection();
|
||||
SelectEvents(); //kek
|
||||
DrawVisual();
|
||||
}
|
||||
|
||||
// release click
|
||||
|
@ -92,9 +107,7 @@ namespace HeavenStudio.Editor
|
|||
DrawVisual();
|
||||
}
|
||||
|
||||
// selecting = (selectionBox.size != Vector2.zero); -- doesn't work really
|
||||
|
||||
// for real time selection just move SelectEvents() to here, but that breaks some shit. might fix soon idk --pelly
|
||||
timelineLastX = timelineContent.transform.localPosition.x;
|
||||
}
|
||||
|
||||
private void DrawVisual()
|
||||
|
@ -102,15 +115,12 @@ namespace HeavenStudio.Editor
|
|||
Vector2 boxStart = startPosition;
|
||||
Vector2 boxEnd = endPosition;
|
||||
|
||||
// boxEnd = new Vector2(Mathf.Clamp(boxEnd.x, -5.78f, Mathf.Infinity), boxEnd.y);
|
||||
|
||||
Vector2 boxCenter = (boxStart + boxEnd) / 2;
|
||||
boxVisual.position = boxCenter;
|
||||
|
||||
Vector2 boxSize = new Vector2(Mathf.Abs(boxStart.x - boxEnd.x), Mathf.Abs(boxStart.y - boxEnd.y));
|
||||
|
||||
// boxVisual.sizeDelta = new Vector2(boxSize.x / boxVisual.localScale.x, boxSize.y / boxVisual.localScale.y);
|
||||
boxVisual.sizeDelta = new Vector2(boxSize.x, boxSize.y);
|
||||
boxVisual.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, boxSize.x);
|
||||
boxVisual.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, boxSize.y);
|
||||
}
|
||||
|
||||
private void DrawSelection()
|
||||
|
@ -168,7 +178,7 @@ namespace HeavenStudio.Editor
|
|||
{
|
||||
var mousePos = Editor.instance.EditorCamera.ScreenToWorldPoint(Input.mousePosition);
|
||||
// var mousePos = new Vector2();
|
||||
// RectTransformUtility.ScreenPointToLocalPointInRectangle(timelineContent, Input.mousePosition, Camera.main, out mousePos);
|
||||
// RectTransformUtility.ScreenPointToLocalPointInRectangle(timelineContent, Input.mousePosition, Editor.instance.EditorCamera, out mousePos);
|
||||
return new Vector3(mousePos.x, mousePos.y, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,10 +25,10 @@ namespace HeavenStudio.Editor
|
|||
{
|
||||
private Initializer Initializer;
|
||||
|
||||
[SerializeField] private Canvas MainCanvas;
|
||||
[SerializeField] public Canvas MainCanvas;
|
||||
[SerializeField] public Camera EditorCamera;
|
||||
|
||||
[SerializeField] public GameObject EditorLetterbox;
|
||||
// [SerializeField] public GameObject EditorLetterbox;
|
||||
[SerializeField] public GameObject GameLetterbox;
|
||||
|
||||
[Header("Rect")]
|
||||
|
@ -52,6 +52,7 @@ namespace HeavenStudio.Editor
|
|||
[SerializeField] private Button EditorThemeBTN;
|
||||
[SerializeField] private Button FullScreenBTN;
|
||||
[SerializeField] private Button TempoFinderBTN;
|
||||
[SerializeField] private Button SnapDiagBTN;
|
||||
|
||||
[Header("Tooltip")]
|
||||
public TMP_Text tooltipText;
|
||||
|
@ -105,27 +106,75 @@ namespace HeavenStudio.Editor
|
|||
Tooltip.AddTooltip(EditorThemeBTN.gameObject, "Editor Theme");
|
||||
Tooltip.AddTooltip(FullScreenBTN.gameObject, "Preview <color=#adadad>[Tab]</color>");
|
||||
Tooltip.AddTooltip(TempoFinderBTN.gameObject, "Tempo Finder");
|
||||
Tooltip.AddTooltip(SnapDiagBTN.gameObject, "Snap Settings");
|
||||
|
||||
UpdateEditorStatus(true);
|
||||
}
|
||||
|
||||
public void LateUpdate()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Tab))
|
||||
#region Keyboard Shortcuts
|
||||
if (!editingInputField)
|
||||
{
|
||||
if (!Editor.instance.editingInputField)
|
||||
if (Input.GetKeyDown(KeyCode.Tab))
|
||||
{
|
||||
Fullscreen();
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Delete))
|
||||
{
|
||||
if (!Editor.instance.editingInputField)
|
||||
if (Input.GetKeyDown(KeyCode.Delete))
|
||||
{
|
||||
List<TimelineEventObj> ev = new List<TimelineEventObj>();
|
||||
for (int i = 0; i < Selections.instance.eventsSelected.Count; i++) ev.Add(Selections.instance.eventsSelected[i]);
|
||||
CommandManager.instance.Execute(new Commands.Deletion(ev));
|
||||
}
|
||||
|
||||
if (Input.GetKey(KeyCode.LeftControl))
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Z))
|
||||
{
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
CommandManager.instance.Redo();
|
||||
else
|
||||
CommandManager.instance.Undo();
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Y))
|
||||
{
|
||||
CommandManager.instance.Redo();
|
||||
}
|
||||
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.D))
|
||||
{
|
||||
ToggleDebugCam();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.GetKey(KeyCode.LeftControl))
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.N))
|
||||
{
|
||||
LoadRemix("");
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.O))
|
||||
{
|
||||
OpenRemix();
|
||||
}
|
||||
else if (Input.GetKey(KeyCode.LeftAlt))
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.S))
|
||||
{
|
||||
SaveRemix(true);
|
||||
}
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.S))
|
||||
{
|
||||
SaveRemix(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
if (CommandManager.instance.canUndo())
|
||||
UndoBTN.transform.GetChild(0).GetComponent<Image>().color = "BD8CFF".Hex2RGB();
|
||||
|
@ -137,29 +186,6 @@ namespace HeavenStudio.Editor
|
|||
else
|
||||
RedoBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
|
||||
|
||||
if (Input.GetKey(KeyCode.LeftControl))
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Z))
|
||||
{
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
CommandManager.instance.Redo();
|
||||
else
|
||||
CommandManager.instance.Undo();
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Y))
|
||||
{
|
||||
CommandManager.instance.Redo();
|
||||
}
|
||||
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.D))
|
||||
{
|
||||
ToggleDebugCam();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Timeline.instance.timelineState.selected && Editor.instance.canSelect)
|
||||
{
|
||||
if (Input.GetMouseButtonUp(0))
|
||||
|
@ -182,37 +208,6 @@ namespace HeavenStudio.Editor
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.GetKey(KeyCode.LeftControl))
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.N))
|
||||
{
|
||||
LoadRemix("");
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.O))
|
||||
{
|
||||
OpenRemix();
|
||||
}
|
||||
else if (Input.GetKey(KeyCode.LeftAlt))
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.S))
|
||||
{
|
||||
SaveRemix(true);
|
||||
}
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.S))
|
||||
{
|
||||
SaveRemix(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (Application.isEditor)
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.S))
|
||||
{
|
||||
// SaveRemix(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Sprite GameIcon(string name)
|
||||
|
@ -441,7 +436,7 @@ namespace HeavenStudio.Editor
|
|||
{
|
||||
if (fullscreen == false)
|
||||
{
|
||||
EditorLetterbox.SetActive(false);
|
||||
// EditorLetterbox.SetActive(false);
|
||||
GameLetterbox.SetActive(true);
|
||||
|
||||
MainCanvas.enabled = false;
|
||||
|
@ -453,7 +448,7 @@ namespace HeavenStudio.Editor
|
|||
}
|
||||
else
|
||||
{
|
||||
EditorLetterbox.SetActive(true);
|
||||
// EditorLetterbox.SetActive(true);
|
||||
GameLetterbox.SetActive(false);
|
||||
|
||||
MainCanvas.enabled = true;
|
||||
|
@ -466,6 +461,7 @@ namespace HeavenStudio.Editor
|
|||
GameCamera.instance.camera.rect = new Rect(0, 0, 1, 1);
|
||||
GameManager.instance.CursorCam.rect = new Rect(0, 0, 1, 1);
|
||||
GameManager.instance.OverlayCamera.rect = new Rect(0, 0, 1, 1);
|
||||
EditorCamera.rect = new Rect(0, 0, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace HeavenStudio.Editor
|
|||
|
||||
public Beatmap.Entity entity;
|
||||
|
||||
private bool active;
|
||||
public bool active;
|
||||
|
||||
private int childCountAtStart;
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@ namespace HeavenStudio.Editor
|
|||
public GameObject GameEventSelector;
|
||||
public GameObject EventRef;
|
||||
public GameObject CurrentSelected;
|
||||
public RectTransform GameEventSelectorCanScroll;
|
||||
private RectTransform GameEventSelectorRect;
|
||||
private RectTransform eventsParent;
|
||||
|
||||
[Header("Properties")]
|
||||
|
@ -29,9 +31,15 @@ namespace HeavenStudio.Editor
|
|||
private int dragTimes;
|
||||
public float posDif;
|
||||
public int ignoreSelectCount;
|
||||
private float selectorHeight;
|
||||
private float eventSize;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
GameEventSelectorRect = GameEventSelector.GetComponent<RectTransform>();
|
||||
selectorHeight = GameEventSelectorRect.rect.height;
|
||||
eventSize = EventRef.GetComponent<RectTransform>().rect.height;
|
||||
|
||||
eventsParent = EventRef.transform.parent.GetChild(2).GetComponent<RectTransform>();
|
||||
SelectGame("Game Manager", 1);
|
||||
|
||||
|
@ -40,7 +48,7 @@ namespace HeavenStudio.Editor
|
|||
|
||||
private void Update()
|
||||
{
|
||||
if(!Conductor.instance.NotStopped())
|
||||
if(!(EventParameterManager.instance.active || Conductor.instance.NotStopped()))
|
||||
{
|
||||
if (gameOpen)
|
||||
{
|
||||
|
@ -54,11 +62,14 @@ namespace HeavenStudio.Editor
|
|||
}
|
||||
}
|
||||
|
||||
if (Input.mouseScrollDelta.y != 0)
|
||||
if (RectTransformUtility.RectangleContainsScreenPoint(GameEventSelectorCanScroll, Input.mousePosition, Editor.instance.EditorCamera) && Input.mouseScrollDelta.y != 0)
|
||||
{
|
||||
UpdateIndex(currentEventIndex - Mathf.RoundToInt(Input.mouseScrollDelta.y));
|
||||
}
|
||||
}
|
||||
|
||||
//moved here so this updates dynamically with window scale
|
||||
UpdateScrollPosition();
|
||||
}
|
||||
|
||||
#region Functions
|
||||
|
@ -75,26 +86,32 @@ namespace HeavenStudio.Editor
|
|||
else if (currentEventIndex > eventsParent.childCount - 1)
|
||||
currentEventIndex = 0;
|
||||
|
||||
if (currentEventIndex > 2 && eventsParent.childCount >= 8)
|
||||
{
|
||||
if (eventsParent.childCount - 4 > currentEventIndex)
|
||||
{
|
||||
EventRef.transform.parent.DOLocalMoveY((EventRef.GetComponent<RectTransform>().sizeDelta.y) * (currentEventIndex - 2), 0.35f).SetEase(Ease.OutExpo);
|
||||
}
|
||||
else
|
||||
{
|
||||
EventRef.transform.parent.DOLocalMoveY((EventRef.GetComponent<RectTransform>().sizeDelta.y) * (eventsParent.childCount - 7), 0.35f).SetEase(Ease.OutExpo);
|
||||
}
|
||||
}
|
||||
else
|
||||
EventRef.transform.parent.DOLocalMoveY(0, 0.35f).SetEase(Ease.OutExpo);
|
||||
|
||||
CurrentSelected.transform.DOLocalMoveY(eventsParent.transform.GetChild(currentEventIndex).localPosition.y + eventsParent.transform.localPosition.y, 0.35f).SetEase(Ease.OutExpo);
|
||||
|
||||
if (updateCol)
|
||||
SetColors(currentEventIndex);
|
||||
}
|
||||
|
||||
private void UpdateScrollPosition()
|
||||
{
|
||||
selectorHeight = GameEventSelectorRect.rect.height;
|
||||
eventSize = EventRef.GetComponent<RectTransform>().rect.height;
|
||||
|
||||
if (currentEventIndex * eventSize >= selectorHeight/2 && eventsParent.childCount * eventSize >= selectorHeight)
|
||||
{
|
||||
if (currentEventIndex * eventSize < eventsParent.childCount * eventSize - selectorHeight/2)
|
||||
{
|
||||
EventRef.transform.parent.DOLocalMoveY((currentEventIndex * eventSize) - selectorHeight/2, 0.35f).SetEase(Ease.OutExpo);
|
||||
}
|
||||
else
|
||||
{
|
||||
EventRef.transform.parent.DOLocalMoveY((eventsParent.childCount * eventSize) - selectorHeight + (eventSize*0.33f), 0.35f).SetEase(Ease.OutExpo);
|
||||
}
|
||||
}
|
||||
else
|
||||
EventRef.transform.parent.DOLocalMoveY(0, 0.35f).SetEase(Ease.OutExpo);
|
||||
}
|
||||
|
||||
public void SelectGame(string gameName, int index)
|
||||
{
|
||||
if (SelectedGameIcon != null)
|
||||
|
|
28
Assets/Scripts/LevelEditor/SnapDialog.cs
Normal file
28
Assets/Scripts/LevelEditor/SnapDialog.cs
Normal file
|
@ -0,0 +1,28 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
{
|
||||
public class SnapDialog : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject snapSetter;
|
||||
private void Awake()
|
||||
{
|
||||
}
|
||||
|
||||
public void SwitchSnapDialog()
|
||||
{
|
||||
if(snapSetter.activeSelf) {
|
||||
snapSetter.SetActive(false);
|
||||
} else {
|
||||
snapSetter.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/LevelEditor/SnapDialog.cs.meta
Normal file
11
Assets/Scripts/LevelEditor/SnapDialog.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f32d53b1d58c64e41b71bd7520435169
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
36
Assets/Scripts/LevelEditor/Timeline/LayerLabel.cs
Normal file
36
Assets/Scripts/LevelEditor/Timeline/LayerLabel.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
using TMPro;
|
||||
using Starpelly;
|
||||
|
||||
namespace HeavenStudio.Editor.Track
|
||||
{
|
||||
public class LayerLabel : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private RectTransform rect;
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
//convert timeline layer scale to screen space
|
||||
Camera cam;
|
||||
//"your program can't crash if you put everything in a try block"
|
||||
try
|
||||
{
|
||||
cam = Editor.instance.EditorCamera;
|
||||
float layerScaleDist = cam.WorldToScreenPoint(Timeline.instance.LayerCorners[1]).y - Camera.main.WorldToScreenPoint(Timeline.instance.LayerCorners[0]).y;
|
||||
float modScale = Timeline.GetScaleModifier();
|
||||
rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, layerScaleDist/4 * (1/modScale));
|
||||
}
|
||||
catch (System.NullReferenceException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
11
Assets/Scripts/LevelEditor/Timeline/LayerLabel.cs.meta
Normal file
11
Assets/Scripts/LevelEditor/Timeline/LayerLabel.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b90b6b57a843c2245bfdae87a3e8fb21
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -72,6 +72,7 @@ namespace HeavenStudio.Editor.Track
|
|||
GameManager.instance.Beatmap.bpm += increase;
|
||||
UpdateStartingBPMText();
|
||||
UpdateStartingBPMFromText(); // In case the scrolled-to value is invalid.
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -109,6 +110,8 @@ namespace HeavenStudio.Editor.Track
|
|||
|
||||
// In case the newBPM ended up differing from the inputted string.
|
||||
UpdateStartingBPMText();
|
||||
|
||||
Timeline.instance.FitToSong();
|
||||
}
|
||||
|
||||
public void UpdateOffsetFromText()
|
||||
|
@ -160,6 +163,8 @@ namespace HeavenStudio.Editor.Track
|
|||
}
|
||||
|
||||
tempoTimelineObjs.Add(tempoTimelineObj);
|
||||
|
||||
Timeline.instance.FitToSong();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,10 @@ namespace HeavenStudio.Editor.Track
|
|||
|
||||
tempoChange.tempo += newTempo;
|
||||
|
||||
//make sure tempo is positive
|
||||
if (tempoChange.tempo < 1)
|
||||
tempoChange.tempo = 1;
|
||||
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
Vector3 mousePos = Editor.instance.EditorCamera.ScreenToWorldPoint(Input.mousePosition);
|
||||
|
@ -96,6 +100,7 @@ namespace HeavenStudio.Editor.Track
|
|||
private void UpdateTempo()
|
||||
{
|
||||
tempoTXT.text = $"{tempoChange.tempo} BPM";
|
||||
Timeline.instance.FitToSong();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -68,6 +68,7 @@ namespace HeavenStudio.Editor.Track
|
|||
[SerializeField] private RectTransform TimelineSongPosLineRef;
|
||||
[SerializeField] private RectTransform TimelineEventObjRef;
|
||||
[SerializeField] private RectTransform LayersRect;
|
||||
|
||||
public TempoTimeline TempoInfo;
|
||||
public VolumeTimeline VolumeInfo;
|
||||
private RectTransform TimelineSongPosLine;
|
||||
|
@ -83,6 +84,8 @@ namespace HeavenStudio.Editor.Track
|
|||
public Button MusicVolumeBTN;
|
||||
public Slider PlaybackSpeed;
|
||||
|
||||
public Vector3[] LayerCorners = new Vector3[4];
|
||||
|
||||
public static Timeline instance { get; private set; }
|
||||
|
||||
public bool userIsEditingInputField
|
||||
|
@ -256,9 +259,11 @@ namespace HeavenStudio.Editor.Track
|
|||
|
||||
SliderControl();
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
#region Keyboard Shortcuts
|
||||
if (!userIsEditingInputField)
|
||||
{
|
||||
if (!Editor.instance.editingInputField)
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
|
@ -269,20 +274,44 @@ namespace HeavenStudio.Editor.Track
|
|||
PlayCheck(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.P))
|
||||
{
|
||||
if (!Editor.instance.editingInputField)
|
||||
if (Input.GetKeyDown(KeyCode.P))
|
||||
{
|
||||
AutoPlayToggle();
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.M))
|
||||
{
|
||||
if (!Editor.instance.editingInputField)
|
||||
if (Input.GetKeyDown(KeyCode.M))
|
||||
{
|
||||
MetronomeToggle();
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Alpha1))
|
||||
{
|
||||
timelineState.SetState(true, false, false);
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Alpha2))
|
||||
{
|
||||
timelineState.SetState(false, true, false);
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Alpha3))
|
||||
{
|
||||
timelineState.SetState(false, false, true);
|
||||
}
|
||||
|
||||
|
||||
float moveSpeed = 750;
|
||||
if (Input.GetKey(KeyCode.LeftShift)) moveSpeed *= 2;
|
||||
|
||||
if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
|
||||
{
|
||||
TimelineContent.transform.localPosition += new Vector3(moveSpeed * Time.deltaTime, 0);
|
||||
}
|
||||
else if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
|
||||
{
|
||||
TimelineContent.transform.localPosition += new Vector3(-moveSpeed * Time.deltaTime, 0);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
if (Input.GetMouseButton(1) && !Conductor.instance.isPlaying && Editor.MouseInRectTransform(TimelineGridSelect))
|
||||
{
|
||||
|
@ -304,21 +333,6 @@ namespace HeavenStudio.Editor.Track
|
|||
lastBeatPos = TimelineSlider.localPosition.x;
|
||||
}
|
||||
|
||||
float moveSpeed = 750;
|
||||
if (Input.GetKey(KeyCode.LeftShift)) moveSpeed *= 2;
|
||||
|
||||
if (!Editor.instance.editingInputField)
|
||||
{
|
||||
if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
|
||||
{
|
||||
TimelineContent.transform.localPosition += new Vector3(moveSpeed * Time.deltaTime, 0);
|
||||
}
|
||||
else if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
|
||||
{
|
||||
TimelineContent.transform.localPosition += new Vector3(-moveSpeed * Time.deltaTime, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (Conductor.instance.isPlaying)
|
||||
TimelineContent.transform.localPosition = new Vector3((-Conductor.instance.songPositionInBeats * 100) + 200, TimelineContent.transform.localPosition.y);
|
||||
|
||||
|
@ -326,18 +340,19 @@ namespace HeavenStudio.Editor.Track
|
|||
|
||||
CurrentTempo.text = $" = {Conductor.instance.songBpm}";
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Alpha1) && !userIsEditingInputField)
|
||||
{
|
||||
timelineState.SetState(true, false, false);
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Alpha2) && !userIsEditingInputField)
|
||||
{
|
||||
timelineState.SetState(false, true, false);
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Alpha3) && !userIsEditingInputField)
|
||||
{
|
||||
timelineState.SetState(false, false, true);
|
||||
}
|
||||
LayersRect.GetWorldCorners(LayerCorners);
|
||||
}
|
||||
|
||||
public static float GetScaleModifier()
|
||||
{
|
||||
Camera cam = Editor.instance.EditorCamera;
|
||||
return Mathf.Pow(cam.pixelWidth/1280f, 1f) * Mathf.Pow(cam.pixelHeight/720f, 0f);
|
||||
}
|
||||
|
||||
public Vector2 LayerCornersToDist()
|
||||
{
|
||||
Vector3[] v = LayerCorners;
|
||||
return new Vector2(Mathf.Abs(v[1].x - v[2].x), Mathf.Abs(v[3].y - v[1].y));
|
||||
}
|
||||
|
||||
private void SliderControl()
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace HeavenStudio.Editor.Track
|
|||
[SerializeField] private RectTransform resizeGraphic;
|
||||
[SerializeField] private RectTransform leftDrag;
|
||||
[SerializeField] private RectTransform rightDrag;
|
||||
private GameObject moveTemp;
|
||||
// private GameObject moveTemp;
|
||||
|
||||
[Header("Properties")]
|
||||
public Beatmap.Entity entity;
|
||||
|
@ -61,8 +61,9 @@ namespace HeavenStudio.Editor.Track
|
|||
|
||||
lastMovePos = transform.localPosition;
|
||||
|
||||
moveTemp = new GameObject();
|
||||
moveTemp.transform.SetParent(this.transform.parent);
|
||||
// what the fuck????
|
||||
// moveTemp = new GameObject();
|
||||
// moveTemp.transform.SetParent(this.transform.parent);
|
||||
|
||||
bool visible = rectTransform.IsVisibleFrom(Editor.instance.EditorCamera);
|
||||
for (int i = 0; i < this.transform.childCount; i++)
|
||||
|
@ -105,7 +106,7 @@ namespace HeavenStudio.Editor.Track
|
|||
|
||||
#endregion
|
||||
|
||||
SetColor(GetTrack());
|
||||
SetColor(entity.track);
|
||||
|
||||
if (selected)
|
||||
{
|
||||
|
@ -132,6 +133,20 @@ namespace HeavenStudio.Editor.Track
|
|||
if (Conductor.instance.NotStopped())
|
||||
{
|
||||
Cancel();
|
||||
|
||||
if (moving)
|
||||
moving = false;
|
||||
|
||||
if (selected)
|
||||
{
|
||||
selected = false;
|
||||
selectedImage.gameObject.SetActive(false);
|
||||
for (int i = 0; i < outline.childCount; i++)
|
||||
outline.GetChild(i).GetComponent<Image>().color = new Color32(0, 0, 0, 51);
|
||||
}
|
||||
|
||||
rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, Timeline.instance.LayerHeight());
|
||||
this.transform.localPosition = new Vector3(this.transform.localPosition.x, -entity.track * Timeline.instance.LayerHeight());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -157,14 +172,11 @@ namespace HeavenStudio.Editor.Track
|
|||
lastPos_ = transform.localPosition;
|
||||
|
||||
this.transform.position = new Vector3(mousePos.x - startPosX, mousePos.y - startPosY - 0.40f, 0);
|
||||
this.transform.localPosition = new Vector3(Mathf.Clamp(Mathp.Round2Nearest(this.transform.localPosition.x, Timeline.SnapInterval()), 0, Mathf.Infinity), Timeline.instance.SnapToLayer(this.transform.localPosition.y));
|
||||
// moveTemp.transform.position = new Vector3(mousePos.x - startPosX, mousePos.y - startPosY - 0.40f, 0);
|
||||
// moveTemp.transform.localPosition = new Vector3(Mathf.Clamp(Mathp.Round2Nearest(moveTemp.transform.localPosition.x, 0.25f), 0, Mathf.Infinity), Timeline.instance.SnapToLayer(moveTemp.transform.localPosition.y));
|
||||
this.transform.localPosition = new Vector3(Mathf.Max(Mathp.Round2Nearest(this.transform.localPosition.x, Timeline.SnapInterval()), 0), Timeline.instance.SnapToLayer(this.transform.localPosition.y));
|
||||
|
||||
if (lastPos != transform.localPosition)
|
||||
{
|
||||
OnMove();
|
||||
// this.transform.DOLocalMove(new Vector3(Mathf.Clamp(Mathp.Round2Nearest(moveTemp.transform.localPosition.x, 0.25f), 0, Mathf.Infinity), Timeline.instance.SnapToLayer(moveTemp.transform.localPosition.y)), 0.15f).SetEase(Ease.OutExpo);
|
||||
}
|
||||
|
||||
lastPos = transform.localPosition;
|
||||
|
@ -215,6 +227,9 @@ namespace HeavenStudio.Editor.Track
|
|||
{
|
||||
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
|
||||
}
|
||||
|
||||
rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, Timeline.instance.LayerHeight());
|
||||
this.transform.localPosition = new Vector3(this.transform.localPosition.x, -entity.track * Timeline.instance.LayerHeight());
|
||||
}
|
||||
|
||||
#region ClickEvents
|
||||
|
|
|
@ -27,27 +27,33 @@ namespace HeavenStudio.Editor
|
|||
|
||||
private void Update()
|
||||
{
|
||||
Vector2 anchoredPosition = Input.mousePosition;
|
||||
Vector3 anchoredPosition = Input.mousePosition;
|
||||
Camera camera = Editor.instance.EditorCamera;
|
||||
Vector3 canvasScale = Editor.instance.MainCanvas.transform.localScale;
|
||||
Vector2 scale = new Vector2(canvasScale.x, canvasScale.y);
|
||||
float toolTipScale = camera.pixelWidth / 1280f;
|
||||
|
||||
if (anchoredPosition.x + background.rect.width > canvasRect.rect.width)
|
||||
if (anchoredPosition.x + background.rect.width * toolTipScale > camera.pixelWidth)
|
||||
{
|
||||
anchoredPosition.x = canvasRect.rect.width - background.rect.width;
|
||||
anchoredPosition.x = camera.pixelWidth - background.rect.width * toolTipScale;
|
||||
}
|
||||
if (anchoredPosition.x < 0)
|
||||
if (anchoredPosition.x < -camera.pixelWidth)
|
||||
{
|
||||
anchoredPosition.x = 0;
|
||||
anchoredPosition.x = -camera.pixelWidth;
|
||||
}
|
||||
|
||||
if (anchoredPosition.y + background.rect.height > canvasRect.rect.height)
|
||||
if (anchoredPosition.y + background.rect.height * toolTipScale > camera.pixelHeight)
|
||||
{
|
||||
anchoredPosition.y = canvasRect.rect.height - background.rect.height;
|
||||
anchoredPosition.y = camera.pixelHeight - background.rect.height * toolTipScale;
|
||||
}
|
||||
if (anchoredPosition.y < 0)
|
||||
if (anchoredPosition.y < -camera.pixelHeight)
|
||||
{
|
||||
anchoredPosition.y = 0;
|
||||
anchoredPosition.y = -camera.pixelHeight;
|
||||
}
|
||||
|
||||
rectTransform.anchoredPosition = anchoredPosition;
|
||||
anchoredPosition.z = camera.nearClipPlane;
|
||||
anchoredPosition = camera.ScreenToWorldPoint(anchoredPosition);
|
||||
rectTransform.anchoredPosition = anchoredPosition / scale;
|
||||
}
|
||||
|
||||
public static void OnEnter(string tooltipText, string altTooltipText)
|
||||
|
|
94
Assets/Scripts/Util/UiScrollRectEventBubbling.cs
Normal file
94
Assets/Scripts/Util/UiScrollRectEventBubbling.cs
Normal file
|
@ -0,0 +1,94 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using static UnityEngine.EventSystems.ExecuteEvents;
|
||||
|
||||
namespace kamgam
|
||||
{
|
||||
/// <summary>
|
||||
/// Bubbles events to the parent. Use this to overcome EventTriggers which stop scroll and drag events from bubbling.
|
||||
///
|
||||
/// If an EventTrigger component is attached and other code is listening for
|
||||
/// onPointer events then these will NOT be triggered while dragging if DisableEventTriggerWhileDragging
|
||||
/// is true.
|
||||
/// </summary>
|
||||
public class UiScrollRectEventBubbling : MonoBehaviour,
|
||||
IBeginDragHandler,
|
||||
IDragHandler,
|
||||
IEndDragHandler,
|
||||
IScrollHandler
|
||||
|
||||
{
|
||||
[Tooltip("Should the scroll and drag events be forwarded (bubble up) to the parent?")]
|
||||
public bool Bubble = true;
|
||||
|
||||
[Tooltip("Stop EventTriggers from executing events while dragging?")]
|
||||
public bool DisableEventTriggerWhileDragging = true;
|
||||
|
||||
protected EventTrigger eventTrigger;
|
||||
public EventTrigger EventTrigger
|
||||
{
|
||||
get
|
||||
{
|
||||
if (eventTrigger == null)
|
||||
{
|
||||
eventTrigger = this.GetComponent<EventTrigger>();
|
||||
}
|
||||
return eventTrigger;
|
||||
}
|
||||
}
|
||||
|
||||
protected bool dragging = false;
|
||||
|
||||
protected void HandleEventPropagation<T>(Transform goTransform, BaseEventData eventData, EventFunction<T> callbackFunction) where T : IEventSystemHandler
|
||||
{
|
||||
if (Bubble && goTransform.parent != null)
|
||||
{
|
||||
ExecuteEvents.ExecuteHierarchy(goTransform.parent.gameObject, eventData, callbackFunction);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnScroll(PointerEventData eventData)
|
||||
{
|
||||
HandleEventPropagation(transform, eventData, ExecuteEvents.scrollHandler);
|
||||
}
|
||||
|
||||
public void OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
HandleEventPropagation(transform, eventData, ExecuteEvents.beginDragHandler);
|
||||
|
||||
dragging = true;
|
||||
if (DisableEventTriggerWhileDragging && EventTrigger != null)
|
||||
{
|
||||
EventTrigger.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
HandleEventPropagation(transform, eventData, ExecuteEvents.dragHandler);
|
||||
}
|
||||
|
||||
public void OnEndDrag(PointerEventData eventData)
|
||||
{
|
||||
HandleEventPropagation(transform, eventData, ExecuteEvents.endDragHandler);
|
||||
|
||||
dragging = false;
|
||||
if (DisableEventTriggerWhileDragging && EventTrigger != null)
|
||||
{
|
||||
EventTrigger.enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If the object is disabled while being dragged then the EventTrigger would remain disabled.
|
||||
/// </summary>
|
||||
public void OnDisable()
|
||||
{
|
||||
if (DisableEventTriggerWhileDragging && dragging && EventTrigger != null)
|
||||
{
|
||||
dragging = false;
|
||||
EventTrigger.enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Util/UiScrollRectEventBubbling.cs.meta
Normal file
11
Assets/Scripts/Util/UiScrollRectEventBubbling.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c3ed2b8848b1a2c40819efeb60cbf9ec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in a new issue