mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
v 1.0.0
This commit is contained in:
parent
0828ecd037
commit
2998865184
9821 changed files with 90 additions and 90 deletions
71
Source/Assets/Scripts/GUI/Cards/ActorAddonKeyframeCard.cs
Normal file
71
Source/Assets/Scripts/GUI/Cards/ActorAddonKeyframeCard.cs
Normal file
|
@ -0,0 +1,71 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace RimWorldAnimationStudio
|
||||
{
|
||||
public class ActorAddonKeyframeCard : MonoBehaviour
|
||||
{
|
||||
public string addonName;
|
||||
public Text label;
|
||||
public InputField xOffsetField;
|
||||
public InputField zOffsetField;
|
||||
public InputField rotationField;
|
||||
|
||||
private ActorAddonDef actorAddonDef;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Initialize(ActorAddonDef actorAddonDef)
|
||||
{
|
||||
this.actorAddonDef = actorAddonDef;
|
||||
this.addonName = actorAddonDef.addonName;
|
||||
|
||||
label.text = actorAddonDef.label + ":";
|
||||
|
||||
EventsManager.onAnimationChanged.AddListener(delegate { UpdateGUI(); });
|
||||
EventsManager.onStageIDChanged.AddListener(delegate { UpdateGUI(); });
|
||||
EventsManager.onActorIDChanged.AddListener(delegate { UpdateGUI(); });
|
||||
EventsManager.onStageTickChanged.AddListener(delegate { UpdateGUI(); });
|
||||
EventsManager.onPawnKeyframeChanged.AddListener(delegate { UpdateGUI(); });
|
||||
|
||||
xOffsetField.onEndEdit.AddListener(delegate { OnValueChanged(); });
|
||||
zOffsetField.onEndEdit.AddListener(delegate { OnValueChanged(); });
|
||||
rotationField.onEndEdit.AddListener(delegate { OnValueChanged(); });
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void OnValueChanged()
|
||||
{
|
||||
PawnKeyframe keyframe = Workspace.GetCurrentPawnKeyframe(true);
|
||||
|
||||
keyframe.GetAddonKeyframe(addonName).PosX = float.Parse(xOffsetField.text);
|
||||
keyframe.GetAddonKeyframe(addonName).PosZ = float.Parse(zOffsetField.text);
|
||||
keyframe.GetAddonKeyframe(addonName).Rotation = float.Parse(rotationField.text);
|
||||
|
||||
Workspace.GetCurrentPawnAnimationClip().BuildSimpleCurves();
|
||||
Workspace.RecordEvent("Actor addon position / orientation");
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void UpdateGUI()
|
||||
{
|
||||
PawnAnimationClip clip = Workspace.GetCurrentPawnAnimationClip();
|
||||
|
||||
xOffsetField.SetTextWithoutNotify(string.Format("{0:0.000}", clip.GetActorAddon(addonName).PosX.Evaluate((float)Workspace.StageTick / Workspace.StageWindowSize)));
|
||||
zOffsetField.SetTextWithoutNotify(string.Format("{0:0.000}", clip.GetActorAddon(addonName).PosZ.Evaluate((float)Workspace.StageTick / Workspace.StageWindowSize)));
|
||||
rotationField.SetTextWithoutNotify(string.Format("{0:0.000}", clip.GetActorAddon(addonName).Rotation.Evaluate((float)Workspace.StageTick / Workspace.StageWindowSize)));
|
||||
|
||||
gameObject.SetActive(clip.GetActorAddon(addonName).render == true);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue