void Update() { foreach (KeyCode keyPressed in slotsKeyValue.Keys) { if (Input.GetKeyDown(keyPressed)) { key = keyPressed; OnSelectionEvent?.Invoke(slotsKeyValue[keyPressed]); } } if (Input.GetMouseButtonDown(0)) { //If object to spawn is available if (OnPlacementEvent.Invoke(slotsKeyValue[key])) { InstantiateObj(ps); //SPAWNA OGGETTO GameObject spawn = OnSpawningEvent.Invoke(slotsKeyValue[key]); InstantiateObj(spawn); } else { OnResetEvent?.Invoke(slotsKeyValue[key]); Cursor.SetCursor(/*defaultCursor.texture*/ null, Vector2.zero, CursorMode.ForceSoftware); } } }
public void RemoveSelection() { if (Selected == null) { return; } var molecule = Selected.Molecule; for (int i = 0, n = molecule.Count; i < n; i++) { var elementGO = molecule.GetElement(i).gameObject; Destroy(elementGO); } OnSelectionEvent.Invoke(null); }
public void OnTap(Vector3 touchPosition) { var ray = Camera.ScreenPointToRay(touchPosition); if (Selected != null) { Selected.SetSelected(false); } var prev = Selected; Selected = Physics.Raycast(ray, out var hit, Distance, Mask) ? hit.collider.GetComponent <Element>() : null; if (Selected != null) { Selected.SetSelected(true); } if (prev != Selected) { OnSelectionEvent.Invoke(Selected); } }
/// <summary> /// Set Selected on this Actor. /// </summary> /// <param name="value"></param> public void SetSelected(bool value) { Selected = value; OnSelectionEvent?.Invoke(value); }