public override void OnInspectorGUI() { BuoyancyForce source = (BuoyancyForce)target; EditorGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); source.BuoyancyCollider = (Collider)EditorGUILayout.ObjectField(new GUIContent("Collider", "The collider that will be used to calculate the buoyancy properties of the rigidbody. The collider should be convex for stability reasons."), source.BuoyancyCollider, typeof(Collider), true); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); source.Quality = (BuoyancyQuality)EditorGUILayout.EnumPopup(new GUIContent("Quality"), source.Quality); EditorGUILayout.EndHorizontal(); if (source.Quality == BuoyancyQuality.Custom) { EditorGUILayout.BeginHorizontal(); source.Samples = EditorGUILayout.IntField(new GUIContent("Samples", "The number of sample points used per axis for the buoyancy simulation. More samples results in more realistic behaviour while using more resources."), source.Samples); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); source.UseWeighting = EditorGUILayout.Toggle(new GUIContent("Use Weighting", "Weighting enables easy tweaking of the buoyancy behaviour. If no weighting is used, realistic proportions, rigidbody masses and fluid densities are required for realistic behaviour."), source.UseWeighting); EditorGUILayout.EndHorizontal(); if (source.UseWeighting) { EditorGUILayout.BeginHorizontal(); source.WeightFactor = EditorGUILayout.Slider(new GUIContent("Weight Factor", "A weight factor of 1 results in enough force to counteract gravity and the rigidbody will stay in equilibrium within the fluid. A weight factor of 2 results in a net force equal to gravity but in the opposite direction (making the rigidbody float in the fluid) and so on."), source.WeightFactor, 0.0f, 10.0f); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); source.DragScalar = EditorGUILayout.FloatField(new GUIContent("Drag Scalar", "A scalar that is multiplied by each fluid volume's drag value before being set as linear drag to the submerged rigidbody."), source.DragScalar); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); source.AngularDragScalar = EditorGUILayout.FloatField(new GUIContent("Ang. Drag Scalar", "A scalar that is multiplied by each fluid volume's angular drag value before being set as angular drag to the submerged rigidbody."), source.AngularDragScalar); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); // Handle change if (GUI.changed) { EditorUtility.SetDirty(target); } }
public void Awake() { // Store a reference to the buoyancy force for later use buoyancyForce = GetComponent<BuoyancyForce>(); }
public void Awake() { // Store a reference to the buoyancy force for later use buoyancyForce = GetComponent <BuoyancyForce>(); }
public void addItem(string playerID, string itemName, float scale, float weight) { if (Network.player.ToString() == playerID) { if (itemName == "stone") { mainStone.transform.localScale = original_stone; mainStone.GetComponent <Rigidbody> ().mass = 1f; // mainStone.transform.localScale = new Vector3(mainStone.transform.localScale.x * scale, mainStone.transform.localScale.y * scale, mainStone.transform.localScale.z * scale); mainStone.GetComponent <Rigidbody> ().mass = weight; Launcher l = (Launcher)mainStone.GetComponent(typeof(Launcher)); l.createCapsule(); BuoyancyForce b = (BuoyancyForce)mainStone.GetComponent(typeof(BuoyancyForce)); b.Resolution = 3; b.Resolution = b.Resolution * int.Parse(scale.ToString()); } else if (itemName == "tube") { tube.transform.localScale = new Vector3(2f, 1.5f, 2f); tube.GetComponent <Rigidbody> ().mass = 1f; tube.transform.localScale = new Vector3(tube.transform.localScale.x * scale, tube.transform.localScale.y * scale, tube.transform.localScale.z * scale); tube.GetComponent <Rigidbody> ().mass = weight; // BuoyancyForce b = (BuoyancyForce) tube.GetComponent(typeof(BuoyancyForce)); // b.Resolution = 3; // b.Resolution = b.Resolution * int.Parse(scale.ToString()); DropABox drop = (DropABox)Button_AddTube.GetComponent(typeof(DropABox)); drop.DropBox(); } else if (itemName == "torus") { torus.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f); torus.GetComponent <Rigidbody> ().mass = 1f; torus.transform.localScale = new Vector3(torus.transform.localScale.x * scale, torus.transform.localScale.y * scale, torus.transform.localScale.z * scale); torus.GetComponent <Rigidbody> ().mass = weight; // BuoyancyForce b = (BuoyancyForce) torus.GetComponent(typeof(BuoyancyForce)); // b.Resolution = 3; // b.Resolution = b.Resolution * int.Parse(scale.ToString()); DropABox drop = (DropABox)Button_AddTorus.GetComponent(typeof(DropABox)); drop.DropBox(); } else if (itemName == "duck") { duck.transform.localScale = new Vector3(4, 4, 4); duck.GetComponent <Rigidbody> ().mass = 1f; duck.transform.localScale = new Vector3(duck.transform.localScale.x * scale, duck.transform.localScale.y * scale, duck.transform.localScale.z * scale); duck.GetComponent <Rigidbody> ().mass = weight; AddDuckOnClient l = (AddDuckOnClient)Button_AddDuck.GetComponent(typeof(AddDuckOnClient)); l.DropDuck(); } } }