ExposeMemberAttribute Class Reference

This attribute class has no internal functionality. Rather, it's presence is checked for by the editor-only, EyE.EditorUnity.Tools.ExposedObjectProperties and EyE.EditorUnity.Tools.PropertyExposerFunctions classes which actually implement it.

Detailed Description

Exposed members, including fields, properties and functions, can be drawn without minimal user work by implementing one of the following classes:

  • EyE.EditorUnity.Tools.DefaultExposedMemberEditor
  • EyE.EditorUnity.Tools.DefaultExposedMemberPropertyDrawer
  • EyE.EditorUnity.Tools.DefaultExposedMemberExpandablePropertyDrawer

Usage Examples: EyE.Unity.Examples.Rank

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using EyE.Unity;
{
[CreateAssetMenuAttribute(fileName = "DefaultRank", menuName = "Soldier Objects/Rank", order = 2)]
public class Rank:ScriptableObject
{
[SerializeField]
protected string rankTitle;
[ExposeMember(tooltip = "20 Character Limit")]
public string RankTitle
{
get { return rankTitle; }
set { if (value.Length > 20)
rankTitle = value.Substring(0, 20);
else
rankTitle = value;
}
}
[ExposeMember]
public Texture2D insignia;
}
}

EyE.Unity.Examples.InventoryObjectType

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using EyE.Unity;
{
//[CreateAssetMenuAttribute(fileName = "DefaultInventoryItemType", menuName = "Types/InventoryItemType", order = 0)]
public abstract class InventoryObjectType : ScriptableObject
{
[ExposeMemberAttribute(conditionalDisplayMemberName = "isAnInventoryObjectType", tooltip = "When Saved as an asset, the system will attempted to use this string for filename of the InventoryObjectType asset.")]
public string inventoryObjectTypeName { get { return base.name; } set { base.name = value; } }
[Multiline]
public string typeDescription;
public ObjectSize sizeInInventory = new ObjectSize();
[ExposeMember]
public Mesh model;
[ExposeMember]
public abstract float Price
{
get;
}
bool isAnInventoryObjectType() { return this.GetType() == typeof(InventoryObjectType); }
}
}

EyE.Unity.Examples.WeaponType

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using EyE.Unity;
{
[System.Flags]
public enum DamageType
{ piercing=1, slashing=2, bludgeon=4, fire=8, poison=16}
[CreateAssetMenuAttribute(fileName = "DefaultWeaponType", menuName = "Types/InventoryItemType/WeaponType", order = 1)]
public class WeaponType : InventoryObjectType
{
[ExposeMember(tooltip = "When Saved as an asset, the system will attempted to use this string for filename of the WeaponType asset.")]
public string weaponTypeName { get { return base.name; } set { base.name = value; } }
[ExposeMember(group ="FoldOutDamageDetails", displayOrderInGroup = 0)]
public int Damage = 1;
[ExposeMember(group = "FoldOutDamageDetails", displayOrderInGroup = 1)]
public DamageType typesOfDamageInflicted = DamageType.bludgeon;
[ExposeMember(group = "FoldOutDamageDetails", displayOrderInGroup = 0)]
public float dps { get { return Damage * attackRate; } }
[ExposeMember(alternatelabel ="Fire Rate", alternateLabelConditionalName = "MissleWeapon", tooltip = "Number of attacks per round.")]
public float attackRate=1f;
[ExposeMember(group = "FoldOutMissleWeapon", conditionalDisplayMemberName = "isBaseWeaponType")]
public float range = 1.0f;
private bool __missleWeapon = false;
[ExposeMember(conditionalDisplayMemberName = "isBaseWeaponType")]
public virtual bool MissleWeapon { get { return __missleWeapon; } set { __missleWeapon = value; } }
[ExposeMember(group = "FoldOutMissleWeapon", tooltip ="Number of attacks that can be made before needing to reload.", conditionalDisplayMemberName = "isBaseWeaponType")]
public int maxAmmo;
[ExposeMember(group = "FoldOutMissleWeapon", tooltip = "How long this weapon type takes to reload.", conditionalDisplayMemberName = "isBaseWeaponType")]
public float reloadTime;
[ExposeMember(group = "FoldOutMissleWeapon", tooltip = "Can multiple kinds of ammo be fired by this weapon type.", conditionalDisplayMemberName = "MissleWeapon")]
public bool variableAmmo = false;
[ExposeMember(group = "FoldOutMissleWeapon/FoldOutvariableAmmo", tooltip = "Number typesofAmmo it can fire.", conditionalDisplayMemberName = "MissleWeapon")]
public List<AmmunitionType> usableKindsOfAmmo = new List<AmmunitionType>();
[ExposeMember]
public override float Price
{
get
{
return dps * range;
}
}
protected bool isBaseWeaponType()
{
return GetType() == typeof(WeaponType);
}
}
}

