TextObject
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Ichni.Editor;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UniRx;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
@@ -12,7 +15,8 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
public bool isOverridingDuration; //是否手动设置了时间区间,开启时,子物体的时间区间将被忽略,且在自动计算区间时跳过此模块
|
||||
public float startTime, endTime; //起止时间
|
||||
|
||||
public IDisposable timeObserver;
|
||||
|
||||
public TimeDurationSubmodule(GameElement attachedGameElement) : base(attachedGameElement)
|
||||
{
|
||||
isOverridingDuration = false;
|
||||
@@ -38,7 +42,7 @@ namespace Ichni.RhythmGame
|
||||
}
|
||||
}
|
||||
|
||||
public bool CheckTimeInDuration(float time, float offset = 0.2f)
|
||||
public bool CheckTimeInDuration(float time, float offset = 0.1f)
|
||||
{
|
||||
return time >= startTime - offset && time <= endTime + offset;
|
||||
}
|
||||
@@ -91,15 +95,38 @@ namespace Ichni.RhythmGame
|
||||
startTime = durations.Min(duration => duration.x);
|
||||
endTime = durations.Max(duration => duration.y);
|
||||
}
|
||||
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new TimeDurationSubmodule_BM(attachedGameElement);
|
||||
}
|
||||
}
|
||||
|
||||
public partial class TimeDurationSubmodule
|
||||
{
|
||||
public void SetUpObserver(UnityAction enableAction, UnityAction disableAction = null)
|
||||
{
|
||||
timeObserver?.Dispose();
|
||||
timeObserver = Observable.EveryUpdate().Subscribe(_ =>
|
||||
{
|
||||
float songTime = EditorManager.instance.songInformation.songTime;
|
||||
if (CheckTimeInDuration(songTime, 0f) && !attachedGameElement.gameObject.activeSelf)
|
||||
{
|
||||
attachedGameElement.gameObject.SetActive(true);
|
||||
enableAction?.Invoke();
|
||||
Debug.Log($"TimeDurationSubmodule: {attachedGameElement.elementName} is active at time {songTime}, duration: [{startTime}, {endTime}]");
|
||||
}
|
||||
else if (!CheckTimeInDuration(songTime, 0f) && attachedGameElement.gameObject.activeSelf)
|
||||
{
|
||||
attachedGameElement.gameObject.SetActive(false);
|
||||
disableAction?.Invoke();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public partial class TimeDurationSubmodule
|
||||
{
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new TimeDurationSubmodule_BM(attachedGameElement);
|
||||
}
|
||||
|
||||
public override void SetUpInspector()
|
||||
{
|
||||
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace Ichni.RhythmGame
|
||||
track.trackPathSubmodule.pathNodeList.Remove(this);
|
||||
track.trackPathSubmodule.SetPathPoints();
|
||||
track.Refresh();
|
||||
print("PathNode " + elementName + " destroyed.");
|
||||
//print("PathNode " + elementName + " destroyed.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user