void OnTriggerExit(Collider collider) { //Detect fingers not touching the object anymore if (isHands == true) { //If object was active if (state == "Active") { for (int i = 0; i < collidingObjects.Length; i++) { // If colliding object is the sane trigger object if (collider.gameObject.GetInstanceID() == collidingObjects [i].GetInstanceID()) { state = null; isTouching = false; if (gameObject.name == "2DButton") { // Call Button UnPressed Function buttonPress bPScr = gameObject.GetComponent <buttonPress> (); bPScr.ButtonUnPressed(); } //PLACE ELSE IF CONDITION(S) HERE TO ADD MORE FEATURES FOR DIFFERENT TYPES OF BUTTONS } } } } }
void Update() { // If fingers are within hovering distance of the object if (intObj.isPrimaryHovered) { currDistance = intObj.primaryHoverDistance; // If your fingers are within the objects proximity and the button isn't already being held down if (intObj.primaryHoverDistance < proximityDistance && state == null) { state = "Active"; // Call Button Pressed Function buttonPress bPScr = gameObject.GetComponent <buttonPress>(); bPScr.ButtonPressed(); } // If fingers have left the objects proximity else if (state == "Active" && intObj.primaryHoverDistance > proximityDistance) { state = null; // Call Button UnPressed Function buttonPress bPScr = gameObject.GetComponent <buttonPress>(); bPScr.ButtonUnPressed(); } } }
////////////////////////////////////// 3D GRID ////////////////////////////////////// private void init3DGrid() { int totalCount = 0; // Init Array grid3DArr = new GameObject[(int)volumeAmount3D, (int)rowAmount3D, (int)columnAmount3D]; // Init Shape if (Enable3DGrid == true) { for (int z = 0; z < volumeAmount3D; z++) { for (int y = 0; y < rowAmount3D; y++) { for (int x = 0; x < columnAmount3D; x++) { Vector3 pos = new Vector3(x, z, y) * spacing3D + positionRelativeObject.transform.position; if (EnableDifferentPrefabs == false) { grid3DArr[z, y, x] = Instantiate(prefab, pos, prefab.transform.localRotation); // Init Default Prefab if (prefab.name == "button_PF") { interactButtonScript = grid3DArr[z, y, x].GetComponentInChildren <InteractionButton>(); buttonPressScript = grid3DArr[z, y, x].GetComponentInChildren <buttonPress>(); interactButtonScript.OnPress.AddListener(buttonPressScript.ButtonPressed); interactButtonScript.OnUnpress.AddListener(buttonPressScript.ButtonUnPressed); } } else { grid3DArr[z, y, x] = Instantiate(prefabs3G[totalCount], pos, prefabs3G[totalCount].transform.localRotation); if (scale3G[totalCount] != 0) { grid3DArr[z, y, x].transform.localScale = new Vector3(scale3G[totalCount], scale3G[totalCount], scale3G[totalCount]); } // Init Prefab if (prefabs3G[totalCount].name == "button_PF") { interactButtonScript = grid3DArr[z, y, x].GetComponentInChildren <InteractionButton>(); buttonPressScript = grid3DArr[z, y, x].GetComponentInChildren <buttonPress>(); interactButtonScript.OnPress.AddListener(buttonPressScript.ButtonPressed); interactButtonScript.OnUnpress.AddListener(buttonPressScript.ButtonUnPressed); } totalCount++; } } } } } }
////////////////////////////////////// CIRCLE ////////////////////////////////////// private void initCircle() { // Init Array circleArr = new GameObject[numberOfObjects]; // Init Shape for (int i = 0; i < numberOfObjects; i++) { // Math for circle shape float angle = i * Mathf.PI * 2 / numberOfObjects; Vector3 pos = new Vector3(Mathf.Cos(angle), 0, Mathf.Sin(angle)) * radius + positionRelativeObject.transform.position; if (EnableDifferentPrefabs == false) { circleArr[i] = Instantiate(prefab, pos, prefab.transform.localRotation); // Init Default Prefab if (prefab.name == "button_PF") { interactButtonScript = circleArr[i].GetComponentInChildren <InteractionButton>(); buttonPressScript = circleArr[i].GetComponentInChildren <buttonPress>(); interactButtonScript.OnPress.AddListener(buttonPressScript.ButtonPressed); interactButtonScript.OnUnpress.AddListener(buttonPressScript.ButtonUnPressed); } } else { circleArr[i] = Instantiate(prefabsC[i], pos, prefabsC[i].transform.localRotation); if (scaleC[i] != 0) { circleArr[i].transform.localScale = new Vector3(scaleC[i], scaleC[i], scaleC[i]); } //Init Prefab if (prefabsC[i].name == "button_PF") { interactButtonScript = circleArr[i].GetComponentInChildren <InteractionButton>(); buttonPressScript = circleArr[i].GetComponentInChildren <buttonPress>(); interactButtonScript.OnPress.AddListener(buttonPressScript.ButtonPressed); interactButtonScript.OnUnpress.AddListener(buttonPressScript.ButtonUnPressed); } } } }
public void OnDrop(PointerEventData data) { containerImage.color = normalColor; press = FindObjectOfType(typeof(buttonPress)) as buttonPress; press.passos(data.pointerEnter.name, data.pointerDrag.name, data.pointerEnter.tag); //Debug.Log(data.pointerEnter.tag); if (receivingImage == null) { return; } Sprite dropSprite = GetDropSprite(data); if (dropSprite != null) { receivingImage.overrideSprite = dropSprite; } }
void Start() { limparConteudo = FindObjectOfType(typeof(trashContent)) as trashContent; press = FindObjectOfType(typeof(buttonPress)) as buttonPress; }
////////////////////////////////////// TRIANGLE ////////////////////////////////////// private void initTriangle() { int totalCount = 0; // Init Array triangleRArr = new GameObject[(int)rowAmountTriangle + 1, (int)rowAmountTriangle + 1]; triangleLArr = new GameObject[(int)rowAmountTriangle + 1, (int)rowAmountTriangle + 1]; // Init Shape if (EnableTriangle == true) { for (int y = (int)rowAmountTriangle; y >= 0; y--) { for (int x = (int)rowAmountTriangle - y; x > 0; x--) { // Right half of triangle Vector3 pos = new Vector3(x, 0, y) * spacingTriangle + positionRelativeObject.transform.position; if (EnableDifferentPrefabs == false) { triangleRArr[y, x] = Instantiate(prefab, pos, prefab.transform.localRotation); // Init Default Prefab if (prefab.name == "button_PF") { interactButtonScript = triangleRArr[y, x].GetComponentInChildren <InteractionButton>(); buttonPressScript = triangleRArr[y, x].GetComponentInChildren <buttonPress>(); interactButtonScript.OnPress.AddListener(buttonPressScript.ButtonPressed); interactButtonScript.OnUnpress.AddListener(buttonPressScript.ButtonUnPressed); } } else { triangleRArr[y, x] = Instantiate(prefabsT[totalCount], pos, prefabsT[totalCount].transform.localRotation); if (scaleT[totalCount] != 0) { triangleRArr[y, x].transform.localScale = new Vector3(scaleT[totalCount], scaleT[totalCount], scaleT[totalCount]); } // Init Prefab if (prefabsT[totalCount].name == "button_PF") { interactButtonScript = triangleRArr[y, x].GetComponentInChildren <InteractionButton>(); buttonPressScript = triangleRArr[y, x].GetComponentInChildren <buttonPress>(); interactButtonScript.OnPress.AddListener(buttonPressScript.ButtonPressed); interactButtonScript.OnUnpress.AddListener(buttonPressScript.ButtonUnPressed); } totalCount++; } // Left half of triangle if (x > 1) { pos = new Vector3(-x + 2, 0, y) * spacingTriangle + positionRelativeObject.transform.position; if (EnableDifferentPrefabs == false) { triangleLArr[y, x] = Instantiate(prefab, pos, prefab.transform.localRotation); // Init Default Prefab if (prefab.name == "button_PF") { interactButtonScript = triangleLArr[y, x].GetComponentInChildren <InteractionButton>(); buttonPressScript = triangleLArr[y, x].GetComponentInChildren <buttonPress>(); interactButtonScript.OnPress.AddListener(buttonPressScript.ButtonPressed); interactButtonScript.OnUnpress.AddListener(buttonPressScript.ButtonUnPressed); } } else { triangleLArr[y, x] = Instantiate(prefabsT[totalCount], pos, prefabsT[totalCount].transform.localRotation); if (scaleT[totalCount] != 0) { triangleLArr[y, x].transform.localScale = new Vector3(scaleT[totalCount], scaleT[totalCount], scaleT[totalCount]); } // Init Prefab if (prefabsT[totalCount].name == "button_PF") { interactButtonScript = triangleLArr[y, x].GetComponentInChildren <InteractionButton>(); buttonPressScript = triangleLArr[y, x].GetComponentInChildren <buttonPress>(); interactButtonScript.OnPress.AddListener(buttonPressScript.ButtonPressed); interactButtonScript.OnUnpress.AddListener(buttonPressScript.ButtonUnPressed); } totalCount++; } } } } } }