// Initialization void Start() { // Extract terrain information if (!terrain) { terrain = Terrain.activeTerrain; } terrain_collider = terrain.GetComponent <Collider>(); terrain_data = terrain.terrainData; terrain_size = terrain_data.size; heightmap_width = terrain_data.heightmapResolution; heightmap_height = terrain_data.heightmapResolution; heightmap_data = terrain_data.GetHeights(0, 0, heightmap_width, heightmap_height); heightmap_data_constant = terrain_data.GetHeights(0, 0, heightmap_width, heightmap_height); heightmap_data_filtered = terrain_data.GetHeights(0, 0, heightmap_width, heightmap_height); current_brush = null; current_brush_primitive = null; // Get classes _feetPlacement = FindObjectOfType <IKFeetPlacement>(); _ragdoll = FindObjectOfType <Ragdoll>(); // Retrieve mass from Ragdoll mass = _ragdoll.CalculateMass(); primitiveMass = primitiveCollider.gameObject.GetComponent <Rigidbody>().mass; // Time elapsed elapsed = 0f; }
public void Activate() { BrushPhysics active_brush = terrain.GetBrush(); if (active_brush) { active_brush.Deactivate(); } terrain.SetBrush(this); active = true; }
public override void OnInspectorGUI() { BrushPhysics myBrush = (BrushPhysics)target; if (myBrush.IsActive()) { DrawDefaultInspector(); } if (ToggleButtonStyleNormal == null) { ToggleButtonStyleNormal = "Button"; ToggleButtonStyleToggled = new GUIStyle(ToggleButtonStyleNormal); ToggleButtonStyleToggled.normal.background = ToggleButtonStyleToggled.active.background; } GUIStyle style = myBrush.IsActive() ? ToggleButtonStyleToggled : ToggleButtonStyleNormal; if (GUILayout.Button("Use", style)) { myBrush.Toggle(); } }
// Get and set active brushes public void SetBrush(BrushPhysics brush) { Debug.Log("[INFO] Setting brush to " + brush); current_brush = brush; }