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>());*/ }
private void ChangeParent(string parentId) { if (parentId == null || parentId == "") { RemoveConnectionToParent(); Parent = null; Data.Parent = ""; transform.parent = ProjectManager.Instance.ActionPointsOrigin.transform; transform.localRotation = Quaternion.identity; return; } try { IActionPointParent actionPointParent = ProjectManager.Instance.GetActionPointParent(parentId); Parent = actionPointParent; Data.Parent = parentId; transform.parent = actionPointParent.GetTransform(); } catch (KeyNotFoundException ex) { Debug.LogError(ex); } }
public ActionPoint SpawnActionPoint(IO.Swagger.Model.ProjectActionPoint apData, IActionPointParent actionPointParent) { Debug.Assert(apData != null); GameObject AP; if (actionPointParent == null) { AP = Instantiate(ActionPointPrefab, ActionPointsOrigin.transform); } else { AP = Instantiate(ActionPointPrefab, actionPointParent.GetTransform()); } AP.transform.localScale = new Vector3(1f, 1f, 1f); ActionPoint actionPoint = AP.GetComponent <ActionPoint>(); actionPoint.InitAP(apData, APSize, actionPointParent); ActionPoints.Add(actionPoint.Data.Id, actionPoint); return(actionPoint); }