public ConnectionsRegisterer(ConnectionsTracker connTracker, InputCanvas inputCanvas, LineDrawer drawer, ResultNode resultNode) { this.connTracker = connTracker; this.inputCanvas = inputCanvas; this.drawer = drawer; this.resultNode = resultNode; }
public void Setup(Camera cameraIn, ConnectionsTracker trackerIn, float globalScaleIn = 0.2f) { this.tracker = trackerIn; this.myCamera = cameraIn; this.globalScale = globalScaleIn; if (this.buttonPrefab == null) { this.buttonPrefab = Resources.Load("Prefabs/NonCanvases/TMP/TMPButton", typeof(GameObject)) as GameObject; this.inputFieldPrefab = Resources.Load("Prefabs/NonCanvases/TMP/TMPInputField", typeof(GameObject)) as GameObject; this.dropDownPrefab = Resources.Load("Prefabs/NonCanvases/TMP/TMPDropdown", typeof(GameObject)) as GameObject; this.textPrefab = Resources.Load("Prefabs/NonCanvases/TMP/TMPText", typeof(GameObject)) as GameObject; } this.canvasGO = new GameObject("MainCanvas"); this.canvas = canvasGO.AddComponent <Canvas>(); this.canvas.worldCamera = this.myCamera; var rectT = canvas.GetComponent <RectTransform>(); this.canvasGO.AddComponent <CanvasScaler>(); this.canvasGO.AddComponent <GraphicRaycaster>(); rectT.sizeDelta = new Vector2(this.canvasHalfX * 2, this.canvasHalfY * 2); GenerateBasicElements generator = new GenerateBasicElements(this); drawActionButtonMapping = new DrawActionButtonMapping(Color.white, generator, this); drawSavedCubesRow = new DrawSavedCubesRow(Color.white, generator, this); drawSavingCube = new DrawSavingCube(Color.white, generator, this); drawVariableSelection = new DrawVariableSelection(Color.white, generator, this); drawTypesSelection = new DrawTypesSelection(Color.white, generator, this); drawConstantSelection = new DrawConstantSelection(Color.white, generator, this); Vector2 tl = new Vector2(-this.canvasHalfX, this.canvasHalfY); float interBlockOffset = this.xOffset * 4; drawSavedCubesRow.GenerateUI(tl, out Vector2 offset1); tl.x += offset1.x + interBlockOffset; drawSavingCube.GenerateUI(tl, out Vector2 offset2); tl.x += offset2.x + interBlockOffset; drawActionButtonMapping.GenerateUI(tl, out Vector2 offset3); tl.y += -offset3.y - interBlockOffset; drawVariableSelection.GenerateUI(tl, out Vector2 offset4); tl.y += -offset4.y - interBlockOffset; drawTypesSelection.GenerateUI(tl, out Vector2 offset5); tl.y += -offset5.y - interBlockOffset; drawConstantSelection.GenerateUI(tl, out Vector2 offset6); tl.y += -offset6.y - interBlockOffset; }
public ResultCanvas(GameObject prefab, Camera cam, ConnectionsTracker connTracker, Transform parent) { this.canvas = GameObject.Instantiate(prefab); this.canvas.transform.SetParent(parent); this.canvas.GetComponent <Canvas>().worldCamera = cam; this.ParseElements(); this.doneButton = this.canvas.transform.Find("DoneButton").GetComponent <Button>(); this.doneButton.onClick.AddListener(this.OnClickDone); this.resultText = this.canvas.transform.Find("ResultText").GetComponent <TMP_Text>(); canvas.transform.position = Vector3.zero; this.connTracker = connTracker; }
private void Start() { if (transperantMat == null) { this.transperantMat = Resources.Load("Materials/transperantMat", typeof(Material)) as Material; this.inputPanelPrefab = Resources.Load("Prefabs/WorldSpaceCanvases/ConstantCanvasPrefab", typeof(GameObject)) as GameObject; this.resultAndVariablesPanelPrefab = Resources.Load("Prefabs/WorldSpaceCanvases/ResultCanvasPrefab", typeof(GameObject)) as GameObject; this.worldSpaceTextPrefab = Resources.Load("Prefabs/WorldSpaceCanvases/WorldSpaceTextPrefab", typeof(GameObject)) as GameObject; } this.spellcraftParent = new GameObject("Spellcraft Parent"); this.persistantParent = new GameObject("Persistant Parent"); this.connTracker = new ConnectionsTracker(this); //Rotation of class nodes implementation that wull be replaced this.rotatorGO = new GameObject("Rotator"); this.rotatorGO.transform.SetParent(this.spellcraftParent.transform); //... //Parented this.drawer = new LineDrawer(this); this.drawer.DrawBox(SpellcraftConstants.HalfSize, SpellcraftConstants.Thickness, SpellcraftConstants.BoxCenter); this.myCamera = GameObject.Find("Camera").GetComponent <Camera>(); this.camHandling = this.myCamera.gameObject.AddComponent <SpellcraftCam>(); this.myCamera2 = GameObject.Find("Camera2").GetComponent <Camera>(); this.camHandling2 = this.myCamera2.gameObject.AddComponent <SpellMenuDragCam>(); this.myCamera2.enabled = false; this.procUI = this.GetComponent <SpellcraftProcUI>(); this.procUI.Setup(this.myCamera2, this.connTracker, 0.035f); // Procedural SpellCraftUI float YY = 1000; this.procUI.SetCanvasPosition(new Vector3(0, YY, -1000)); this.procUIAnchor = new GameObject("ProcUIAnchor"); this.procUIAnchor.transform.position = new Vector3(0, YY, -2000); GameObject center = new GameObject("Center"); center.transform.SetParent(this.spellcraftParent.transform); this.camHandling.Setup(center); this.classVisualisation = new ClassVisualisation(this); this.resultCanvas = new ResultCanvas(this.resultAndVariablesPanelPrefab, this.myCamera, this.connTracker, this.persistantParent.transform); this.resultCanvas.SetPosition(new Vector3(0, 0, -25)); this.resultCanvas.SetScale(new Vector3(0.02f, 0.02f, 0.02f)); this.resultCanvas.Hide(); this.inputCanvas = new InputCanvas(this.myCamera, this.inputPanelPrefab, this.persistantParent.transform); //Extract that somewhere this.resultGO = GameObject.CreatePrimitive(PrimitiveType.Sphere); this.resultGO.name = "Result GO"; this.resultGO.transform.SetParent(this.persistantParent.transform); this.resultGO.transform.position = new Vector3(0, -15, 0); this.resultNode = this.resultGO.AddComponent <ResultNode>(); //... this.connRegisterer = new ConnectionsRegisterer(this.connTracker, this.inputCanvas, this.drawer, this.resultNode); this.infoCanvas = new InfoCanvas(this.worldSpaceTextPrefab, this.myCamera, this.spellcraftParent.transform); this.levels = new Setups(this.resultCanvas, this.inputCanvas, this.connRegisterer, this, this.resultNode, this.classVisualisation); this.resultCanvasVantigePoint = new GameObject("VantigePoint"); this.resultCanvasVantigePoint.transform.position = new Vector3(0, 0, -30); this.resultCanvasVantigePoint.transform.SetParent(this.spellcraftParent.transform); this.dynamicSetup = new DynamicSetup(this.classVisualisation, this, this.resultCanvas, this.inputCanvas); //this.levels.JustTwoAddMethod(true); if (LoadLevel) { this.levels.LineDestroyer(false); } else { this.connTracker.RegisterBundle(null); } this.spellcraftParent.transform.position = this.position; this.persistantParent.transform.position = this.position; }