82 lines
2.3 KiB
C#
82 lines
2.3 KiB
C#
//============= 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(NamedCanvasGroup))]
|
|
public class NamedCanvasGroupInspector : ComponentHandlerInspector {
|
|
}
|
|
#endif
|
|
|
|
[System.Serializable, RequireComponent(typeof(CanvasGroup))]
|
|
public class NamedCanvasGroup : ComponentHandler {
|
|
public override string TypeLabel () {
|
|
return "CanvasGroup";
|
|
}
|
|
|
|
public override string ContentLabel() {
|
|
UpdateComponent();
|
|
return "";
|
|
}
|
|
|
|
public override void UpdateComponent() {
|
|
base.UpdateComponent();
|
|
canvasGroupComponent = GetComponent<CanvasGroup>();
|
|
}
|
|
|
|
public CanvasGroup canvasGroupComponent;
|
|
|
|
public bool changeInteractable = true;
|
|
|
|
public override void Start() {
|
|
}
|
|
|
|
// public override void Update() {
|
|
// base.Update();
|
|
// }
|
|
|
|
public override string titleText {
|
|
get {
|
|
return "FadeIn&Out Canvas Groups";
|
|
}
|
|
}
|
|
|
|
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}\")"}
|
|
};
|
|
}
|
|
}
|
|
|
|
#region both values setting
|
|
public override void SetAlpha(float alpha) {
|
|
if (canvasGroupComponent != null) {
|
|
canvasGroupComponent.alpha = 1 - alpha;
|
|
if (changeInteractable) {
|
|
canvasGroupComponent.blocksRaycasts = canvasGroupComponent.interactable = (canvasGroupComponent.alpha >= 0.03f);
|
|
}
|
|
}
|
|
}
|
|
|
|
public override float GetAlpha() {
|
|
if (canvasGroupComponent != null) {
|
|
return 1-canvasGroupComponent.alpha;
|
|
}
|
|
return 0;
|
|
}
|
|
#endregion
|
|
}
|