This page will show the public values and methods available to scripters to control the MegaScatter system.
MegaScatter Enums
This holds the two types that control how many scattered objects appear in the scene.
{
Density,
Count,
}
Density
Scatter count is calculated from Area of meshes and splines.
Count
Scatter count is set via the Count values in MegaScatter and MegaScatterMeshInf classes.
MegaScatterCol Class
This simple class is used for Texture scatter objects to define color masks.
{
public Color lowcol;
public Color highcol;
}
Members
lowcol
Defines the start of a color range used by Texture scatter classes, texture color will need to fall between this and highcol for an object to be placed.
highcol
Defines the end of a color range used by Texture scatter classes, texture color will need to fall between this and lowcol for an object to be placed.
MegaScatterLayer Class
This is the main Scatter Layer
{
public string LayerName;
public bool Enabled;
public GameObject obj;
public float weight;
public float scale;
public bool uniformScaling;
public float uniscaleLow;
public float uniscaleHigh;
public Vector3 prerot;
public Vector3 scaleLow;
public Vector3 scaleHigh;
public Vector3 rotLow;
public Vector3 rotHigh;
public Vector3 offsetLow;
public Vector3 offsetHigh;
public Vector3 snap;
public Vector3 snapRot;
public AnimationCurve distCrv;
public int seed;
public bool noOverlap;
public float radius;
public float colradiusadj;
public int raycount;
public float align;
public bool clearOverlap;
public bool markstatic;
public float minDistance;
public float maxDistance;
public float colAmt;
public AnimationCurve colcurve;
public int forcecount;
public int maxcount;
public bool perCurveCount;
public List<MegaScatterCol> scattercols;
public AnimationCurve scaleOnDist;
public int vertexlimit;
public bool vertexnoise;
public float noisescale;
public Vector3 strength;
public List<Color> colvariations;
public float minslope;
public float maxslope;
public float collisionOffset;
public bool useheight;
public float minheight;
public float maxheight;
}
Members
LayerName
Name for the layer.
Enabled
Whether the layer is active in the scatter or not.
obj
The source object to use for this layer.
weight
How much this layer will contribute to the overall scatter count. The higher the number relative to other layers the more of this layer object will be in the scatter.
scale
A quick scale value for this layer, makes it easier if you have source objects of different sizes.
uniformScaling
Should the random scaling be uniform across all axis or use per axis values. If true then uniscalelow and uniscalehigh will be used as the scaling range, if false scaleLow and scaleHigh will be used.
uniscaleLow
The low value for the uniform scaling variation.
uniscaleHigh
The high value for the uniform scaling variation.
prerot
Some objects have differnt up values etc, so here you can correct that so objects appear correctly when scattered.
scaleLow
The low scale Vector3 value to use for scaling variation.
scaleHigh
The high scale Vector3 value to use for scaling variation.
rotLow
The low rotation Vector3 value to use for rotation variation.
rotHigh
The high scale Vector3 value to use for rotation variation.
offsetLow
The low offset Vector3 value to use for positioning variation.
offsetHigh
The high offset Vector3 value to use for positioning variation.
snap
The position snap values, use this to make objects snap to grid positions.
snapRot
The rotation snap values, use this to make scatter objects only use certain angles.
distCrv
This curve describes the distribution of the random number.
seed
The random number seed for the layer.
noOverlap
Set tto true if you want the system to check for overlapping objects.
radius
The radius for the layer used in the overlap test.
colradiusadj
When scattering against walls etc you can increase the radius check size to force things away from ignore objects, Has no effect on overlap just on ignore objects.
raycount
Number of rays to use in the raycasts, the more used the more accurate the tests.
align
Value from 0 to 1 to say how much the layer should align with any ground object.
clearOverlap
Clears the overlap data so layer can overlap already scattered objects but not itself.
markstatic
Marks any created objects as static in the scene.
minDistance
For scatter along objects this is the min distance from the spline an object can appear, 0 means on the spline.
maxDistance
For scatter along objects this is the max distance from the spline an object can appear.
colAmt
How much the vertical coloring alpha is applied to the layer.
colcurve
Curve that controls the vertical coloring of the mesh alpha, can be used to make things stiffer at the bottom etc.
forcecount
This value will override any counts calculated for this layer. 0 means use calculated count.
maxcount
The maximum number of objects to be scattered for this layer, again will override any other count values.
perCurveCount
If the scatter shape is made up of multiple splines setting this will mean the counts are calculated for each spline as opposed to the whole shape.
scattercols
For scattering to textures this holds the list of the various color masks for the scattering.
scaleOnDist
For scatter along objects you can control the scaling of the scatter mesh based on distance from the spline using this curve.
vertexlimit
The max vertex count before a new mesh is created.
vertexnoise
Set to true to apply vertex noise to mesh scatters.
noisescale
The roughness of the noise.
strength
How much noise to apply to each axis.
colvariations
If the scatter objects are being colored this list holds the color variations to use.
minslope
The min slope angle this layer can be scattered on.
maxslope
The max slope angle this layer can be scattered on.
collisionOffset
Allows for control of how far above or below the ground meshes will appear, useful for fine tuning meshes to sit nicely on the ground if their pivots are not at the base.
useheight
Set to true to use the height values below to control scattering.
minheight
The height below which this layer will not be scattered.
maxheight
The height above which this layer will not be scattered.
MegaScatterCollisionObj
This class is used to describe objects that scatters can and can not appear on.
{
public Collider collider;
public bool active;
}
Members
collider
The collider object to use in the scene.
active
Whether is collider is used in the scatter tests.
MegaScatter
This is the base class for the various Scatter Object types in the system.
{
public bool buildOnStart;
public bool update;
public bool meshPerShape;
public float Density;
public int forcecount;
public MegaScatterMode countmode;
public int StartCurve
public int EndCurve;
public bool raycast;
public bool NeedsGround;
public float collisionOffset;
public MegaShape shape;
public List<bool> usespline;
public List<MegaScatterLayer> layers;
public int seed = 0;
public bool hideObjects;
public Vector3 globalScale;
public bool fillHoles;
public bool colorMesh;
public List<MegaScatterCollisionObj> ignoreobjs;
public List<MegaScatterCollisionObj> surfaces;
public MegaScatterQuery queryObject;
public Collider texturecollider;
}
Members
buildOnStart
Set to true to have scatter objects at start.
update
set to true to allow the system to rescatter.
meshPerShape
Tells the system to make a new mesh for each spline in the scatter shape or color mask for texture scatters.
Density
The density value, the higher the more objects will be scattered.
forcecount
The number of meshes to scatter when in Count mode.
countmode
The mode to use to calculate how many meshes are to be scattered, Count or Density.
StartCurve
If the shape to scatter to has multiple splines you can limit the splines to use by changing this.
EndCurve
If the shape to scatter to has multiple splines you can limit the splines to use by changing this.
raycast
Whether this scatter objects does raycast to position objects on the ground.
NeedsGround
If raycasting but no ground set then with this set to true no object will appear unless there is ground for it.
CollisionOffset
How far above the shape raycasts start.
shape
The shape to scatter into or along.
usespline
This is a list of bools one per spline in the shape so you can turn off or on a spline to control the scatter.
layers
The layers to scatter for this object (see above)
seed
The random number see for this object.
hideObjects
Will hide any objects generated i the hierarchy.
globalScale
A scaling value to apply to all layers, makes it easy to adjust the whole scatter object if it is not the right size.
fillHoles
With multiple spline shapes will tell the system to detect holes and to scatter or not into them.
colorMesh
Tells the system to color the meshes.
ignoreobjs
List of colliders the scatter should not scatter on or near.
surfaces
List of colliders that the scatter should scatter on.
queryObject
Not currently used.
texturecollider
Texture scatters can use either a texture or a textured object.
MegaScatter Methods
The shape used for the scattering can be changed by calling this method with the new MegaShape object to use.
Returns an int with the number of mesh layers the scatter object uses.
Returns a string for the layer whose index is passed in.
Returns true if the layer with the name passed is active in the scatter, false if it is not.
Returns true is the layer is On false if it is Off.
onoff – bool value for the new state of the layer.
Allows you to turn on or off scatter layers by name.
onoff – bool value for the new state of the layer.
Allows you to turn on or off scatter layers by index.
Returns the index for the passed layer name. Returns -1 if name not found.
Tells the Scatter object to re scatter.
Returns the count value for all the objects that were scattered for the layer. Can be used with GetLayerScatterPos to get the positions for all the objects that were placed in the scene.
Returns the count value for all the objects that were scattered for the layer. Can be used with GetLayerScatterPos to get the positions for all the objects that were placed in the scene.
Returns the MegaScatterMeshInf class for the named layer so the values can be altered.
Returns the MegaScatterMeshInf class for the indexe layer so the values can be altered.
num – The index of the scattered object to get the position for. Use GetLayerScatterCount to get the max index value.
Returns the Vector3 value for the given object on the given layer, useful if you need to know where objects were placed.
num – The index of the scattered object to get the position for. Use GetLayerScatterCount to get the max index value.
Returns the Vector3 value for the given object on the given layer, useful if you need to know where objects were placed.
Example Code
Coming soon.
You must be logged in to post a comment.