コード例 #1
0
    public override Vector3 GetRandomPositionInEdge()
    {
        Vector3 pos = Vector3.zero;

        switch (RandomUtility.Index(ActualSize.x, ActualSize.y, ActualSize.z))
        {
        case 0:
            pos = new Vector3(RandomUtility.Extents(Extents.x), RandomUtility.sign * Extents.y, RandomUtility.sign * Extents.z);
            break;

        case 1:
            pos = new Vector3(RandomUtility.sign * Extents.x, RandomUtility.Extents(Extents.y), RandomUtility.sign * Extents.z);
            break;

        case 2:
            pos = new Vector3(RandomUtility.sign * Extents.x, RandomUtility.sign * Extents.y, RandomUtility.Extents(Extents.z));
            break;
        }
        return(GetWorldSpacePosition(pos));
    }
コード例 #2
0
    /// <summary>
    /// 获取表面上随机的位置
    /// </summary>
    public Vector3 GetRandomPositionInSurface()
    {
        Vector3 actualSize = ActualSize;
        Vector3 pos        = Vector3.zero;

        switch (RandomUtility.Index(actualSize.y * actualSize.z, actualSize.x * actualSize.z, actualSize.x * actualSize.y))
        {
        case 0:
            pos = new Vector3(RandomUtility.sign * Extents.x, RandomUtility.Extents(Extents.y), RandomUtility.Extents(Extents.z));
            break;

        case 1:
            pos = new Vector3(RandomUtility.Extents(Extents.x), RandomUtility.sign * Extents.y, RandomUtility.Extents(Extents.z));
            break;

        case 2:
            pos = new Vector3(RandomUtility.Extents(Extents.x), RandomUtility.Extents(Extents.z), RandomUtility.sign * Extents.z);
            break;
        }
        return(GetWorldSpacePosition(pos));
    }
コード例 #3
0
 public override Vector3 GetRandomPositionInArea()
 {
     return(GetWorldSpacePosition(new Vector3(RandomUtility.Extents(Extents.x), RandomUtility.Extents(Extents.y), RandomUtility.Extents(Extents.z))));
 }