77 lines
2.2 KiB
C#
77 lines
2.2 KiB
C#
using Cryville.Common.Pdt;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Cryville.Crtr.Components {
|
|
public abstract class SkinComponent : MonoBehaviour {
|
|
#if false
|
|
/// <summary>
|
|
/// The properties of the component.
|
|
/// </summary>
|
|
[Obsolete]
|
|
public Dictionary<string, Property> Properties { get; private set; }
|
|
/// <summary>
|
|
/// Submits a property.
|
|
/// </summary>
|
|
/// <param name="name">The name of the property.</param>
|
|
/// <param name="property">The property itself.</param>
|
|
[Obsolete]
|
|
protected void SubmitProperty(string name, Property property) {
|
|
Properties.Add(name, property);
|
|
}
|
|
/// <summary>
|
|
/// The property of a skin component.
|
|
/// </summary>
|
|
[Obsolete]
|
|
public struct Property {
|
|
/// <summary>
|
|
/// The type of the property.
|
|
/// </summary>
|
|
public readonly Type Type;
|
|
/// <summary>
|
|
/// The callback that gets the property value.
|
|
/// </summary>
|
|
public readonly Func<object> Get;
|
|
/// <summary>
|
|
/// The callback that sets the property value.
|
|
/// </summary>
|
|
public readonly Action<object> Set;
|
|
/// <summary>
|
|
/// Creates a property.
|
|
/// </summary>
|
|
/// <param name="type">The type of the property.</param>
|
|
/// <param name="get">The callback that gets the property value.</param>
|
|
/// <param name="set">The callback that sets the property value.</param>
|
|
public Property(Type type, Func<object> get, Action<object> set) {
|
|
Type = type; Get = get; Set = set;
|
|
}
|
|
}
|
|
#endif
|
|
|
|
/// <summary>
|
|
/// The property operators of the component.
|
|
/// </summary>
|
|
public Dictionary<string, PdtOperator> PropOps { get; private set; }
|
|
/// <summary>
|
|
/// Submits a property.
|
|
/// </summary>
|
|
/// <param name="name">The name of the property.</param>
|
|
/// <param name="property">The property operator.</param>
|
|
protected void SubmitProperty(string name, PdtOperator property) {
|
|
PropOps.Add(name, property);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Create a skin component
|
|
/// </summary>
|
|
protected SkinComponent() {
|
|
// Properties = new Dictionary<string, Property>();
|
|
PropOps = new Dictionary<string, PdtOperator>();
|
|
}
|
|
|
|
public virtual void Init() { }
|
|
protected abstract void OnDestroy();
|
|
}
|
|
}
|