HeavenStudioPlus/Assets/Scripts/LevelEditor/Timeline/KeepSizeRelativeToContent.cs
Braedon Lewis c7d829c033 General editor improvements (#257)
* Spaceball cleanup and small bug fix

* Replace old hit sound in spaceball

* Camera filters

* added 9 new filters, including 3 types of sepia

* oops

* remark

* normalization of fade out and fade in on filters are by 100

* GenerateFilterTypeEnum comments

* Pure black and white filter

* Zooming

* Constant playback bar offset

* Prepare box selector rewrite

* Update icons, finalize
2023-02-04 22:05:36 -05:00

32 lines
858 B
C#

using UnityEngine;
using UnityEngine.UI;
namespace HeavenStudio.Editor.Track
{
public class KeepSizeRelativeToContent : MonoBehaviour
{
private RectTransform rectTransform;
public float sizeDeltaXInternal;
public float sizeDeltaX = 1.0f;
public float multiply;
private void Start()
{
rectTransform = GetComponent<RectTransform>();
SetScale(Timeline.instance.TimelineContent.localScale.x);
}
private void LateUpdate()
{
SetScale(Timeline.instance.TimelineContent.localScale.x);
}
private void SetScale(float scale)
{
rectTransform.localScale = new Vector3((1.0f / scale) * multiply, transform.localScale.y, 1);
LayoutRebuilder.ForceRebuildLayoutImmediate(rectTransform);
}
}
}