1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using Sirenix.OdinInspector;
- namespace KairoEngine.Core.GameActions
- {
- public class GameActionContextGameObject : GameActionContextVariableBase
- {
- [HorizontalGroup("value"), LabelText("@name"), ShowInInspector, PropertyOrder(1), ReadOnly]
- public GameObject value { get => this._value; set => this._value = value; }
-
- [HorizontalGroup("value", 0.14f), Button("@editButtonName"), ShowIf("@canEdit"), PropertyOrder(2)]
- private void EditValue()
- {
- if(showEdit == false)
- {
- showEdit = true;
- editButtonName = "Done";
- }
- else
- {
- showEdit = false;
- editButtonName = "Edit";
- }
- }
- private string editButtonName = "Edit";
- [NonSerialized, ShowInInspector, ShowIf("@showEdit && canEdit"), PropertyOrder(4)] internal GameObject _value;
- public override string GetTypeName() => "GameActionContextGameObject";
- public override string GetVariableName() => "GameObject";
- public override T GetValue<T>(T defaultValue)
- {
- var result = value;
- try
- {
- return (T)System.Convert.ChangeType(value, typeof(T));
- }
- catch
- {
- return defaultValue;
- }
- }
- public static GameActionContextGameObject JSONToGameActionContextGameObject(string data)
- {
- return JsonUtility.FromJson<GameActionContextGameObject>(data);
- }
- public override void OnBeforeSerialize(GameActionObjectSerializer serializer)
- {
- serializer.SerializeGameObject($"{name}-Transform", _value);
- }
- public override void OnBeforeDeserialize(GameActionObjectSerializer serializer)
- {
- _value = serializer.DeserializeGameObject($"{name}-Transform");
- }
-
- }
- }
|