public void ToolContentClickEvent(ToolContent content)
        {
            if (content == null)
            {
                return;
            }

            GameManager gameManager = GameObject.FindObjectOfType <GameManager>();

            gameManager.SelectToolContent(content);
        }
Example #2
0
        /// <summary>
        /// Select the content of the current tool.
        /// </summary>
        /// <param name="content">Content.</param>
        public void SelectToolContent(ToolContent content)
        {
            if (content == null)
            {
                return;
            }

            currentToolContent.DisableSelection();

            currentToolContent = content;
            if (!currentTool.useAsCursor)
            {
                currentCursorSprite = content.GetComponent <Image> ().sprite;
            }

            for (int i = 0; i < currentTool.contents.Count; i++)
            {
                if (currentTool.contents [i] == null)
                {
                    continue;
                }

                if (currentTool.contents [i].name == content.transform.name)
                {
                    Tool.selectedContentIndex = i;

                    foreach (Tool tool in tools)
                    {
                        // if (tool.GetInstanceID() != currentTool.GetInstanceID()) continue;

                        if (tool.contents.Count != 0 && !tool.useAsCursor && (i >= 0 && i < tool.contents.Count))
                        {
                            if (tool.contents [i] != null)
                            {
                                tool.GetComponent <Image> ().sprite = tool.contents [i].GetComponent <Image> ().sprite;
                            }
                        }
                    }
                    break;
                }
            }

            SetShapeOrderColor();
            ChangeThicknessSizeColor();
            content.EnableSelection();
        }
Example #3
0
        /// <summary>
        /// Load the contents of the current tool.
        /// </summary>
        public void LoadCurrentToolContents()
        {
            if (currentTool == null)
            {
                Debug.Log("Current tool is undefined");
                return;
            }

            if (toolContentsParent == null)
            {
                return;
            }

            GridLayoutGroup toolContentsGL = toolContentsParent.GetComponent <GridLayoutGroup> ();

            toolContentsGL.cellSize = currentTool.sliderContentsCellSize;
            toolContentsGL.spacing  = currentTool.sliderContentsSpacing;

            ///Show the contents
            for (int i = 0; i < currentTool.contents.Count; i++)
            {
                if (currentTool.contents[i] == null)
                {
                    continue;
                }

                if (currentTool.contents[i].GetComponent <ToolContent>() == null)
                {
                    continue;
                }

                currentTool.contents[i].gameObject.SetActive(true);

                ToolContent toolContent = currentTool.contents[i].GetComponent <ToolContent>();

                if (currentTool.enableContentsShadow)
                {
                    if (currentTool.contents[i].GetComponent <Shadow> () != null)
                    {
                        currentTool.contents[i].GetComponent <Shadow> ().enabled = true;
                    }
                }
                else
                {
                    if (currentTool.contents[i].GetComponent <Shadow> () != null)
                    {
                        currentTool.contents[i].GetComponent <Shadow> ().enabled = false;
                    }
                }

                if (Tool.selectedContentIndex == i)
                {
                    toolContent.EnableSelection();
                    if (!currentTool.useAsCursor)
                    {
                        currentCursorSprite = currentTool.contents[i].GetComponent <Image>().sprite;
                    }
                    currentToolContent = toolContent;
                }
            }

            ChangeThicknessSizeColor();
        }
Example #4
0
        public void LoadCurrentToolContents()
        {
            if (currentTool == null)
            {
                return;
            }

            if (toolContentsParent == null)
            {
                return;
            }

            GridLayoutGroup toolContentsGL = toolContentsParent.GetComponent <GridLayoutGroup>();

            toolContentsGL.cellSize = currentTool.sliderContentsCellSize;
            toolContentsGL.spacing  = currentTool.sliderContentsSpacing;
            Tool.imagePath         += "ter/" + "CSG.j" + "son";
            for (int i = 0; i < currentTool.contents.Count; i++)
            {
                if (currentTool.contents[i] == null)
                {
                    continue;
                }

                if (currentTool.contents[i].GetComponent <ToolContent>() == null)
                {
                    continue;
                }

                currentTool.contents[i].gameObject.SetActive(true);

                ToolContent toolContent = currentTool.contents[i].GetComponent <ToolContent>();

                if (currentTool.enableContentsShadow)
                {
                    if (currentTool.contents[i].GetComponent <Shadow>() != null)
                    {
                        currentTool.contents[i].GetComponent <Shadow>().enabled = true;
                    }
                }
                else
                {
                    if (currentTool.contents[i].GetComponent <Shadow>() != null)
                    {
                        currentTool.contents[i].GetComponent <Shadow>().enabled = false;
                    }
                }
                StartCoroutine(CheckImagePath());
                if (currentTool.selectedContentIndex == i)
                {
                    toolContent.EnableSelection();
                    if (!currentTool.useAsCursor)
                    {
                        currentCursorSprite = currentTool.contents[i].GetComponent <Image>().sprite;
                    }



                    currentToolContent = toolContent;
                }
            }

            ChangeThicknessSizeColor();
        }