Created
February 18, 2023 07:07
-
-
Save shubhank008/8f6b4ec8b8a0206411473ab1ce5b0ad0 to your computer and use it in GitHub Desktop.
Show EntityId and DataId as readonly properties in inspector/editor for MMORPGKIT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.Serialization; | |
using System; | |
using Unity.Collections; | |
using LiteNetLib; | |
using LiteNetLibManager; | |
using LiteNetLib.Utils; | |
using ReadOnlyAttribute = Unity.Collections.ReadOnlyAttribute; | |
#if UNITY_EDITOR | |
using UnityEditor; | |
#endif | |
namespace MultiplayerARPG | |
{ | |
public abstract partial class BaseGameData : ScriptableObject, IGameData, IComparable | |
{ | |
[Category("DataId/EntityId")] | |
[Header("DataId/EntityId")] | |
[ReadOnly] | |
public int dataId_readonly; | |
public int entityId_readonly; | |
//Need to add call to this method in OnValidate() of BaseGameData.cs | |
void ShowDataIdReadOnly() | |
{ | |
this.dataId_readonly = this.DataId; | |
} | |
} | |
public abstract partial class BasePlayerCharacterEntity | |
{ | |
void ShowDataIdReadOnly() | |
{ | |
this.entityId_readonly = this.EntityId; | |
this.dataId_readonly = this.DataId; | |
} | |
#if UNITY_EDITOR | |
protected override void OnValidate() | |
{ | |
base.OnValidate(); | |
this.ShowDataIdReadOnly(); | |
} | |
#endif | |
} | |
public abstract partial class BaseMonsterCharacterEntity | |
{ | |
void ShowDataIdReadOnly() | |
{ | |
this.entityId_readonly = this.EntityId; | |
this.dataId_readonly = this.DataId; | |
} | |
#if UNITY_EDITOR | |
protected override void OnValidate() | |
{ | |
base.OnValidate(); | |
this.ShowDataIdReadOnly(); | |
} | |
#endif | |
} | |
public abstract partial class DamageableEntity | |
{ | |
[Category("DataId/EntityId")] | |
[Header("DataId/EntityId")] | |
[ReadOnly] | |
public int dataId_readonly; | |
public int entityId_readonly; | |
void ShowDataIdReadOnly() | |
{ | |
this.entityId_readonly = this.EntityId; | |
this.dataId_readonly = 0; | |
} | |
#if UNITY_EDITOR | |
protected override void OnValidate() | |
{ | |
base.OnValidate(); | |
this.ShowDataIdReadOnly(); | |
} | |
#endif | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Need to add call to
ShowDataIdReadOnly()
method in OnValidate() of BaseGameData.csNot needed for all other classes