void Update() { if (_material != null) { // The target color for the Interaction object will be determined by various simple state checks. Color targetColor = defaultColor; if (_intObj.isHovered && useHover) { float glow = _intObj.closestHoveringControllerDistance.Map(0F, 0.2F, 1F, 0.0F); targetColor = Color.Lerp(defaultColor, hoverColor, glow); } // On press if (_intObj is InteractionButton && (_intObj as InteractionButton).isPressed) { if (!_isPushed) { _isPushed = true; switch (ButtonChoice) { case ButtonType.SpawnLink: GameObject newLink = RobotLink.SpawnLink(); GameObject Linktool = SpawnTransformTool(newLink); LinkIDCount += 1; newLink.GetComponent <RobotLink>().SelfID = LinkIDCount; newLink.transform.localScale = spawnScale; newLink.transform.position = spawnLocation; break; case ButtonType.SpawnJoint: GameObject newJoint = ObjectJoint.SpawnJoint(); GameObject Jointtool = SpawnTransformTool(newJoint); JointIDCount += 1; newJoint.GetComponent <ObjectJoint>().SelfID = JointIDCount; newJoint.transform.localScale = spawnScale; newJoint.transform.position = spawnLocation; break; case ButtonType.Attach: AttachObjects(); break; case ButtonType.Delete: DeleteObject(); break; } targetColor = pressedColor; } } // For the button cooldown if (_intObj is InteractionButton && !(_intObj as InteractionButton).isPressed) { _isPushed = false; } // Lerp actual material color to the target color. _material.color = Color.Lerp(_material.color, targetColor, 30F * Time.deltaTime); } }
private void SpawnJoint() { GameObject newJoint = ObjectJoint.SpawnJoint(); newJoint.AddComponent <ClickerTest>(); }