ドキュメント

Unity Engine

Unity Engine

FindKernel(string)

Find ComputeShader kernel index.
読み終わるまでの所要時間 1 分最終更新 1ヶ月前

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.CoreModule
public int FindKernel(string name)

Parameters

name

Name of kernel function as defined in the compute shader source file.

Returns

Type

Description

intThe Kernel index. If the kernel is not found, Unity logs a "FindKernel failed" error message and raises an ArgumentException.

Remarks

A single compute shader can contain many "kernels" (functions that do the computation); FindKernel returns kernel index given the name.
Additional Resources: ComputeShader.Dispatch.

Examples

using UnityEngine;public class ComputeShaderExample : MonoBehaviour{ public ComputeShader computeShader; void Start() { // Find the kernel named "CSMain" in the compute shader int kernelHandle = computeShader.FindKernel("CSMain"); // Log the kernel index Debug.Log($"Kernel 'CSMain' found at index: {kernelHandle}"); }}