各种优化,movable采音器完善
This commit is contained in:
@@ -219,3 +219,4 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
noteBase: {fileID: 0}
|
||||
ifHold: {fileID: 3901934672832090415}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni;
|
||||
using Ichni.RhythmGame;
|
||||
using UnityEngine;
|
||||
|
||||
public class NotefabContoler : MonoBehaviour
|
||||
{
|
||||
public NoteBase noteBase;
|
||||
public void Onclick()
|
||||
{
|
||||
EditorManager.instance.uiManager.hierarchy.FindTab(noteBase);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae19b314bbfece546a1a8d74d38387ac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,240 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Dreamteck.Splines;
|
||||
using Ichni;
|
||||
using Ichni.Editor;
|
||||
using Ichni.RhythmGame;
|
||||
using TMPro;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SampleWindow : MovableWindow//该window高度为300,横的要在100和500之间切换
|
||||
{
|
||||
public static List<SampleWindow> instances = new List<SampleWindow>();
|
||||
public TMP_InputField DeviverInputField;
|
||||
public TMP_InputField verticalInputField;
|
||||
public TMP_InputField horizontalInputField;
|
||||
public RectTransform LineMovepoint;
|
||||
public RectTransform NoteMovepoint;
|
||||
|
||||
public List<NoteBase> noteBases;
|
||||
public bool isFocus = false;
|
||||
public bool isExpand = false;
|
||||
public int beatDeviver = 100;
|
||||
public int Xdevide = 1;
|
||||
public float realDevider;
|
||||
public GameObject beatLinePrefabv;
|
||||
public GameObject beatLinePrefabh;
|
||||
public GameObject NotePrefab;
|
||||
public RectTransform secBeatLineh;//用于定位屏幕位置
|
||||
float songTime => EditorManager.instance.songInformation.songTime;
|
||||
float songBeat => EditorManager.instance.songInformation.songBeat;
|
||||
float beatmapStartTime => -EditorManager.instance.songInformation.delay;
|
||||
float timePerBeat => 60f / EditorManager.instance.songInformation.bpm;
|
||||
public GameElement gameElement;
|
||||
public SplinePositioner trackPositioner = null;
|
||||
public GameObject trackHead;
|
||||
public void Initialize(GameElement qgameElement, string title)
|
||||
{
|
||||
closeButton.onClick.AddListener(() =>
|
||||
{
|
||||
instances.Remove(this);
|
||||
});
|
||||
if (instances.Where(i => i.gameElement == qgameElement).Count() != 0)
|
||||
{
|
||||
Destroy(this.gameObject);
|
||||
foreach (SampleWindow i in instances)
|
||||
{
|
||||
i.StartCoroutine(WindowAnim.Shake(instances.Where(i => i.gameElement == qgameElement).First().windowRect.gameObject));
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
this.gameElement = qgameElement;
|
||||
if (qgameElement is Track track)
|
||||
{
|
||||
trackPositioner = this.gameObject.AddComponent<SplinePositioner>();
|
||||
trackPositioner.spline = track.trackPathSubmodule.path;
|
||||
trackPositioner.enabled = isFocus;
|
||||
trackPositioner.targetObject = trackHead;
|
||||
}
|
||||
InitializeWindow(title);
|
||||
|
||||
|
||||
//
|
||||
SpawnBeatline();
|
||||
OnceSpawnNote();
|
||||
instances.Add(this);
|
||||
}
|
||||
public void SpawnBeatline()//添加优化措施
|
||||
|
||||
{
|
||||
for (int i = LineMovepoint.childCount - 1; i >= 0; i--)
|
||||
{
|
||||
Destroy(LineMovepoint.GetChild(i).gameObject);
|
||||
}
|
||||
for (int i = 0; i < (int)EditorManager.instance.songInformation.song.length / timePerBeat; i++)
|
||||
{
|
||||
|
||||
|
||||
for (int j = 1; j < Xdevide; j++)
|
||||
{
|
||||
GameObject v = Instantiate(beatLinePrefabh, LineMovepoint);
|
||||
v.transform.localPosition = new Vector3(0, i * beatDeviver + (beatDeviver / Xdevide * j), 0);
|
||||
RawImage g = v.GetComponent<RawImage>();
|
||||
g.color = new Color(g.color.r, g.color.g, g.color.b, 0.2f);
|
||||
if (v.transform.localPosition.y > 600)
|
||||
{
|
||||
Destroy(v);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GameObject u = Instantiate(beatLinePrefabh, LineMovepoint);
|
||||
u.transform.localPosition = new Vector3(0, i * beatDeviver, 0);
|
||||
if (i == 1)
|
||||
{
|
||||
secBeatLineh = u.GetComponent<RectTransform>();
|
||||
realDevider = secBeatLineh.position.y - LineMovepoint.position.y;
|
||||
Debug.Log(realDevider);
|
||||
}
|
||||
if (u.transform.localPosition.y > 600)
|
||||
{
|
||||
Destroy(u);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnceSpawnNote()
|
||||
{
|
||||
if (gameElement is Track track) noteBases = track.GetAllNotes();
|
||||
else if (gameElement is ElementFolder elementFolder) noteBases = elementFolder.GetAllNotes();
|
||||
for (int i = NoteMovepoint.childCount - 1; i >= 0; i--)
|
||||
{
|
||||
Destroy(NoteMovepoint.GetChild(i).gameObject);
|
||||
}
|
||||
foreach (var i in noteBases)
|
||||
{
|
||||
SpawnNote(i);
|
||||
}
|
||||
}
|
||||
private void SpawnNote(NoteBase i)
|
||||
{
|
||||
GameObject u = Instantiate(NotePrefab, NoteMovepoint);
|
||||
u.transform.localPosition = new Vector3(0, i.exactJudgeTime / timePerBeat * beatDeviver, 0);
|
||||
Image color = u.GetComponent<Image>();
|
||||
u.GetComponent<NotefabContoler>().noteBase = i;
|
||||
switch (i)
|
||||
{
|
||||
case Hold hold:
|
||||
color.color = new Color(0, 1, 0, 1);
|
||||
RawImage a = u.GetComponent<RawImage>();
|
||||
a.transform.localPosition = new Vector3(0, (hold.holdEndTime - hold.exactJudgeTime) / timePerBeat * beatDeviver / 2, 0);
|
||||
a.GetComponent<RectTransform>().sizeDelta = new Vector2(0, (hold.holdEndTime - hold.exactJudgeTime) / timePerBeat * beatDeviver);
|
||||
break;
|
||||
|
||||
case Tap:
|
||||
color.color = new Color(0, 1, 1, 1);
|
||||
break;
|
||||
|
||||
case Stay:
|
||||
color.color = new Color(1, 1, 0, 1);
|
||||
break;
|
||||
|
||||
case Flick:
|
||||
color.color = new Color(1, 0.2f, 0, 1);
|
||||
break;
|
||||
}//服了,之后整合到controler里头去
|
||||
}
|
||||
void Update()
|
||||
|
||||
{
|
||||
|
||||
LineMovepoint.localPosition = new(0, -beatDeviver * (songBeat - (int)songBeat), 0);
|
||||
NoteMovepoint.localPosition = new(0, -beatDeviver * songBeat, 0);
|
||||
if (isFocus && gameElement is Track track)
|
||||
{
|
||||
if (track.trackTimeSubmodule is TrackTimeSubmoduleMovable trackTimeSubmoduleMovable)
|
||||
{
|
||||
trackPositioner.SetPercent(track.trackTimeSubmodule.headPercent);
|
||||
windowRect.GetComponent<CanvasGroup>().alpha = (songTime >= trackTimeSubmoduleMovable.trackStartTime && songTime <= trackTimeSubmoduleMovable.trackEndTime) ? 1f : 0.2f;
|
||||
|
||||
}
|
||||
else if (track.trackTimeSubmodule is TrackTimeSubmoduleStatic)
|
||||
{
|
||||
trackPositioner.SetPercent(0f);
|
||||
}
|
||||
TransformChanged();
|
||||
windowRect.GetComponent<CanvasGroup>().alpha = track.timeDurationSubmodule.CheckTimeInDuration(songTime) ? 1f : 0.2f;
|
||||
}
|
||||
|
||||
}
|
||||
void TransformChanged()
|
||||
{
|
||||
RectTransform canvasRect = EditorManager.instance.inspectorCanvas.GetComponent<RectTransform>();
|
||||
Vector2 ScreenPosition = EditorManager.instance.cameraManager.currentCamera.WorldToScreenPoint(trackHead.transform.position);
|
||||
|
||||
if (RectTransformUtility.ScreenPointToLocalPointInRectangle(canvasRect, ScreenPosition, null, out Vector2 uiPosition))
|
||||
{
|
||||
windowRect.anchoredPosition = new Vector2(uiPosition.x, uiPosition.y + 150f);
|
||||
}
|
||||
}
|
||||
public void ChangeFocus()
|
||||
{
|
||||
isFocus = !isFocus;
|
||||
if (trackPositioner != null) trackPositioner.enabled = isFocus;
|
||||
}
|
||||
public void ChangeXdevide(string devide)
|
||||
{
|
||||
Xdevide = int.Parse(devide);
|
||||
SpawnBeatline();
|
||||
}
|
||||
public void ChangeBeatdevide(string devide)
|
||||
{
|
||||
beatDeviver = int.Parse(devide);
|
||||
SpawnBeatline();
|
||||
OnceSpawnNote();
|
||||
}
|
||||
public void ChangeExpand()
|
||||
{
|
||||
if (isExpand)
|
||||
{
|
||||
isExpand = false;
|
||||
windowRect.sizeDelta = new Vector2(100, windowRect.sizeDelta.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
isExpand = true;
|
||||
windowRect.sizeDelta = new Vector2(500, windowRect.sizeDelta.y);
|
||||
}
|
||||
}
|
||||
public void AddNote()
|
||||
{
|
||||
// 获取鼠标在 NoteMovepoint 中的相对位置
|
||||
Vector2 localMousePosition = NoteMovepoint.InverseTransformPoint(Mouse.current.position.ReadValue());
|
||||
Debug.Log(localMousePosition);
|
||||
|
||||
|
||||
float mouseBeat = localMousePosition.y / beatDeviver;
|
||||
float far = 0f;
|
||||
while (far < mouseBeat)
|
||||
{
|
||||
far += 1f / Xdevide;
|
||||
}
|
||||
far -= 1f / Xdevide;
|
||||
float time = far * timePerBeat;
|
||||
|
||||
if (!isExpand)//movable
|
||||
{
|
||||
Tap a = Tap.GenerateElement("New Tap", Guid.NewGuid(), new List<string>(), true, gameElement, time);
|
||||
noteBases.Add(a);
|
||||
SpawnNote(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a48a638548bdb6645bfa74867dc72087
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -185,7 +185,6 @@ RectTransform:
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 5187296554905279573}
|
||||
- {fileID: 8216584910314174699}
|
||||
- {fileID: 4291884888778775130}
|
||||
m_Father: {fileID: 70126183804589383}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
@@ -1086,138 +1085,6 @@ MonoBehaviour:
|
||||
m_hasFontAssetChanged: 0
|
||||
m_baseMaterial: {fileID: 0}
|
||||
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
||||
--- !u!1 &3825130537493743442
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 8216584910314174699}
|
||||
- component: {fileID: 6318520465025258386}
|
||||
- component: {fileID: 356359123782394345}
|
||||
- component: {fileID: 82358708566530618}
|
||||
m_Layer: 5
|
||||
m_Name: Add
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &8216584910314174699
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3825130537493743442}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 6090386518530065525}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 15.5804}
|
||||
m_SizeDelta: {x: 500, y: 271.1608}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &6318520465025258386
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3825130537493743442}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &356359123782394345
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3825130537493743442}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 0}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Type: 1
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!114 &82358708566530618
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3825130537493743442}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Navigation:
|
||||
m_Mode: 3
|
||||
m_WrapAround: 0
|
||||
m_SelectOnUp: {fileID: 0}
|
||||
m_SelectOnDown: {fileID: 0}
|
||||
m_SelectOnLeft: {fileID: 0}
|
||||
m_SelectOnRight: {fileID: 0}
|
||||
m_Transition: 0
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
||||
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: 0.1
|
||||
m_SpriteState:
|
||||
m_HighlightedSprite: {fileID: 0}
|
||||
m_PressedSprite: {fileID: 0}
|
||||
m_SelectedSprite: {fileID: 0}
|
||||
m_DisabledSprite: {fileID: 0}
|
||||
m_AnimationTriggers:
|
||||
m_NormalTrigger: Normal
|
||||
m_HighlightedTrigger: Highlighted
|
||||
m_PressedTrigger: Pressed
|
||||
m_SelectedTrigger: Selected
|
||||
m_DisabledTrigger: Disabled
|
||||
m_Interactable: 1
|
||||
m_TargetGraphic: {fileID: 356359123782394345}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 7258356208599686677}
|
||||
m_TargetAssemblyTypeName: SampleWindow, Assembly-CSharp
|
||||
m_MethodName: AddNote
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
--- !u!1 &5039759906105514086
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -2580,7 +2447,7 @@ RectTransform:
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_ConstrainProportionsScale: 1
|
||||
m_Children:
|
||||
- {fileID: 3623418567324571912}
|
||||
- {fileID: 8670700627722813223}
|
||||
|
||||
@@ -58,7 +58,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 0, g: 1, b: 1, a: 0.2627451}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
|
||||
Reference in New Issue
Block a user