---
tags:
    - "String"
    - "Text"
    - "Name"
    - "Key"
    - "Mount"
    - "Muzzle"
    - "Sight"
    - "Grip"
    - "Slot"
---

# Id

[Ids](index.md) / **Id**

<div class="grid cards" markdown>

* :green_circle: Can Read

* :red_circle: Cannot Write

</div>

## Description

A constant id, which only keeps letters, digits, dashes and underscores

## Code

```cs
using System;
using UnityEngine;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Get]

    [Inline(nameof(m_Id))]

    [Title("Id")]
    [Category("Ids/Id")]

    [Description("A constant id, which only keeps letters, digits, dashes and underscores")]
    [Image(typeof(IconID), ColorTheme.Type.Yellow)]

    [Keywords("String", "Text", "Name", "Key", "Mount", "Muzzle", "Sight", "Grip", "Slot")]

    [Serializable]
    public class TypeStringId : TypeString, ISerializationCallbackReceiver
    {
        [SerializeField] private string m_Id;

        // CONSTRUCTORS: --------------------------------------------------------------------------

        public TypeStringId() : this(string.Empty)
        { }

        public TypeStringId(string id)
        {
            this.m_Id = TextUtils.MakeId(id);
        }

        // PUBLIC METHODS: ------------------------------------------------------------------------

        public override string GetPreview(GameObject source) => this.m_Id;

        public override string Get(Args args) => this.m_Id;

        public override string ToString() => this.m_Id;

        // SERIALIZATION: -------------------------------------------------------------------------

        void ISerializationCallbackReceiver.OnBeforeSerialize()
        {
            this.m_Id = TextUtils.MakeId(this.m_Id);
        }

        void ISerializationCallbackReceiver.OnAfterDeserialize()
        { }

        protected override SubscriptionMode Subscription => SubscriptionMode.OnEditorChange;
    }
}

```

