void Load()
            {
                string[] data = File.ReadAllLines("GameData/Sigma/Replacements/MenuButtons/Debug/" + name + ".txt");

                try { transform.localPosition = ConfigNode.ParseVector3(data[1]); } catch { }
                try { transform.localRotation = Quaternion.Euler(ConfigNode.ParseVector3(data[4])); } catch { }
                try { transform.localScale = ConfigNode.ParseVector3(data[7]); } catch { }

                TextMeshPro mesh = GetComponent <TextMeshPro>();

                if (mesh != null)
                {
                    if (!string.IsNullOrEmpty(data[10]))
                    {
                        mesh.text = data[10];
                    }

                    TextProButton3D button = GetComponent <TextProButton3D>();

                    if (button == null)
                    {
                        try { mesh.color = ConfigNode.ParseColor(data[13]); } catch { }
                    }
                    else
                    {
                        try { button.normalColor = ConfigNode.ParseColor(data[13]); } catch { }
                        try { button.hoverColor = ConfigNode.ParseColor(data[16]); } catch { }
                        try { button.downColor = ConfigNode.ParseColor(data[19]); } catch { }
                    }
                }
            }
            void Save()
            {
                string[] data = new string[20];

                data[0] = "position";
                data[1] = Print(transform.localPosition);
                data[2] = "";
                data[3] = "rotation";
                data[4] = Print(transform.localRotation.eulerAngles);
                data[5] = "";
                data[6] = "scale";
                data[7] = Print(transform.localScale);

                TextMeshPro mesh = GetComponent <TextMeshPro>();

                if (mesh != null)
                {
                    data[8]  = "";
                    data[9]  = "text";
                    data[10] = mesh.text;
                    data[11] = "";
                    data[12] = "normalColor";
                    data[13] = Print(mesh.color);

                    TextProButton3D button = GetComponent <TextProButton3D>();

                    if (button != null)
                    {
                        data[13] = "";
                        data[13] = Print(button.normalColor);
                        data[14] = "";
                        data[15] = "hoverColor";
                        data[16] = Print(button.hoverColor);
                        data[17] = "";
                        data[18] = "downColor";
                        data[19] = Print(button.downColor);
                    }
                }

                File.WriteAllLines("GameData/Sigma/Replacements/MenuButtons/Debug/" + name + ".txt", data);
            }
            void ApplyTo()
            {
                Debug.Log("CustomMenuButton.ApplyTo", "object = " + name);

                transform.localPosition = position ?? transform.localPosition;
                transform.localRotation = rotation ?? transform.localRotation;
                transform.localScale    = scale ?? transform.localScale;

                TextMeshPro mesh = GetComponent <TextMeshPro>();

                Debug.Log("CustomMenuButton.ApplyTo", "mesh = " + mesh);

                if (mesh != null)
                {
                    if (!string.IsNullOrEmpty(text))
                    {
                        mesh.text = text;
                    }

                    TextProButton3D button = GetComponent <TextProButton3D>();
                    Debug.Log("CustomMenuButton.ApplyTo", "button = " + button);

                    if (button == null)
                    {
                        mesh.color = normalColor ?? mesh.color;
                    }
                    else
                    {
                        button.normalColor = normalColor ?? button.normalColor;
                        button.hoverColor  = hoverColor ?? button.hoverColor;
                        button.downColor   = downColor ?? button.downColor;

                        button.OnMouseExit();
                    }
                }
            }
예제 #4
0
 void Awake()
 {
     button = GetComponent <TextProButton3D>();
 }