public RandomScale Clone() { RandomScale clone = new RandomScale(); clone.transform = transform; clone.axis = axis; clone.uniform = uniform; clone.min = min; clone.max = max; return(clone); }
static public RandomScale[] CloneArray(RandomScale[] sources) { int len = sources.Length; RandomScale[] clones = new RandomScale[len]; for (int i = 0; i < len; i++) { clones[i] = sources[i].Clone(); } return(clones); }
private void RandomizeScale() { int len = scales.Length; for (int i = 0; i < len; i++) { RandomScale scaleRandomization = scales[i]; if (defaultToBaseTransform) { scaleRandomization.transform = defaultTransform; } if (scaleRandomization.transform != null) { Vector3 scale = scaleRandomization.transform.localScale; float scaleValue = Random.Range(scaleRandomization.min, scaleRandomization.max); Axis axis = scaleRandomization.axis; // x if (axis == Axis.X || axis == Axis.XZ || axis == Axis.XYZ) { scale.x *= scaleValue; } // y if (!scaleRandomization.uniform) { scaleValue = Random.Range(scaleRandomization.min, scaleRandomization.max); } if (axis == Axis.Y || axis == Axis.YZ || axis == Axis.XYZ) { scale.y *= scaleValue; } // z if (!scaleRandomization.uniform) { scaleValue = Random.Range(scaleRandomization.min, scaleRandomization.max); } if (axis == Axis.Z || axis == Axis.XZ || axis == Axis.XYZ) { scale.z *= scaleValue; } scaleRandomization.transform.localScale = scale; } } }