//Initialize the image given the serialized data public void Initialize(ImageDataSerializable data, int index) { CC_Selectable.CreateUIElement(gameObject); GetComponent <CC_Selectable>().myCanvas = index; this.data = data; StartCoroutine("Init"); }
/// <summary> /// Sets the current CCState and renders all displayed menus for this state /// </summary> void SetCCState(CCState newState, bool updateMenus) { //Begin state enable stuff //Begin state disable stuff if (newState != CCState.Selecting) { CC_Selectable.CancelSelect(); } CC_Menu CreationMenu = GetMenuByName("CreationMenu"); if (CreationMenu != null) { CreationMenu.SetEnabled(false); } CC_Menu windowManagerMenu = GetMenuByName("WindowManagerMenu"); if (windowManagerMenu != null) { windowManagerMenu.SetEnabled(false); } CC_UISelectionManager._instance.ChangeCCState(newState); backgroundHandler.Disable(); //Menu rendering if (updateMenus) { UpdateMenus(newState); } currState = newState; }
/// <summary> /// Update function too long, need to refactor into some smaller methods if/when we expand this script /// </summary> void Update() { UpdateSelected(); if (selected == null) { return; } if (Input.GetKeyDown(KeyCode.Escape)) { CC_Selectable.CancelSelect(); } if (isMouseover()) { if (Input.GetMouseButtonDown(0) && !isDragging) //Begin drag { RectTransformUtility.ScreenPointToLocalPointInRectangle(myCanvas.transform as RectTransform, Input.mousePosition, myCanvas.worldCamera, out lastMousePos); startDrag = lastMousePos; isDragging = true; } } if (isDragging && Input.GetMouseButtonUp(0)) { isDragging = false; Vector3 pos = Camera.main.WorldToScreenPoint(selected.transform.position); if (pos.x > Screen.width || pos.x < 0 || pos.y > Screen.height || pos.y < 0) { selected.transform.position = myCanvas.transform.TransformPoint(startDrag); } } if (isDragging) { ProcessMovement(); } }
void DeleteObject() { CC_Selectable.selectables.Remove(selected); Destroy(selected); CC_Selectable.CancelSelect(); }