mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
Improved adding and removal of anim events
This commit is contained in:
parent
f0d46df3d6
commit
8523abf957
276 changed files with 1401 additions and 5422 deletions
333
Assets/Scripts/Managers/AnimationController.cs
Normal file
333
Assets/Scripts/Managers/AnimationController.cs
Normal file
|
@ -0,0 +1,333 @@
|
|||
using System;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Xml.Serialization;
|
||||
using UnityEngine;
|
||||
using SFB;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace RimWorldAnimationStudio
|
||||
{
|
||||
public class AnimationController : Singleton<AnimationController>
|
||||
{
|
||||
[Header("Animation settings")]
|
||||
public bool isAnimating = false;
|
||||
public int stageTick = 1;
|
||||
|
||||
[Header("Object references")]
|
||||
public Slider stageTimelineSlider;
|
||||
public Dropdown stageLoopDropdown;
|
||||
public InputField cyclesNormalField;
|
||||
public InputField cyclesFastField;
|
||||
public Text stageTickText;
|
||||
public Text stageLengthText;
|
||||
public ActorCard actorCard;
|
||||
public Transform animationTimelines;
|
||||
|
||||
[Header("Prefabs")]
|
||||
public ActorBody actorBodyPrefab;
|
||||
public AnimationTimeline animationTimelinePrefab;
|
||||
|
||||
// Private timing variables
|
||||
private float timeSinceLastUpdate = 0;
|
||||
private int cycleIndex = 0;
|
||||
|
||||
public void Update()
|
||||
{
|
||||
// No animation, exit
|
||||
if (Workspace.animationDef == null) { return; }
|
||||
|
||||
// Dirty animation, reset
|
||||
if (Workspace.animationDef != null && Workspace.isDirty)
|
||||
{ Initialize(); return; }
|
||||
|
||||
// Update tick if animating
|
||||
if (isAnimating)
|
||||
{
|
||||
timeSinceLastUpdate += Time.deltaTime;
|
||||
|
||||
if (timeSinceLastUpdate < 1f / 60f)
|
||||
{ return; }
|
||||
|
||||
timeSinceLastUpdate -= 1f / 60f;
|
||||
stageTick += 1;
|
||||
|
||||
if (stageTick > Workspace.animationClipWindowSize)
|
||||
{
|
||||
if (stageLoopDropdown.value == 1)
|
||||
{ stageTick = 1; }
|
||||
|
||||
else if (stageLoopDropdown.value == 2 && Workspace.stageID < Workspace.animationDef.animationStages.Count - 1)
|
||||
{
|
||||
++cycleIndex;
|
||||
stageTick = 1;
|
||||
|
||||
if (cycleIndex > int.Parse(cyclesNormalField.text))
|
||||
{
|
||||
++Workspace.stageID;
|
||||
cycleIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{ stageTick = Workspace.animationClipWindowSize; }
|
||||
}
|
||||
}
|
||||
|
||||
// Update stage timeline
|
||||
stageTimelineSlider.maxValue = Workspace.animationClipWindowSize;
|
||||
stageTimelineSlider.value = stageTick;
|
||||
stageTickText.text = stageTick.ToString();
|
||||
stageLengthText.text = Workspace.animationClipWindowSize.ToString();
|
||||
|
||||
// Update animation
|
||||
UpdateAnimation();
|
||||
}
|
||||
|
||||
public void UpdateAnimation()
|
||||
{
|
||||
List<ActorBody> actorBodies = GetComponentsInChildren<ActorBody>().ToList();
|
||||
|
||||
for (int actorID = 0; actorID < actorBodies.Count; actorID++)
|
||||
{
|
||||
PawnAnimationClip clip = Workspace.animationDef?.animationStages[Workspace.stageID]?.animationClips[actorID];
|
||||
|
||||
if (clip == null)
|
||||
{ continue; }
|
||||
|
||||
float clipPercent = (float)(stageTick % clip.duration) / clip.duration;
|
||||
|
||||
ActorBody actorBody = actorBodies[actorID];
|
||||
string bodyType = actorBody.bodyType;
|
||||
|
||||
Vector3 deltaPos = new Vector3(clip.BodyOffsetX.Evaluate(clipPercent), 0, clip.BodyOffsetZ.Evaluate(clipPercent));
|
||||
deltaPos += Workspace.animationDef.actors[actorID].bodyTypeOffset.GetOffset(bodyType);
|
||||
|
||||
float bodyAngle = clip.BodyAngle.Evaluate(clipPercent);
|
||||
float headAngle = clip.HeadAngle.Evaluate(clipPercent);
|
||||
|
||||
if (bodyAngle < 0) bodyAngle = 360 - ((-1f * bodyAngle) % 360);
|
||||
if (bodyAngle > 360) bodyAngle %= 360;
|
||||
|
||||
if (headAngle < 0) headAngle = 360 - ((-1f * headAngle) % 360);
|
||||
if (headAngle > 360) headAngle %= 360;
|
||||
|
||||
int bodyFacing = (int)clip.BodyFacing.Evaluate(clipPercent);
|
||||
int headFacing = (int)clip.HeadFacing.Evaluate(clipPercent);
|
||||
|
||||
Vector3 headBob = new Vector3(0, 0, clip.HeadBob.Evaluate(clipPercent)) + PawnUtility.BaseHeadOffsetAt(bodyType, bodyFacing);
|
||||
|
||||
Vector3 bodyPos = new Vector3(deltaPos.x, deltaPos.z, 0);
|
||||
Vector3 headPos = new Vector3(headBob.x, headBob.z, 0);
|
||||
|
||||
actorBody.transform.position = bodyPos;
|
||||
actorBody.transform.eulerAngles = new Vector3(0, 0, bodyAngle);
|
||||
|
||||
actorBody.headRenderer.transform.localPosition = headPos;
|
||||
actorBody.headRenderer.transform.eulerAngles = new Vector3(0, 0, headAngle);
|
||||
|
||||
actorBody.bodyRenderer.sprite = Resources.Load<Sprite>("Textures/Humanlike/Bodies/" + bodyType + bodyFacing);
|
||||
actorBody.headRenderer.sprite = Resources.Load<Sprite>("Textures/Humanlike/Heads/Head" + headFacing);
|
||||
|
||||
actorBody.bodyRenderer.sortingLayerName = clip.layer;
|
||||
actorBody.headRenderer.sortingLayerName = clip.layer;
|
||||
actorBody.headRenderer.sortingOrder = headFacing == 0 ? -1 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
Debug.Log("Initializing animation preview");
|
||||
Reset();
|
||||
|
||||
InitializeAnimationTimeline();
|
||||
StageCardManager.Instance.Initialize();
|
||||
|
||||
Workspace.isDirty = false;
|
||||
}
|
||||
|
||||
public void InitializeAnimationTimeline()
|
||||
{
|
||||
Workspace.animationClipWindowSize = Workspace.animationDef.animationStages[Workspace.stageID].animationClips.Select(x => x.duration).Max();
|
||||
|
||||
cyclesNormalField.text = Mathf.Max(Mathf.CeilToInt((float)Workspace.animationDef.animationStages[Workspace.stageID].playTimeTicks / Workspace.animationClipWindowSize), 1).ToString();
|
||||
cyclesFastField.text = Mathf.Max(Mathf.CeilToInt((float)Workspace.animationDef.animationStages[Workspace.stageID].playTimeTicksQuick / Workspace.animationClipWindowSize), 1).ToString();
|
||||
|
||||
for (int actorID = 0; actorID < Workspace.animationDef.actors.Count; actorID++)
|
||||
{
|
||||
ActorBody actorBody = Instantiate(actorBodyPrefab, transform);
|
||||
actorBody.Initialize(actorID);
|
||||
|
||||
AnimationTimeline animationTimeline = Instantiate(animationTimelinePrefab, animationTimelines);
|
||||
animationTimeline.Initialize(actorID);
|
||||
}
|
||||
|
||||
stageTimelineSlider.maxValue = Workspace.animationClipWindowSize;
|
||||
stageTimelineSlider.value = 1;
|
||||
stageTick = 1;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
Workspace.stageID = 0;
|
||||
|
||||
ResetAnimationTimeline();
|
||||
StageCardManager.Instance.Reset();
|
||||
}
|
||||
|
||||
public void ResetAnimationTimeline()
|
||||
{
|
||||
isAnimating = false;
|
||||
timeSinceLastUpdate = 0;
|
||||
cycleIndex = 0;
|
||||
|
||||
foreach (ActorBody actorBody in GetComponentsInChildren<ActorBody>())
|
||||
{ Destroy(actorBody.gameObject); }
|
||||
|
||||
foreach (Transform animationTimeline in animationTimelines)
|
||||
{ Destroy(animationTimeline.gameObject); }
|
||||
}
|
||||
|
||||
public bool AddAnimationStage()
|
||||
{
|
||||
AnimationStage stage = new AnimationStage();
|
||||
|
||||
return stage.MakeNew();
|
||||
}
|
||||
|
||||
public bool CloneAnimationStage()
|
||||
{
|
||||
AnimationStage stage = Workspace.animationDef.animationStages[Workspace.stageID].Copy();
|
||||
stage.Initialize();
|
||||
stage.stageName += " (Clone)";
|
||||
|
||||
Workspace.animationDef.animationStages.Insert(Workspace.stageID + 1, stage);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool MoveAnimationStage(int startIndex, int delta)
|
||||
{
|
||||
if (startIndex + delta < 0 || startIndex + delta >= Workspace.animationDef.animationStages.Count)
|
||||
{ return false; }
|
||||
|
||||
AnimationStage stage = Workspace.animationDef.animationStages[startIndex];
|
||||
Workspace.animationDef.animationStages[startIndex] = Workspace.animationDef.animationStages[startIndex + delta];
|
||||
Workspace.animationDef.animationStages[startIndex + delta] = stage;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool RemoveAnimationStage()
|
||||
{
|
||||
if (Workspace.animationDef.animationStages.Count == 1)
|
||||
{
|
||||
Debug.LogWarning("Cannot delete animation stage - the animation must contain at least one animation stage.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Workspace.animationDef.animationStages.RemoveAt(Workspace.stageID);
|
||||
Workspace.stageID = Workspace.stageID >= Workspace.animationDef.animationStages.Count ? Workspace.stageID = Workspace.animationDef.animationStages.Count - 1 : Workspace.stageID;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void AddActor()
|
||||
{
|
||||
Actor actor = new Actor();
|
||||
|
||||
if (actor.MakeNew())
|
||||
{ Initialize(); }
|
||||
}
|
||||
|
||||
public void RemoveActor()
|
||||
{
|
||||
if (Workspace.animationDef.actors.Count == 1)
|
||||
{
|
||||
Debug.LogWarning("Cannot delete actor - the animation must contain at least one actor.");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (AnimationStage stage in Workspace.animationDef.animationStages)
|
||||
{ stage.animationClips.RemoveAt(Workspace.actorID); }
|
||||
|
||||
Workspace.animationDef.actors.RemoveAt(Workspace.actorID);
|
||||
Workspace.actorID = Workspace.actorID >= Workspace.animationDef.actors.Count ? Workspace.actorID = Workspace.animationDef.actors.Count - 1 : Workspace.actorID;
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public void AddPawnKeyframe()
|
||||
{
|
||||
PawnAnimationClip clip = Workspace.Instance.GetCurrentPawnAnimationClip();
|
||||
List<PawnKeyframe> keyframes = clip?.keyframes;
|
||||
|
||||
if (clip == null || keyframes == null)
|
||||
{ Debug.LogWarning("Cannot add pawn keyframe - the AnimationDef is invalid"); return; }
|
||||
|
||||
if (keyframes.FirstOrDefault(x => x.atTick == stageTick) != null)
|
||||
{ Debug.LogWarning("Cannot add pawn keyframe - a keyframe already exists at this tick"); return; }
|
||||
|
||||
float clipPercent = (float)(stageTick % clip.duration) / clip.duration;
|
||||
|
||||
PawnKeyframe keyframe = new PawnKeyframe();
|
||||
keyframe.bodyAngle = clip.BodyAngle.Evaluate(clipPercent);
|
||||
keyframe.headAngle = clip.HeadAngle.Evaluate(clipPercent);
|
||||
keyframe.headBob = clip.HeadBob.Evaluate(clipPercent);
|
||||
keyframe.bodyOffsetX = clip.BodyOffsetX.Evaluate(clipPercent);
|
||||
keyframe.bodyOffsetZ = clip.BodyOffsetZ.Evaluate(clipPercent);
|
||||
keyframe.headFacing = clip.HeadFacing.Evaluate(clipPercent);
|
||||
keyframe.bodyFacing = clip.BodyFacing.Evaluate(clipPercent);
|
||||
keyframe.genitalAngle = clip.GenitalAngle.Evaluate(clipPercent);
|
||||
|
||||
keyframe.atTick = stageTick;
|
||||
|
||||
PawnKeyframe nextKeyframe = keyframes.FirstOrDefault(x => x.atTick > stageTick);
|
||||
|
||||
if (nextKeyframe != null)
|
||||
{ keyframes.Insert(keyframes.IndexOf(nextKeyframe), keyframe); }
|
||||
|
||||
else
|
||||
{ keyframes.Add(keyframe); }
|
||||
|
||||
clip.BuildSimpleCurves();
|
||||
|
||||
animationTimelines.GetChild(Workspace.actorID).GetComponent<AnimationTimeline>().AddPawnKeyFrame(keyframe.keyframeID);
|
||||
}
|
||||
|
||||
public void RemovePawnKeyframe()
|
||||
{
|
||||
PawnKeyframe keyframe = Workspace.Instance.GetCurrentPawnKeyframe(false);
|
||||
|
||||
if (keyframe != null)
|
||||
{
|
||||
animationTimelines.GetChild(Workspace.actorID).GetComponent<AnimationTimeline>().RemovePawnKeyFrame(keyframe.keyframeID);
|
||||
|
||||
PawnAnimationClip clip = Workspace.Instance.GetCurrentPawnAnimationClip();
|
||||
clip.keyframes.Remove(keyframe);
|
||||
clip.BuildSimpleCurves();
|
||||
}
|
||||
}
|
||||
|
||||
public void ToggleAnimation()
|
||||
{
|
||||
isAnimating = !isAnimating;
|
||||
}
|
||||
|
||||
public void UpdateFromStageTimelineSlider()
|
||||
{
|
||||
if (Workspace.animationDef == null)
|
||||
{ return; }
|
||||
|
||||
if (stageTick != (int)stageTimelineSlider.value)
|
||||
{ stageTick = (int)stageTimelineSlider.value; }
|
||||
}
|
||||
|
||||
public void ToggleActorManipulationMode(int mode)
|
||||
{
|
||||
Workspace.actorManipulationMode = (ActorManipulationMode)mode;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Managers/AnimationController.cs.meta
Normal file
11
Assets/Scripts/Managers/AnimationController.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5ce34f72fe7ef0c41a7bc163fce97970
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
115
Assets/Scripts/Managers/ApplicationManager.cs
Normal file
115
Assets/Scripts/Managers/ApplicationManager.cs
Normal file
|
@ -0,0 +1,115 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using SFB;
|
||||
|
||||
namespace RimWorldAnimationStudio
|
||||
{
|
||||
public class ApplicationManager : Singleton<ApplicationManager>
|
||||
{
|
||||
public DialogBox exitDialog;
|
||||
public SelectAnimationDialog selectAnimationDialog;
|
||||
|
||||
public void TryToCloseApplication()
|
||||
{
|
||||
exitDialog.Pop();
|
||||
}
|
||||
|
||||
public void CloseApplication()
|
||||
{
|
||||
Debug.Log("Exiting application");
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
public void TryToLoadAnimation()
|
||||
{
|
||||
var paths = StandaloneFileBrowser.OpenFilePanel("Open AnimationDef File", "", "xml", false);
|
||||
|
||||
if (paths == null || paths.Any() == false)
|
||||
{ Debug.LogError("Selected file was null or invalid"); return; }
|
||||
|
||||
Defs defs = XmlUtility.ReadXML<Defs>(paths[0]);
|
||||
|
||||
if (defs?.animationDefs == null)
|
||||
{ Debug.LogError("Selected file contains no animation data"); return; }
|
||||
|
||||
if (defs.animationDefs.Count == 1)
|
||||
{ LoadAnimation(defs.animationDefs[0]); return; }
|
||||
|
||||
selectAnimationDialog.Initialize(defs);
|
||||
selectAnimationDialog.Pop();
|
||||
}
|
||||
|
||||
public void LoadAnimation(AnimationDef animationDef)
|
||||
{
|
||||
Debug.Log("Loaded AnimationDef: " + animationDef.defName);
|
||||
|
||||
Workspace.animationDef = animationDef;
|
||||
animationDef.Initialize();
|
||||
Workspace.isDirty = true;
|
||||
|
||||
var animationDefCards = Resources.FindObjectsOfTypeAll(typeof(AnimationDefCard)) as AnimationDefCard[];
|
||||
|
||||
if (animationDefCards != null)
|
||||
{
|
||||
animationDefCards[0].Initialize();
|
||||
animationDefCards[0].gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void TrySaveAnimation()
|
||||
{
|
||||
if (Workspace.animationDef == null)
|
||||
{ return; }
|
||||
|
||||
string defName = Workspace.animationDef.defName != null && Workspace.animationDef.defName != "" ? Workspace.animationDef.defName : "newAnimationDef";
|
||||
|
||||
var path = StandaloneFileBrowser.SaveFilePanel("Save AnimationDef File", "", defName, "xml");
|
||||
|
||||
if (path != null && path != "")
|
||||
{ SaveAnimation(path); }
|
||||
}
|
||||
|
||||
public void SaveAnimation(string path)
|
||||
{
|
||||
Debug.Log("Saving AnimationDef: " + Workspace.animationDef.defName);
|
||||
|
||||
AnimationDef animationDef = Workspace.animationDef;
|
||||
|
||||
foreach (AnimationStage stage in animationDef.animationStages)
|
||||
{
|
||||
foreach (PawnAnimationClip clip in stage.animationClips)
|
||||
{
|
||||
clip.keyframes = clip.keyframes.OrderBy(x => x.atTick).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Defs defs = new Defs();
|
||||
defs.animationDefs.Add(animationDef);
|
||||
|
||||
XmlUtility.WriteXML(defs, path);
|
||||
}
|
||||
|
||||
public void NewAnimation()
|
||||
{
|
||||
return;
|
||||
|
||||
AnimationDef animationDef = new AnimationDef();
|
||||
|
||||
// Add one stage, add one actor, add one clip, add one frame
|
||||
|
||||
Workspace.animationDef = new AnimationDef();
|
||||
Workspace.isDirty = true;
|
||||
|
||||
var animationDefCards = Resources.FindObjectsOfTypeAll(typeof(AnimationDefCard)) as GameObject[];
|
||||
|
||||
if (animationDefCards != null)
|
||||
{ animationDefCards[0].SetActive(true); }
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Managers/ApplicationManager.cs.meta
Normal file
11
Assets/Scripts/Managers/ApplicationManager.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8c0c094e56b459d42850b3632db6c4ef
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
96
Assets/Scripts/Managers/CameraController.cs
Normal file
96
Assets/Scripts/Managers/CameraController.cs
Normal file
|
@ -0,0 +1,96 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RimWorldAnimationStudio
|
||||
{
|
||||
public class CameraController : MonoBehaviour
|
||||
{
|
||||
private Camera cam;
|
||||
|
||||
[Header("Scroll controls")]
|
||||
public float scrollSpeed = 100f;
|
||||
|
||||
[Header("Zoom controls")]
|
||||
public float zoom = -5f;
|
||||
public float minZoom = -3f;
|
||||
public float maxZoom = -15f;
|
||||
|
||||
[Header("Max bounds")]
|
||||
public float maxBoundsXAxis = 30;
|
||||
public float maxBoundsYAxis = 30;
|
||||
|
||||
private float x;
|
||||
private float y;
|
||||
|
||||
private float curZoom;
|
||||
private bool mouseDragActive = false;
|
||||
private Vector3 mouseDragOrigin;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
x = transform.position.x;
|
||||
y = transform.position.y;
|
||||
|
||||
curZoom = zoom;
|
||||
|
||||
transform.position = new Vector3(transform.position.x, transform.position.y, -10);
|
||||
cam = this.GetComponent<Camera>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetMouseButton(2))
|
||||
{ StartMouseDrag(); }
|
||||
|
||||
else if (Input.GetMouseButtonUp(2))
|
||||
{ ResetMouseDrag(); }
|
||||
|
||||
curZoom += Input.GetAxis("Mouse ScrollWheel") * scrollSpeed * 0.1f;
|
||||
curZoom = Mathf.Clamp(curZoom, maxZoom, minZoom);
|
||||
|
||||
Vector3 cameraPosition = Vector3.Lerp(transform.position, new Vector3(x, y, -10), 0.2f);
|
||||
transform.position = cameraPosition;
|
||||
cam.orthographicSize = Mathf.Abs(curZoom);
|
||||
}
|
||||
|
||||
public void SetPosition(Vector3 position)
|
||||
{
|
||||
x = position.x;
|
||||
y = position.y;
|
||||
|
||||
transform.position = position;
|
||||
}
|
||||
|
||||
public void SetZoom(float zoom)
|
||||
{
|
||||
this.zoom = Mathf.Clamp(zoom, maxZoom, minZoom);
|
||||
}
|
||||
|
||||
public void StartMouseDrag()
|
||||
{
|
||||
Vector3 delta = cam.ScreenToWorldPoint(Input.mousePosition) - cam.transform.position;
|
||||
|
||||
if (mouseDragActive == false)
|
||||
{
|
||||
mouseDragActive = true;
|
||||
mouseDragOrigin = cam.ScreenToWorldPoint(Input.mousePosition);
|
||||
}
|
||||
|
||||
cam.transform.position = mouseDragOrigin - delta;
|
||||
}
|
||||
|
||||
public void ResetMouseDrag()
|
||||
{
|
||||
mouseDragActive = false;
|
||||
}
|
||||
|
||||
public void ResetCamera()
|
||||
{
|
||||
cam.transform.position = new Vector3(0, 0, -10);
|
||||
curZoom = zoom;
|
||||
|
||||
mouseDragActive = false;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Managers/CameraController.cs.meta
Normal file
11
Assets/Scripts/Managers/CameraController.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 192ae5e804d239d42891ba0bdc42e8b6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
55
Assets/Scripts/Managers/StageCardManager.cs
Normal file
55
Assets/Scripts/Managers/StageCardManager.cs
Normal file
|
@ -0,0 +1,55 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace RimWorldAnimationStudio
|
||||
{
|
||||
public class StageCardManager : Singleton<StageCardManager>
|
||||
{
|
||||
public StageCard stageCardPrefab;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
foreach(AnimationStage stage in Workspace.animationDef.animationStages)
|
||||
{ MakeStageCard(stage.stageName); }
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
foreach(StageCard stageCard in GetComponentsInChildren<StageCard>())
|
||||
{ Destroy(stageCard.gameObject); }
|
||||
}
|
||||
|
||||
public StageCard MakeStageCard(string stageName = null)
|
||||
{
|
||||
StageCard stageCard = Instantiate(stageCardPrefab, transform);
|
||||
|
||||
if (stageName != null)
|
||||
{ stageCard.Initialize(stageName); }
|
||||
|
||||
return stageCard;
|
||||
}
|
||||
|
||||
public void OnNewStage()
|
||||
{
|
||||
if (AnimationController.Instance.AddAnimationStage())
|
||||
{ MakeStageCard("NewStage"); }
|
||||
}
|
||||
|
||||
public void OnCloneStage()
|
||||
{
|
||||
if (AnimationController.Instance.CloneAnimationStage())
|
||||
{
|
||||
StageCard stageCard = MakeStageCard(Workspace.animationDef.animationStages[Workspace.stageID + 1].stageName);
|
||||
stageCard.transform.SetSiblingIndex(Workspace.stageID + 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDeleteStage()
|
||||
{
|
||||
if (AnimationController.Instance.RemoveAnimationStage())
|
||||
{ Destroy(transform.GetChild(Workspace.stageID).gameObject); }
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Managers/StageCardManager.cs.meta
Normal file
11
Assets/Scripts/Managers/StageCardManager.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7ecd16bf04b637f4c96d6ae733205d3a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue