Skip to content

Game.Rendering.Utilities.GraphicsUtilities

Assembly: Assembly-CSharp (Cities: Skylines 2)

Namespace: Game.Rendering.Utilities

Type: public static class

Base: System.Object

Summary:
Utility class providing helper functions related to graphics for debugging/asset-generation. Currently contains a single helper that procedurally generates a small tiled texture (used as a windows/index map debug texture) and writes it to disk under the game's data folder. The texture is built as 125x125 pixels composed of 5x5 tiles (625 tiles). Each tile is filled with a single random color produced by ColorUtils.NiceRandomColor(). The generated PNG is written to "Art/Resources/Textures/WindowsIdxMapGeneratedDebug.png" inside Application.dataPath. Note: the method uses UnityEngine APIs and must be run on the Unity main thread / in an environment where those APIs are available (editor or game runtime).


Fields

  • None
    No private or public fields are declared in this static utility class.

Properties

  • None
    There are no properties.

Constructors

  • None (static class)
    GraphicsUtilities is a static class and therefore has no instance constructors.

Methods

  • public static void GenerateRandomWindowsTexture()
    Generates a 125x125 Texture2D made of 5x5 tiles (each tile is 5x5 pixels) and saves it as a PNG file to Application.dataPath/Art/Resources/Textures/WindowsIdxMapGeneratedDebug.png.

Details / behaviour: - Creates a 125x125 Texture2D with TextureFormat.RGB24 and no mip chain. - Iterates over 625 tile blocks (25x25 tiles of 5x5 pixels). - For each tile: picks a color using ColorUtils.NiceRandomColor() and fills the 5x5 region with that color. - Uses a local List copied from a 25-element byte array, and removes elements from that list as it fills the tile — however, the byte values themselves are not used to modify color/brightness in the current implementation (likely an unused/buggy remnant). - Calls texture2D.EncodeToPNG() and writes the result using File.WriteAllBytes to the path indicated above. - Destroys the temporary Texture2D via Object.DestroyImmediate(texture2D) to free memory.

Notes and modding tips: - The byte array named collection is never applied to the color values — only used to control removal behavior. If the intent was to vary brightness/alpha by those bytes, the code needs to apply those bytes to the color channels before assigning pixels. - Because it uses Unity APIs (Texture2D, Random, Application, Object.DestroyImmediate), call this function from the main thread (editor script, OnEnable/Start in a MonoBehaviour, or a UI button). Do not call from worker threads. - File writing uses Application.dataPath. In editor builds this will write into the project/game data folder; in a packaged build Application.dataPath may point to read-only locations or different folders — be cautious when writing files in production builds. - The method overwrites the target file each call with no confirmation.

Usage Example

// Example: call from an Editor menu item to generate the debug texture
#if UNITY_EDITOR
using UnityEditor;
using Game.Rendering.Utilities;

public static class DebugTextureGenerator
{
    [MenuItem("Tools/Generate Windows Index Map")]
    public static void Generate()
    {
        GraphicsUtilities.GenerateRandomWindowsTexture();
        UnityEngine.Debug.Log("Generated WindowsIdxMapGeneratedDebug.png");
    }
}
#endif

Alternative runtime example (call from a debug MonoBehaviour):

using UnityEngine;
using Game.Rendering.Utilities;

public class DebugWindowTextureSpawner : MonoBehaviour
{
    void Start()
    {
        // Only call in development builds or for debugging.
        GraphicsUtilities.GenerateRandomWindowsTexture();
    }
}