Documentation index for AI agents (llms.txt) A Markdown version of every page is available: request the page's source under /docs/, follow the "alternate" link in this page's head, or start from /llms.txt.
Visual Script logo Manual

Random Texture#

Random / Random Texture

  • Can Read

  • Cannot Write

Description#

Picks a random Texture from the list

Parameters#

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

Code#

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;
    }
}
Visual Script logoVisual Script © Catsoft Works 2026. All rights reserved.