void OnBoundsTrigger(GameObject bounds) { if (enemyHealth.isDeath()) { return; } BoundsTrigger boundstrigger = bounds.GetComponent <BoundsTrigger> (); if (respect_bounds) { bool flip = false; if (walking_speed >= 0.1f && boundstrigger.position == BoundsTrigger.Position.Right) { flip = true; } if (walking_speed <= 0.1f && boundstrigger.position == BoundsTrigger.Position.Left) { flip = true; } if (flip) { walking_speed = -walking_speed; } } }
public override void OnInspectorGUI() { BoundsTrigger script = (BoundsTrigger)target; // Trigger option: Enum script.onTrigger = (BoundsTrigger.Option)EditorGUILayout.EnumPopup("Action on trigger", script.onTrigger); ViewOptions(ref script); }
void ViewZoom(ref BoundsTrigger script) { script.zoom = EditorGUILayout.Toggle("Zoom", script.zoom); bool enabled = GUI.enabled; GUI.enabled = script.zoom; script.zoomAmount = EditorGUILayout.FloatField("Zoom amount", script.zoomAmount); GUI.enabled = enabled; EditorGUILayout.LabelField("Camera currently set to " + Camera.main.orthographicSize.ToString()); }
void ViewOptions(ref BoundsTrigger script) { // View the rest depending on the trigger choice GUI.enabled = script.onTrigger != BoundsTrigger.Option.disableBounds; EditorGUILayout.Foldout(GUI.enabled, "Options"); if (GUI.enabled) { EditorGUI.indentLevel++; ViewTriggerOnStart(ref script); ViewBounds(ref script); ViewZoom(ref script); EditorGUI.indentLevel--; } }
void ViewBounds(ref BoundsTrigger script) { script.bounds = (BoxCollider2D)EditorGUILayout.ObjectField("Bounds", script.bounds, typeof(BoxCollider2D), true); }
void ViewTriggerOnStart(ref BoundsTrigger script) { // Trigger on start: Boolean script.triggerOnStart = EditorGUILayout.Toggle("Trigger on start", script.triggerOnStart); }