//============= 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; #if UNITY_EDITOR using UnityEditor; [CustomEditor(typeof(NamedImage))] public class NamedImageInspector : ComponentHandlerInspector { } #endif [System.Serializable] public class NamedImage : ComponentHandler { public override string TypeLabel () { return "NamedImage"; } public override string ContentLabel() { UpdateComponent(); return ""; } public override void UpdateComponent() { base.UpdateComponent(); imageComponent = GetComponentInChildren(); } public Image imageComponent; public override string titleText { get { return "Show/Hide, FadeIn/Out"; } } public override string[][] helpText { get { return new string[][] { new string[] {"Show", null, $"BTC.Show(\"{roomId}\", \"{gameObject.name}\")"}, new string[] {"Hide", null, $"BTC.Hide(\"{roomId}\", \"{gameObject.name}\")"}, new string[] {"FadeIn", null, $"BTC.FadeIn(\"{roomId}\", \"{gameObject.name}\")"}, new string[] {"FadeOut", null, $"BTC.FadeOut(\"{roomId}\", \"{gameObject.name}\")"}, }; } } // public override void Start () { // } // public override void Set (NodeState nodeState, string key, string value) { // if (nodeState == NodeState.FirstRun) { // if (key == "text") { // uiTextComponent.text = value; // Task.SetSucceeded(); // return; // } // } // Task.SetFailed(); // } // public override void Update () { // base.Update(); // } #region both values setting public override void SetAlpha(float alpha) { if (imageComponent != null) { Color col = imageComponent.color; col.a = 1 - alpha; imageComponent.color = col; } } public override float GetAlpha() { if (imageComponent != null) { return 1-imageComponent.color.a; } return 0; } #endregion }