/** * <summary>Unregisters a AC_Trigger, so that it is no longer updated</summary> * <param name = "_object">The AC_Trigger to unregister</param> */ public void Unregister(AC_Trigger _object) { if (triggers.Contains(_object)) { triggers.Remove(_object); } }
public void ShowGUI() { AC_Trigger[] triggers = GetComponents <AC_Trigger>(); if (triggers.Length == 0) { EditorGUILayout.HelpBox("This component must be attached to an AC Trigger.", MessageType.Info); return; } AC_Trigger trigger = triggers[0]; if (trigger.source == ActionListSource.InScene) { EditorGUILayout.HelpBox("This component requires that the Trigger's Source field is set to Asset File", MessageType.Warning); return; } else if (trigger.source == ActionListSource.AssetFile && trigger.assetFile != null && trigger.assetFile.NumParameters > 0) { ShowParametersGUI(trigger.assetFile.DefaultParameters, trigger.syncParamValues); } else { EditorGUILayout.HelpBox("No parameters defined for Trigger '" + trigger.gameObject.name + "'.", MessageType.Warning); return; } if (triggers.Length > 1) { EditorGUILayout.HelpBox("Multiple Trigger components detected - parameters will be set for all Triggers that share the same number of parameters as the first.", MessageType.Info); } }
/** * <summary>Registers a AC_Trigger, so that it can be updated</summary> * <param name = "_object">The AC_Trigger to register</param> */ public void Register(AC_Trigger _object) { if (!triggers.Contains(_object)) { triggers.Add(_object); } }
protected void OnRunTrigger(AC_Trigger trigger, GameObject collidingObject) { if (trigger == ownTrigger && trigger.source == ActionListSource.AssetFile) { AssignParameterValues(trigger); } }
public static void PropertiesGUI(AC_Trigger _target) { string[] Options = { "On enter", "Continuous", "On exit" }; if (Application.isPlaying) { if (!_target.IsOn()) { EditorGUILayout.HelpBox("Current state: OFF", MessageType.Info); } } EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Trigger properties", EditorStyles.boldLabel); _target.source = (ActionListSource)EditorGUILayout.EnumPopup("Actions source:", _target.source); if (_target.source == ActionListSource.AssetFile) { _target.assetFile = (ActionListAsset)EditorGUILayout.ObjectField("ActionList asset:", _target.assetFile, typeof(ActionListAsset), false); _target.syncParamValues = EditorGUILayout.Toggle("Sync parameter values?", _target.syncParamValues); } _target.actionListType = (ActionListType)EditorGUILayout.EnumPopup("When running:", _target.actionListType); if (_target.actionListType == ActionListType.PauseGameplay) { _target.isSkippable = EditorGUILayout.Toggle("Is skippable?", _target.isSkippable); } _target.triggerType = EditorGUILayout.Popup("Trigger type:", _target.triggerType, Options); _target.triggerReacts = (TriggerReacts)EditorGUILayout.EnumPopup("Reacts:", _target.triggerReacts); _target.cancelInteractions = EditorGUILayout.Toggle("Cancels interactions?", _target.cancelInteractions); _target.tagID = ShowTagUI(_target.actions.ToArray(), _target.tagID); _target.useParameters = EditorGUILayout.Toggle("Set collider as parameter?", _target.useParameters); EditorGUILayout.Space(); _target.detects = (TriggerDetects)EditorGUILayout.EnumPopup("Trigger detects:", _target.detects); if (_target.detects == TriggerDetects.AnyObjectWithComponent) { _target.detectComponent = EditorGUILayout.TextField("Component name:", _target.detectComponent); } else if (_target.detects == TriggerDetects.AnyObjectWithTag) { _target.detectComponent = EditorGUILayout.TextField("Tag name:", _target.detectComponent); } else if (_target.detects == TriggerDetects.SetObject) { _target.obToDetect = (GameObject)EditorGUILayout.ObjectField("Object to detect:", _target.obToDetect, typeof(GameObject), true); } EditorGUILayout.EndVertical(); if (_target.useParameters) { if (_target.parameters.Count != 1) { ActionParameter newParameter = new ActionParameter(0); newParameter.parameterType = ParameterType.GameObject; newParameter.label = "Collision object"; _target.parameters.Clear(); _target.parameters.Add(newParameter); } } }
public override void OnInspectorGUI() { AC_Trigger _target = (AC_Trigger)target; PropertiesGUI(_target); base.DrawSharedElements(_target); UnityVersionHandler.CustomSetDirty(_target); }
public static void PropertiesGUI(AC_Trigger _target) { string[] Options = { "On enter", "Continuous", "On exit" }; if (Application.isPlaying) { if (!_target.IsOn ()) { EditorGUILayout.HelpBox ("Current state: OFF", MessageType.Info); } } EditorGUILayout.BeginVertical ("Button"); EditorGUILayout.LabelField ("Trigger properties", EditorStyles.boldLabel); _target.source = (ActionListSource) EditorGUILayout.EnumPopup ("Actions source:", _target.source); if (_target.source == ActionListSource.AssetFile) { _target.assetFile = (ActionListAsset) EditorGUILayout.ObjectField ("ActionList asset:", _target.assetFile, typeof (ActionListAsset), false); } _target.actionListType = (ActionListType) EditorGUILayout.EnumPopup ("When running:", _target.actionListType); if (_target.actionListType == ActionListType.PauseGameplay) { _target.isSkippable = EditorGUILayout.Toggle ("Is skippable?", _target.isSkippable); } _target.triggerType = EditorGUILayout.Popup ("Trigger type:", _target.triggerType, Options); _target.cancelInteractions = EditorGUILayout.Toggle ("Cancels interactions?", _target.cancelInteractions); _target.useParameters = EditorGUILayout.Toggle ("Set collider as parameter?", _target.useParameters); EditorGUILayout.Space (); _target.detects = (TriggerDetects) EditorGUILayout.EnumPopup ("Trigger detects:", _target.detects); if (_target.detects == TriggerDetects.AnyObjectWithComponent) { _target.detectComponent = EditorGUILayout.TextField ("Component name:", _target.detectComponent); } else if (_target.detects == TriggerDetects.AnyObjectWithTag) { _target.detectComponent = EditorGUILayout.TextField ("Tag name:", _target.detectComponent); } else if (_target.detects == TriggerDetects.SetObject) { _target.obToDetect = (GameObject) EditorGUILayout.ObjectField ("Object to detect:", _target.obToDetect, typeof (GameObject), true); } EditorGUILayout.EndVertical (); if (_target.useParameters) { if (_target.parameters.Count != 1) { ActionParameter newParameter = new ActionParameter (0); newParameter.parameterType = ParameterType.GameObject; newParameter.label = "Collision object"; _target.parameters.Clear (); _target.parameters.Add (newParameter); } } }
public override void OnInspectorGUI() { AC_Trigger _target = (AC_Trigger)target; PropertiesGUI(_target); base.DrawSharedElements(_target); if (GUI.changed) { EditorUtility.SetDirty(_target); } }
public override void OnInspectorGUI() { AC_Trigger _target = (AC_Trigger)target; if (Application.isPlaying) { if (!_target.IsOn()) { EditorGUILayout.HelpBox("Current state: OFF", MessageType.Info); } } EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Trigger properties", EditorStyles.boldLabel); _target.source = (ActionListSource)EditorGUILayout.EnumPopup("Actions source:", _target.source); if (_target.source == ActionListSource.AssetFile) { _target.assetFile = (ActionListAsset)EditorGUILayout.ObjectField("ActionList asset:", _target.assetFile, typeof(ActionListAsset), false); } _target.actionListType = (ActionListType)EditorGUILayout.EnumPopup("When running:", _target.actionListType); if (_target.actionListType == ActionListType.PauseGameplay) { _target.isSkippable = EditorGUILayout.Toggle("Is skippable?", _target.isSkippable); } _target.triggerType = EditorGUILayout.Popup("Trigger type:", _target.triggerType, Options); _target.cancelInteractions = EditorGUILayout.Toggle("Cancels interactions?", _target.cancelInteractions); _target.useParameters = EditorGUILayout.Toggle("Set collider as parameter?", _target.useParameters); EditorGUILayout.Space(); _target.detects = (TriggerDetects)EditorGUILayout.EnumPopup("Trigger detects:", _target.detects); if (_target.detects == TriggerDetects.AnyObjectWithComponent) { _target.detectComponent = EditorGUILayout.TextField("Component name:", _target.detectComponent); } else if (_target.detects == TriggerDetects.SetObject) { _target.obToDetect = (GameObject)EditorGUILayout.ObjectField("Object to detect:", _target.obToDetect, typeof(GameObject), true); } EditorGUILayout.EndVertical(); DrawSharedElements(); if (GUI.changed) { EditorUtility.SetDirty(_target); } }
public void ShowGUI() { AC_Trigger trigger = GetComponent <AC_Trigger>(); if (trigger.source == ActionListSource.InScene) { EditorGUILayout.HelpBox("This component requires that the Trigger's Source field is set to Asset File", MessageType.Warning); } else if (trigger.source == ActionListSource.AssetFile && trigger.assetFile != null && trigger.assetFile.NumParameters > 0) { ShowParametersGUI(trigger.assetFile.DefaultParameters, trigger.syncParamValues); } else { EditorGUILayout.HelpBox("No parameters defined for Trigger '" + trigger.gameObject.name + "'.", MessageType.Warning); } }
public void Process(AC_Trigger trigger) { if (playerID == -1 && KickStarter.player) { obToDetect = KickStarter.player.gameObject; } if (obToDetect) { bool isInside = trigger.CheckForPoint(obToDetect.transform.position); if (DetermineValidity(isInside, trigger.triggerType)) { if (trigger.IsObjectCorrect(obToDetect)) { trigger.Interact(obToDetect); } } lastFrameWithin = isInside; } }
private void Awake() { if (loadedData) { return; } if (GameIsPlaying() && isActiveAndEnabled) { AC_Trigger trigger = GetComponent <AC_Trigger>(); if (trigger) { if (startState == AC_OnOff.On) { trigger.TurnOn(); } else { trigger.TurnOff(); } } } }
protected void OnRunTrigger(AC_Trigger trigger, GameObject collidingObject) { if (trigger.source != ActionListSource.AssetFile || trigger.assetFile == null) { return; } if (trigger.assetFile.NumParameters == 0) { return; } if (trigger.gameObject != gameObject) { return; } if (trigger != ownTrigger && ownTrigger.assetFile != null && trigger.assetFile.NumParameters != ownTrigger.assetFile.NumParameters) { return; } AssignParameterValues(trigger); }
public static void PropertiesGUI(AC_Trigger _target) { string[] Options = { "On enter", "Continuous", "On exit" }; if (Application.isPlaying) { if (!_target.IsOn()) { EditorGUILayout.HelpBox("Current state: OFF", MessageType.Info); } } CustomGUILayout.BeginVertical(); EditorGUILayout.LabelField("Trigger properties", EditorStyles.boldLabel); _target.source = (ActionListSource)CustomGUILayout.EnumPopup("Actions source:", _target.source, string.Empty, "Where the Actions are stored"); if (_target.source == ActionListSource.AssetFile) { _target.assetFile = (ActionListAsset)CustomGUILayout.ObjectField <ActionListAsset> ("ActionList asset:", _target.assetFile, false, string.Empty, "The ActionList asset that stores the Actions"); _target.syncParamValues = CustomGUILayout.Toggle("Sync parameter values?", _target.syncParamValues, string.Empty, "If True, the ActionList asset's parameter values will be shared amongst all linked ActionLists"); } _target.actionListType = (ActionListType)CustomGUILayout.EnumPopup("When running:", _target.actionListType, string.Empty, "The effect that running the Actions has on the rest of the game"); if (_target.actionListType == ActionListType.PauseGameplay) { _target.isSkippable = CustomGUILayout.Toggle("Is skippable?", _target.isSkippable, string.Empty, "If True, the Actions will be skipped when the user presses the 'EndCutscene' Input button"); } _target.triggerType = CustomGUILayout.Popup("Trigger type:", _target.triggerType, Options, string.Empty, "What kind of contact the Trigger reacts to"); _target.triggerReacts = (TriggerReacts)CustomGUILayout.EnumPopup("Reacts:", _target.triggerReacts, string.Empty, "The state of the game under which the trigger reacts"); _target.cancelInteractions = CustomGUILayout.Toggle("Cancels interactions?", _target.cancelInteractions, string.Empty, "If True, and the Player sets off the Trigger while walking towards a Hotspot Interaction, then the Player will stop and the Interaction will be cancelled"); _target.tagID = ShowTagUI(_target.actions.ToArray(), _target.tagID); if (_target.source == ActionListSource.InScene) { _target.useParameters = CustomGUILayout.Toggle("Set collider as parameter?", _target.useParameters, string.Empty, "If True, the colliding object will be provided as a GameObject parameter"); if (_target.useParameters) { EditorGUILayout.HelpBox("A GameObject parameter will be automatically defined by the Trigger.", MessageType.Info); } } else if (_target.source == ActionListSource.AssetFile && _target.assetFile != null && _target.assetFile.NumParameters > 0) { _target.gameObjectParameterID = Action.ChooseParameterGUI("Collider parameter:", _target.assetFile.DefaultParameters, _target.gameObjectParameterID, ParameterType.GameObject, -1, "The GameObject parameter to automatically set as the colliding object when run."); } _target.detectionMethod = (TriggerDetectionMethod)CustomGUILayout.EnumPopup("Detection method:", _target.detectionMethod, string.Empty, "How this Trigger detects objects. If 'Rigidbody Collider', then it requires that incoming objects have a Rigidbody and a Collider - and it will rely on collisions. If 'Point Based', it will check an incoming object's root position for whether it is within the Trigger's collider boundary."); EditorGUILayout.Space(); if (_target.detectionMethod == TriggerDetectionMethod.RigidbodyCollision) { _target.detects = (TriggerDetects)CustomGUILayout.EnumPopup("Trigger detects:", _target.detects, string.Empty, "What the Trigger will react to"); switch (_target.detects) { case TriggerDetects.AnyObjectWithComponent: _target.detectComponent = CustomGUILayout.TextField("Component name:", _target.detectComponent, string.Empty, "The component that must be attached to an object for the Trigger to react to"); EditorGUILayout.HelpBox("Multiple component names should be separated by a colon ';'", MessageType.Info); break; case TriggerDetects.AnyObjectWithTag: _target.detectComponent = CustomGUILayout.TextField("Tag name:", _target.detectComponent, string.Empty, "The tag that an object must have for the Trigger to react to"); EditorGUILayout.HelpBox("Multiple tags should be separated by a colon ';'", MessageType.Info); break; case TriggerDetects.SetObject: _target.obToDetect = (GameObject)CustomGUILayout.ObjectField <GameObject> ("Object to detect:", _target.obToDetect, true, string.Empty, "The GameObject that the Trigger reacts to"); break; case TriggerDetects.Player: if (KickStarter.settingsManager != null && KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow) { EditorGUILayout.HelpBox("Only the active Player will be detected. To detect all Players, set the 'Detection method' to 'Component name'", MessageType.Info); } break; default: break; } } else if (_target.detectionMethod == TriggerDetectionMethod.TransformPosition) { if (KickStarter.settingsManager == null || KickStarter.settingsManager.playerSwitching == PlayerSwitching.DoNotAllow) { _target.detectsPlayer = CustomGUILayout.Toggle("Detect Player?", _target.detectsPlayer); } else { _target.detectsPlayer = CustomGUILayout.Toggle("Detect active Player?", _target.detectsPlayer); if (_target.detectsPlayer) { _target.detectsAllPlayers = CustomGUILayout.Toggle("Detect inactive Players?", _target.detectsAllPlayers); } } if (_target.obsToDetect == null) { _target.obsToDetect = new List <GameObject>(); } int numObs = _target.obsToDetect.Count; int newNumObs = EditorGUILayout.DelayedIntField("# " + ((_target.detectsPlayer) ? "other " : string.Empty) + "objects to detect:", numObs); if (newNumObs < 0) { newNumObs = 0; } if (newNumObs != numObs) { _target.obsToDetect = ResizeList(_target.obsToDetect, newNumObs); } for (int i = 0; i < _target.obsToDetect.Count; i++) { _target.obsToDetect[i] = (GameObject)EditorGUILayout.ObjectField("Object #" + i + ":", _target.obsToDetect[i], typeof(GameObject), true); } } CustomGUILayout.EndVertical(); if (_target.source == ActionListSource.InScene && _target.useParameters) { if (_target.parameters.Count < 1) { ActionParameter newParameter = new ActionParameter(0); newParameter.parameterType = ParameterType.GameObject; newParameter.label = "Collision object"; _target.parameters.Clear(); _target.parameters.Add(newParameter); } } }
protected void OnEnable() { ownTrigger = GetComponent <AC_Trigger>(); EventManager.OnRunTrigger += OnRunTrigger; }
/** * <summary>Registers a AC_Trigger, so that it can be updated</summary> * <param name = "_object">The AC_Trigger to register</param> */ public void Register(AC_Trigger _object) { triggers.Add(_object); }
/** * <summary>Unregisters a AC_Trigger, so that it is no longer updated</summary> * <param name = "_object">The AC_Trigger to unregister</param> */ public void Unregister(AC_Trigger _object) { triggers.Remove(_object); }
public static void PropertiesGUI(AC_Trigger _target) { string[] Options = { "On enter", "Continuous", "On exit" }; if (Application.isPlaying) { if (!_target.IsOn()) { EditorGUILayout.HelpBox("Current state: OFF", MessageType.Info); } } EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Trigger properties", EditorStyles.boldLabel); _target.source = (ActionListSource)CustomGUILayout.EnumPopup("Actions source:", _target.source, "", "Where the Actions are stored"); if (_target.source == ActionListSource.AssetFile) { _target.assetFile = (ActionListAsset)CustomGUILayout.ObjectField <ActionListAsset> ("ActionList asset:", _target.assetFile, false, "", "The ActionList asset that stores the Actions"); _target.syncParamValues = CustomGUILayout.Toggle("Sync parameter values?", _target.syncParamValues, "", "If True, the ActionList asset's parameter values will be shared amongst all linked ActionLists"); } _target.actionListType = (ActionListType)CustomGUILayout.EnumPopup("When running:", _target.actionListType, "", "The effect that running the Actions has on the rest of the game"); if (_target.actionListType == ActionListType.PauseGameplay) { _target.isSkippable = CustomGUILayout.Toggle("Is skippable?", _target.isSkippable, "", "If True, the Actions will be skipped when the user presses the 'EndCutscene' Input button"); } _target.triggerType = CustomGUILayout.Popup("Trigger type:", _target.triggerType, Options, "", "What kind of contact the Trigger reacts to"); _target.triggerReacts = (TriggerReacts)CustomGUILayout.EnumPopup("Reacts:", _target.triggerReacts, "", "The state of the game under which the trigger reacts"); _target.cancelInteractions = CustomGUILayout.Toggle("Cancels interactions?", _target.cancelInteractions, "", "If True, and the Player sets off the Trigger while walking towards a Hotspot Interaction, then the Player will stop and the Interaction will be cancelled"); _target.tagID = ShowTagUI(_target.actions.ToArray(), _target.tagID); _target.useParameters = CustomGUILayout.Toggle("Set collider as parameter?", _target.useParameters, "", "If True, the colliding object will be provided as a GameObject parameter"); EditorGUILayout.Space(); _target.detects = (TriggerDetects)CustomGUILayout.EnumPopup("Trigger detects:", _target.detects, "", "What the Trigger will react to"); if (_target.detects == TriggerDetects.AnyObjectWithComponent) { _target.detectComponent = CustomGUILayout.TextField("Component name:", _target.detectComponent, "", "The component that must be attached to an object for the Trigger to react to"); EditorGUILayout.HelpBox("Multiple component names should be separated by a colon ';'", MessageType.Info); } else if (_target.detects == TriggerDetects.AnyObjectWithTag) { _target.detectComponent = CustomGUILayout.TextField("Tag name:", _target.detectComponent, "", "The tag that an object must have for the Trigger to react to"); EditorGUILayout.HelpBox("Multiple tags should be separated by a colon ';'", MessageType.Info); } else if (_target.detects == TriggerDetects.SetObject) { _target.obToDetect = (GameObject)CustomGUILayout.ObjectField <GameObject> ("Object to detect:", _target.obToDetect, true, "", "The GameObject that the Trigger reacts to"); } EditorGUILayout.EndVertical(); if (_target.useParameters) { if (_target.parameters.Count != 1) { ActionParameter newParameter = new ActionParameter(0); newParameter.parameterType = ParameterType.GameObject; newParameter.label = "Collision object"; _target.parameters.Clear(); _target.parameters.Add(newParameter); } } }