void Awake() { instance = this; shadowDist = GetComponent <Shadow> ().effectDistance.y; bg = GetComponent <Image> ().color; buttonSound = GetComponent <AudioSource> (); }
private void OnButtonPress(PressButton button, BasePlayer player) { ElevatorButton elevatorButton = button.GetComponent <ElevatorButton>(); if (elevatorButton != null) { elevatorButton.OnButtonPressed(); } }
/// <summary> /// Attaches the prefab entity at the given local position and angles to the parent. /// </summary> /// <param name="aParent">The parent.</param> /// <param name="aPrefab">The prefab for the new entity.</param> /// <param name="aPosition">The local position.</param> /// <param name="anAngle">The local angles.</param> /// <returns></returns> private BaseEntity AttachEntity(BaseEntity aParent, string aPrefab, Vector3 aPosition, Vector3 anAngle = new Vector3(), string aBone = null) { BaseEntity theNewEntity = GameManager.server.CreateEntity(aPrefab, aParent.transform.position); if (!theNewEntity) { return(null); } theNewEntity.Spawn(); Transform theBone = aParent.FindBone(aBone); if (theBone == null && aBone != null) { PrintWarning($"No bone found for name '{aBone}'"); PrintWarning("Valid bone names: " + string.Join(", ", aParent.GetBones().Select(eachBone => eachBone.name))); } if (theBone != null && theBone != aParent.transform) { theNewEntity.SetParent(aParent, theBone.name); theNewEntity.transform.localPosition = theBone.InverseTransformPoint(aParent.transform.TransformPoint(aPosition)); theNewEntity.transform.localRotation = Quaternion.Inverse(theBone.rotation) * (aParent.transform.rotation * Quaternion.Euler(anAngle)); } else { theNewEntity.transform.localPosition = aPosition; theNewEntity.transform.localEulerAngles = anAngle; theNewEntity.SetParent(aParent); } //Puts(theNewEntity.ShortPrefabName + ": (" + theNewEntity.GetComponents<Component>().Length + ") " + string.Join(", ", theNewEntity.GetComponents<Component>().Select(eachComp => eachComp.GetType().Name))); UnityEngine.Object.DestroyImmediate(theNewEntity.GetComponent <DestroyOnGroundMissing>()); UnityEngine.Object.DestroyImmediate(theNewEntity.GetComponent <GroundWatch>()); UnityEngine.Object.DestroyImmediate(theNewEntity.GetComponent <BoxCollider>()); UnityEngine.Object.DestroyImmediate(theNewEntity.GetComponent <InstrumentKeyController>()); theNewEntity.OwnerID = 0; BaseCombatEntity theCombatEntity = theNewEntity as BaseCombatEntity; if (theCombatEntity) { theCombatEntity.pickup.enabled = false; } PressButton theButton = theNewEntity as PressButton; if (theButton) { theButton.pressDuration = 0.2f; } theNewEntity.EnableSaving(true); theNewEntity.SendNetworkUpdateImmediate(); return(theNewEntity); }
void OnButtonPress(PressButton button, BasePlayer player) { if (button.net.ID == configData.button) { SendReply(player, "You have been added to the Whitelist"); storedData.Whitelisted.Add(player.userID); SaveData(); } else { return; } }
//Oxide/uMod has the hook on ButtonPress which will fire everytime a button is pressed //by any player void OnButtonPress(PressButton button, BasePlayer player) { //we will filter the results to buttons that match out config if (button.net.ID == configData.button) { //If the button is the same as the one in the config we tell the player SendReply(player, "You have been added to the Whitelist"); //add the player to the whitelist storedData.Whitelisted.Add(player.userID); //and save the data file SaveData(); } else { //if its not our button Return return; } }
private void CreateButtons() { Vector3 position = Lift.transform.TransformPoint(buttonLowerOffset); ButtonLower = GameManager.server.CreateEntity(BUTTON_PREFAB, position, Lift.transform.rotation * Quaternion.Euler(0f, 180f, 0f)) as PressButton; ButtonLower.enableSaving = false; ButtonLower.Spawn(); ButtonLower.gameObject.AddComponent <ElevatorButton>().Register(this, true); position = Lift.transform.TransformPoint(buttonUpperOffset); ButtonUpper = GameManager.server.CreateEntity(BUTTON_PREFAB, position, Lift.transform.rotation * Quaternion.Euler(0f, -137.8f, 0f)) as PressButton; ButtonUpper.enableSaving = false; ButtonUpper.Spawn(); ButtonUpper.gameObject.AddComponent <ElevatorButton>().Register(this, false); }
private object OnButtonPress(PressButton aButton, BasePlayer aPlayer) { BaseVehicle theVehicle = aButton.GetComponentInParent <BaseVehicle>()?.VehicleParent(); theVehicle = theVehicle ? theVehicle : aButton.GetComponentInParent <BaseVehicle>(); if (theVehicle) { SirenController theController = theVehicle.GetComponent <SirenController>(); if (theController) { if ((config.MountNeeded && aPlayer.GetMountedVehicle() != theVehicle) || !theController.NetIDs.Contains(aButton.net.ID)) { return(false); } theController.ChangeState(); } } return(null); }
void DoActivate(bool open) { if (open) { buttons = new ToggleButton[buttonPrefabs.Length]; for (int i = 0; i < buttons.Length; i++) { GameObject button = (GameObject)Instantiate(buttonPrefabs[i], Vector3.zero, transform.rotation); button.transform.parent = transform; button.transform.localPosition = new Vector3(1, i * 0.5f, 0); buttons[i] = button.GetComponent <ToggleButton>(); RemoteActivatable ra = button.GetComponent <RemoteActivatable>(); ra.target = gameObject; ra.payload = i; } GameObject buildGO = (GameObject)Instantiate(buildButtonPrefab, Vector3.zero, transform.rotation); buildGO.transform.parent = transform; buildGO.transform.localPosition = new Vector3(1.5f, 0.5f, 0); buildButton = buildGO.GetComponent <PressButton>(); buildGO.GetComponent <RemoteActivatable>().target = gameObject; buttons[defaultChoice].on = true; ResetTimer(); } else { for (int i = 0; i < buttons.Length; i++) { buttons[i].DoDestroy(); } buildButton.DoDestroy(); buttons = null; buildButton = null; } isOpen = open; }
private void Awake() { Button = GetComponent <PressButton>(); }
private void Awake() { _Button = GetComponent <PressButton>(); _Button.OnPress += OnButtonPress; _Button.OnRelease += OnButtonRelease; }
private void Awake() { b = new PressButton(); }
// Update is called once per frame void Update() { //quit game if (Input.GetKeyDown(KeyCode.Escape)) { Application.Quit(); } if (Input.GetKeyDown(KeyCode.R)) { SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); } //picking up/dropping object if (Input.GetKeyDown(KeyCode.E) && heldObject == null) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, grabRange)) { GameObject obj = hit.collider.gameObject; Carryable carryable = obj.GetComponent <Carryable>(); if (carryable != null) { GrabObject(obj); } else { PressButton button = obj.GetComponent <PressButton>(); if (button != null) { button.Press(); } } } } else if (Input.GetKeyDown(KeyCode.E) && heldObject != null) { ReleaseObject(heldObject); } //moving held object if (heldObject != null) { Rigidbody rigid = heldObject.GetComponent <Rigidbody>(); Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); Vector3 targetPos = ray.GetPoint(2); rigid.velocity = -(heldObject.transform.position - targetPos) * 20; } //duplicating object if (Input.GetMouseButtonDown(0) && heldObject == null) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, grabRange)) { GameObject obj = hit.collider.gameObject; Carryable carryable = obj.GetComponent <Carryable>(); if (carryable != null) { CloneObject(obj); } } } //merging object else if (Input.GetMouseButtonDown(0) && heldObject != null) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, grabRange, ~(1 << 9))) { GameObject obj = hit.collider.gameObject; Carryable carryable = obj.GetComponent <Carryable>(); if (carryable != null) { MergeObject(obj); } } } }
public TwoInputBarrier(Texture2D[] Textures, Vector2 Location, PressButton input_1, PressButton input_2) : base(Textures, Location) { this.input_1 = input_1; this.input_2 = input_2; }
public void OnPressButton() { PressButton?.Invoke(); }
// Start is called before the first frame update void Start() { playerCScript = player.GetComponent <playerController>(); buttonPressor = gameObject.GetComponent <PressButton>(); }
void Start() { button = GetComponent <PressButton>(); image = GetComponent <Image>(); }