UP-Viagg-io/Viagg-io/Assets/Packages/MyBT/BTC/Handlers/NamedAnimation.cs

112 lines
2.7 KiB
C#
Raw Normal View History

2024-01-19 16:30:05 +01:00
//============= Copyright (c) Ludic GmbH, All rights reserved. ==============
//
// Purpose: Part of the My Behaviour Tree Controller Code
//
//=============================================================================
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using MyBT;
using UnityEngine.Video;
#if UNITY_EDITOR
using UnityEditor;
[CustomEditor(typeof(NamedAnimation))]
public class NamedAnimationInspector : ComponentHandlerInspector {
}
#endif
[System.Serializable]
public class NamedAnimation : ComponentHandler {
public override string TypeLabel () {
return "Animation";
}
public override string ContentLabel() {
UpdateComponent();
// return animation.runtimeAnimatorController.name;
return animationComponent.clip.name;
}
public override void UpdateComponent() {
base.UpdateComponent();
animationComponent = GetComponent<Animation>();
}
public Animation animationComponent;
public override void Start() {
}
public override string titleText {
get {
return "Run: start Animation";
}
}
public override string[][] helpText {
get {
return new string[][] {
new string[] {"Start Animation", $"BTC.Run(\"{roomId}\", \"{gameObject.name}\")"}
};
}
}
public override void Run(MyBT.NodeState nodeState) {
// whan aborting
if (nodeState == NodeState.Aborting) {
animationComponent.Stop();
return;
}
// at start
if (nodeState == NodeState.FirstRun) {
// reset event trigger
animationComponent.Play();
}
// during runtime
if (nodeState == NodeState.Running) {
if (!animationComponent.isPlaying) {
Task.SetSucceeded();
return;
}
}
}
// public override void Set(NodeState nodeState, string key, string value) {
// if (nodeState == NodeState.FirstRun) {
// if (key == "text") {
// text.text = value;
// Task.SetSucceeded();
// return;
// }
// }
// Task.SetFailed();
// }
public override void Update() {
base.Update();
}
#region both values setting
// public override void SetAlpha(float alpha) {
// if (text != null) {
// Color col = text.color;
// col.a = 1 - alpha;
// text.color = col;
// }
// }
// public override float GetAlpha() {
// if (text != null) {
// return 1-text.color.a;
// }
// return 0;
// }
#endregion
}