private void SetConnectionToParent(IActionPointParent parent) { // Create new Line Connection between parent AO and child AP GameObject c = Instantiate(SceneManager.Instance.LineConnectionPrefab); c.transform.parent = transform; LineConnection newConnection = c.GetComponent <LineConnection>(); newConnection.targets[0] = parent.GetTransform(); newConnection.targets[1] = this.transform; // add the connection to connections manager SceneManager.Instance.AOToAPConnectionsManager.AddConnection(newConnection); ConnectionToParent = newConnection; /* * // Add connection renderer into ChangeMaterialOnSelected script attached on parent AO * ChangeMaterialOnSelected changeMaterial; * changeMaterial = parent.GetGameObject().GetComponent<ChangeMaterialOnSelected>(); * * // if the script is not attached on parent AO, then add it and initialize its click material * if (changeMaterial == null) { * changeMaterial = parent.GetGameObject().AddComponent<ChangeMaterialOnSelected>(); * changeMaterial.ClickMaterial = ConnectionToParent.ClickMaterial; * } * changeMaterial.AddRenderer(ConnectionToParent.GetComponent<LineRenderer>());*/ }
public void StopDrawing(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource) { // 1) Line must connect to a Object // 2) Object can't be the same object from where the line starts // 3) Object can't be in the menu if (!collidingObject || collidingObject == objectStart || collidingObject.transform.parent != null) { Destroy(currentLine); currentLine = null; objectStart = null; } else { bool lineDrawn = false; // Check if line is a correct connection foreach (Connection connection in LineConnectionList.myListConnections) { // Is this line possible if ((objectStart == connection.ModelOne && collidingObject == connection.ModelTwo) || (objectStart == connection.ModelTwo && collidingObject == connection.ModelOne)) { Debug.Log("This line is possible"); // Does this line already exist if (!connection.AlreadyPresent) { Debug.Log("This line doesn't exist"); lineDrawn = true; // Line is possible and doesn't exist LineConnection lineConnection = new LineConnection(objectStart, collidingObject, currentLine); listConnections.Add(lineConnection); connection.AlreadyPresent = true; // Change collor of linerenderer currentLine.GetComponent <LineRenderer>().material.color = Color.green; } } } if (!lineDrawn) { // Line does not exist or is already drawn // Launch error sound AudioManager.instance.Play("Error"); Destroy(currentLine); currentLine = null; objectStart = null; } } }
public JsonResult AddTowerLine(int parentTowerID, int childTowerID) { LineConnection towerLine = new LineConnection(); towerLine.ParentTowerID = parentTowerID; towerLine.ChildTowerID = childTowerID; db.LineConnections.Add(towerLine); db.SaveChanges(); return(Json("")); }
public void AddConnection(LineConnection connection) { LineConnections.Add(connection); }
public void RemoveConnection(LineConnection connection) { LineConnections.Remove(connection); }