private void OnSetupSettings(TempObject tmp, Vector3 position, Quaternion rotation, bool newRandom = false) { Renderer renderer = tmp.toGameObject().GetComponent<Renderer>(); Bounds bounds; if (renderer!=null) { bounds = renderer.bounds; } else { bounds = new Bounds(); } if (newRandom) Generator.generateRandom(tmp); if (windowGUI.generateRandomPosition) tmp.PositionOffset = Generator.generatePosition(tmp.PositionRandom, position, rotation, bounds, tmp.toGameObject().transform.lossyScale, windowGUI.offsetFromValue, windowGUI.offsetToValue, windowGUI.brushSize, windowGUI.useRaycast); if (windowGUI.generateRandomRotation) tmp.RotationOffset = Generator.generateRotation(tmp.PositionRandom, windowGUI.minRotationXValue, windowGUI.maxRotationXValue, windowGUI.minRotationYValue, windowGUI.maxRotationYValue, windowGUI.minRotationZValue, windowGUI.maxRotationZValue); if (windowGUI.generateChangeScale) tmp.ScaleOffset = Generator.generateScale(tmp.PositionRandom, windowGUI.minScaleXValue, windowGUI.maxScaleXValue, windowGUI.minScaleYValue, windowGUI.maxScaleYValue, windowGUI.minScaleZValue, windowGUI.maxScaleZValue); tmp.SetupSettings(position, rotation); // устанавливаем свойства }
public static void generateRandom(TempObject tmp) { tmp.PositionRandom = new Vector3(UnityEngine.Random.value, UnityEngine.Random.value, UnityEngine.Random.value); }
private void OnGenerateObject(Vector3 position, Quaternion rotation) { if (windowGUI.PrefabObject==null) return; TempObject tmp = new TempObject((GameObject)Instantiate(windowGUI.PrefabObject, position, rotation)); tmp.toGameObject().transform.parent = getTmpContainer().transform; OnSetupSettings(tmp, position, rotation, true); tmpData.Add(tmp); }