Search Unity

Question Sebastian Lague's Poisson Disc Sampler

Discussion in 'Scripting' started by pacmaybz, Feb 21, 2024.

  1. pacmaybz

    pacmaybz

    Joined:
    Sep 25, 2023
    Posts:
    5
    Hello everyone this is my first question in the forum.

    I was trying to implement the Poisson Disc Sampler from one of the great Sebastian Lague tutorials found here
    https://github.com/SebLague/Poisson-Disc-Sampling/tree/master/Poisson Disc Sampling E01
    in my project, I simply copied the PoissonDiscSampling.cs class

    Code (CSharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6. public static class PoissonDiscSampling {
    7.  
    8.     public static List<Vector2> GeneratePoints(float radius, Vector2 sampleRegionSize, int numSamplesBeforeRejection = 30) { ...}
    9.        
    10.  
    11.     static bool IsValid(Vector2 candidate, Vector2 sampleRegionSize, float cellSize, float radius, List<Vector2> points, int[,] grid) { ...}
    12. }
    13.  
    I tried to implement this in a Start function, but it's only working for OnValidate(), in the tutorial he is using OnValidate to change parameters on the fly in the inspector to see the behaviour. I don't understand why it works for OnValidate() and it's not working for Start(). If someone could explain the reason for this issue please explain below :)

    Thanks in advance
     
  2. pacmaybz

    pacmaybz

    Joined:
    Sep 25, 2023
    Posts:
    5
    I got my answer, it was quite easy, I just wasn't giving the correct parameters when using start
     
    Yoreki likes this.