EyE.Unity.Examples.Weapon

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using EyE.Unity;
{
[System.Serializable]
public class Weapon
{
[ExposeMember]
public WeaponType typeOfWeapon;
[ExposeMember]
public int currentAmmo;
[ExposeMember]
public string engraving;
[ExposeMember]
//[ExposeRangeAttrib(0,10)]
public int Quality = 1;
[ExposeMember]
public float Damage
{
get {
if (typeOfWeapon == null) return 0;
return typeOfWeapon.Damage * 2 * Quality;
}
}
}
}

Public Member Functions

 ExposeMemberAttribute (string tooltip="", [CallerLineNumber]int order=0)
 Default constructor that assigns the provided tool-tip to the ExosedProperty.
 

Public Attributes

string alternatelabel
 This value will be used for the Label, but only when the boolean referenced by alternateLabelConditionalName, is true
 
string alternateLabelConditionalName
 Used to optionally reference a boolean member of the object. This bool will determine weather the mainLabel, or alternateLabel is to be used.
 
string conditionalDisplayMemberName
 Name, identifier of the (sibling) bool member, in object containing the exposed member, that will determine if this value is to be displayed or not. Will parse a leading exclamation point '!' to indicate the boolean value should be inverted/negated for the conditional. You can reference or identify a function, accessor or field member with this string.
You can place the referenced member inside
 
int displayOrderInGroup
 Used to define a specific order within the ExposedProperties group (including "no group")
 
bool displayWarningWhenNull
 This option is appropriate only for reference types, not structs or value-types. Setting this option to true makes the member exposer display a warning in the inspector, when no reference has been provided for the exposed member (is null)
 
string group
 The group may reference a member boolean by name, or start with the string "Foldout"; in which case the group will be enclosed in a foldout section, rather than just an indented section.
 
string groupEnableControl
 Applicable only to boolean type members. The specified group is enabled, or disabled(and hidden), by looking at the boolean value of the member the attribute is applied to.
 
bool isAPotentialWarningFlag
 This option is only used when exposing booleans types. When this flag is used, rather than displaying a check box when exposing the boolean, it will display a warning, when the member's value is true, and nothing when the value is false. The Label of the exposed member is displayed as the warning's text.
 
string mainLabel
 if left blank the "nicified" version of the identifier will be used for the label. Otherwise this value will be used for the main label. (exception: see alternateLabel below)
 
string offerCreationFunctionWhenNull
 This option is appropriate only for reference types, not structs or value-types. When specified, a button will be presented when this members reference value is null. The function named in this parameter will be invoked when the button is clicked.
 
bool readOnly
 Signals that the exposed member should NOT allow input. Default value is false.
 
int sourceLineNumber
 stores the source line number the attribute was applied on.
 
string tooltip
 tool-tip assigned for display for the ExposedProperty
 

Inherits Attribute.

EyE.Unity.ExposeMemberAttribute.group
string group
The group may reference a member boolean by name, or start with the string "Foldout"; in which case t...
Definition: ExposeMemberAttribute.cs:88
EyE.Unity.ExposeMemberAttribute.alternatelabel
string alternatelabel
This value will be used for the Label, but only when the boolean referenced by alternateLabelConditio...
Definition: ExposeMemberAttribute.cs:114
EyE.Unity.ExposeMemberAttribute.conditionalDisplayMemberName
string conditionalDisplayMemberName
Name, identifier of the (sibling) bool member, in object containing the exposed member,...
Definition: ExposeMemberAttribute.cs:101
EyE.Unity.ExposeMemberAttribute.tooltip
string tooltip
tool-tip assigned for display for the ExposedProperty
Definition: ExposeMemberAttribute.cs:83
EyE
This namespace contains classes that provide various tools for use in the Unity Editor.
Definition: EmbededXMLTooltip.cs:5
EyE.Unity.Examples
Definition: CatDebugExample.cs:7
EyE.Unity
This namespace holds classes that extended or inherit from various Unity defined classes....
Definition: EmbededXMLTooltip.cs:5
EyE.Unity.ExposeMemberAttribute.alternateLabelConditionalName
string alternateLabelConditionalName
Used to optionally reference a boolean member of the object. This bool will determine weather the mai...
Definition: ExposeMemberAttribute.cs:109
EyE.Unity.ExposeMemberAttribute.ExposeMemberAttribute
ExposeMemberAttribute(string tooltip="", [CallerLineNumber]int order=0)
Default constructor that assigns the provided tool-tip to the ExosedProperty.
Definition: ExposeMemberAttribute.cs:151
EyE.Unity.Examples.DamageType
DamageType
Enum used in WeaponType to show how they are exposed
Definition: WeaponType.cs:12
EyE.Unity.ExposeMemberAttribute.displayOrderInGroup
int displayOrderInGroup
Used to define a specific order within the ExposedProperties group (including "no group")
Definition: ExposeMemberAttribute.cs:105