---
tags:
    - "Dice"
    - "Constant"
    - "Random"
    - "List"
    - "Array"
    - "Any"
    - "Choose"
---

# Random Texture

[Random](index.md) / **Random Texture**

<div class="grid cards" markdown>

* :green_circle: Can Read

* :red_circle: Cannot Write

</div>

## Description

Picks a random Texture from the list

## Parameters

| Name | Description |
| :--- | :---------- |
| Textures | The list of assets one of them is picked from |

## Code

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

namespace VisualScript.Runtime
{
    [Get]

    [Title("Random Texture")]
    [Category("Random/Texture")]

    [Description("Picks a random Texture from the list")]
    [Image(typeof(IconTexture), ColorTheme.Type.Blue, typeof(BadgeDice))]

    [Parameter("Textures", "The list of assets one of them is picked from")]

    [Keywords("Dice", "Constant", "Random", "List", "Array", "Any", "Choose")]

    [Serializable]
    public class TypeTextureRandom : TypeTexture
    {
        [SerializeField] private List<Texture> m_Textures = new List<Texture>();

        public override Texture GetPreview(GameObject source) => this.Pick();

        public override Texture Get(Args args) => this.Pick();

        private Texture Pick()
        {
            int count = this.m_Textures.Count;
            return count > 0 ? this.m_Textures[UnityEngine.Random.Range(0, count)] : null;
        }

        public override string ToString()
        {
            return $"Random Texture ({this.m_Textures.Count})";
        }

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

```

