public PhysicsExtension(PrefabPainterEditor editor) { this.editor = editor; this.gizmo = editor.GetPainter(); forceApplyType = editor.FindProperty(x => x.physicsSettings.forceApplyType); maxIterations = editor.FindProperty(x => x.physicsSettings.maxIterations); forceMinMax = editor.FindProperty(x => x.physicsSettings.forceMinMax); forceAngleInDegrees = editor.FindProperty(x => x.physicsSettings.forceAngleInDegrees); randomizeForceAngle = editor.FindProperty(x => x.physicsSettings.randomizeForceAngle); simulationRunning = editor.FindProperty(x => x.physicsSettings.simulationRunning); simulationStepCount = editor.FindProperty(x => x.physicsSettings.simulationStepCount); if (physicsSimulation == null) { physicsSimulation = ScriptableObject.CreateInstance <PhysicsSimulation>(); } physicsSimulation.ApplySettings(gizmo.physicsSettings); }
private void ApplyPhysics() { PhysicsSimulation physicsSimulation = ScriptableObject.CreateInstance <PhysicsSimulation>(); PhysicsSettings physicsSettings = new PhysicsSettings(); physicsSettings.simulationStepCountMax = gizmo.brushSettings.autoSimulationStepCountMax; physicsSettings.simulationStepIterations = gizmo.brushSettings.autoSimulationStepIterations; physicsSimulation.ApplySettings(physicsSettings); // TODO: use only the new added ones? Transform[] containerChildren = PrefabUtils.GetContainerChildren(gizmo.container); if (gizmo.brushSettings.autoSimulationType == BrushSettings.AutoSimulationType.Once) { physicsSimulation.RunSimulationOnce(containerChildren); } else if (gizmo.brushSettings.autoSimulationType == BrushSettings.AutoSimulationType.Continuous) { physicsSimulation.StartSimulation(containerChildren); } }