Example #1
0
        public void export()
        {
            if (level == 1)
            {
                // ExportConstStringBuilder.AppendLine(transform.name.Substring(1) + ":{");
                // ExportConstStringBuilder.AppendLine("gameObject : UnityEngine.GameObject,");

                var name = transform.name.StartsWith("-$") ? transform.name.Substring(2) : transform.name.Substring(1);
                ConstStringBuilder.AppendLine("self." + name + "= {");
                ConstStringBuilder.AppendLine(GameObjectTypeString + string.Format("gameObject = transform:Find(\"{0}\").gameObject,", GetFullPath(transform)));
                if (transform.name.StartsWith("-$"))
                {
                    exportItem(transform, level);
                }
            }
            else if (level > 1)
            {
                // ExportConstStringBuilder.AppendLine(transform.name.Substring(1) + ":{");
                // ExportConstStringBuilder.AppendLine("gameObject : UnityEngine.GameObject,");


                var name = transform.name.StartsWith("-$") ? transform.name.Substring(2) : transform.name.Substring(1);
                ConstStringBuilder.AppendLine(name + "= {");
                ConstStringBuilder.AppendLine(GameObjectTypeString + string.Format("gameObject = transform:Find(\"{0}\").gameObject,", GetFullPath(transform)));
                if (transform.name.StartsWith("-$"))
                {
                    exportItem(transform, level);
                }
            }

            foreach (var item in Items)
            {
                exportItem(item, level);
            }

            foreach (var child in Childs)
            {
                child.export();
            }

            if (level > 0)
            {
                // ExportConstStringBuilder.AppendLine("}");
                ConstStringBuilder.AppendLine("}");
                if (level > 1)
                {
                    ConstStringBuilder.AppendLine(",");
                }
            }
            // print(outStruct.ExportConstStringBuilder + "\n" + outStruct.ConstStringBuilder);
        }
Example #2
0
        //private void exportSpineUI(Spine.Unity.SkeletonGraphic skeletonGraphic, bool inside = false)
        //{
        //    var name = skeletonGraphic.name.Substring(skeletonGraphic.name.IndexOf('$') + 1);

        //    var typeString = "";

        //    var ExportFormatString = inside ? "{0}: Spine.Unity.SkeletonGraphic," : " {0}: Spine.Unity.SkeletonGraphic;";
        //    ExportConstStringBuilder.AppendLine(string.Format(ExportFormatString, name));

        //    var FormatString = inside ?
        //     "{0} = transform:Find(\"{1}\"):GetComponent(\"SkeletonGraphic\")," :
        //     "self.{0} = transform:Find(\"{1}\"):GetComponent(\"SkeletonGraphic\");";
        //    ConstStringBuilder.AppendLine(string.Format(typeString + FormatString, name, GetFullPath(skeletonGraphic.transform)));
        //}

        private void exportGameObject(Transform item, bool inside = false)
        {
            var name = item.name.Substring(item.name.IndexOf('$') + 1);

            var typeString = "";

            var ExportFormatString = inside ? "{0}: UnityEngine.Transform," : " {0}: UnityEngine.Transform;";

            ExportConstStringBuilder.AppendLine(string.Format(ExportFormatString, name));

            var FormatString = inside ?
                               "{0} = transform:Find(\"{1}\")," :
                               "self.{0} = transform:Find(\"{1}\");";

            ConstStringBuilder.AppendLine(string.Format(typeString + FormatString, name, GetFullPath(item.transform)));
        }
Example #3
0
        private void exportDropdown(Dropdown dropdown, bool inside = false)
        {
            var name = dropdown.name.Substring(dropdown.name.IndexOf('$') + 1);

            var typeString = "";

            var ExportFormatString = inside ? "{0}: UnityEngine.UI.Dropdown," : " {0}: UnityEngine.UI.Dropdown;";

            ExportConstStringBuilder.AppendLine(string.Format(ExportFormatString, name));

            var FormatString = inside ?
                               "{0} = transform:Find(\"{1}\"):GetComponent(\"Dropdown\")," :
                               "self.{0} = transform:Find(\"{1}\"):GetComponent(\"Dropdown\");";

            ConstStringBuilder.AppendLine(string.Format(typeString + FormatString, name, GetFullPath(dropdown.transform)));
        }
Example #4
0
        private void exportInput(InputField input, bool inside = false)
        {
            var name = input.name.Substring(input.name.IndexOf('$') + 1);

            var typeString = "";

            var ExportFormatString = inside ? "{0}: UnityEngine.UI.InputField," : " {0}: UnityEngine.UI.InputField;";

            ExportConstStringBuilder.AppendLine(string.Format(ExportFormatString, name));

            var FormatString = inside ?
                               "{0} = transform:Find(\"{1}\"):GetComponent(\"InputField\")," :
                               "self.{0} = transform:Find(\"{1}\"):GetComponent(\"InputField\");";

            ConstStringBuilder.AppendLine(string.Format(typeString + FormatString, name, GetFullPath(input.transform)));
        }
Example #5
0
        private void exportToggle(Toggle toggle, bool inside = false)
        {
            var name = toggle.name.Substring(toggle.name.IndexOf('$') + 1);

            var typeString = "";

            var ExportFormatString = inside ? "{0}: UnityEngine.UI.Toggle," : " {0}: UnityEngine.UI.Toggle;";

            ExportConstStringBuilder.AppendLine(string.Format(ExportFormatString, name));

            var FormatString = inside ?
                               "{0} = transform:Find(\"{1}\"):GetComponent(\"Toggle\")," :
                               "self.{0} = transform:Find(\"{1}\"):GetComponent(\"Toggle\");";

            ConstStringBuilder.AppendLine(string.Format(typeString + FormatString, name, GetFullPath(toggle.transform)));
        }
Example #6
0
        private void exportAnimator(Animator image, bool inside = false)
        {
            var name = "Animator_" + image.name.Substring(image.name.IndexOf('$') + 1);

            var typeString = "";

            var ExportFormatString = inside ? "{0}: UnityEngine.UI.Image," : " {0}: UnityEngine.UI.Image;";

            ExportConstStringBuilder.AppendLine(string.Format(ExportFormatString, name));

            var FormatString = inside ?
                               "{0} = transform:Find(\"{1}\"):GetComponent(\"Animator\")," :
                               "self.{0} = transform:Find(\"{1}\"):GetComponent(\"Animator\");";

            ConstStringBuilder.AppendLine(string.Format(typeString + FormatString, name, GetFullPath(image.transform)));
        }
Example #7
0
        // private void exportGameObject(GameObject gameobject, bool inside = false){
        //     var name = gameobject.name.Substring(1);

        //     var ExportFormatString = inside ? "{0}: UnityEngine.GameObject," : " {0}: UnityEngine.GameObject;";
        //     ExportConstStringBuilder.AppendLine(string.Format(ExportFormatString, name));

        //     var FormatString = inside ?
        //      "{0} = transform:Find(\"{1}\").gameObject," :
        //      "self.{0} = transform:Find(\"{1}\").gameObject;";
        //     ConstStringBuilder.AppendLine(string.Format(FormatString, name, GetFullPath(gameobject.transform)));
        // }


        private void exportReatTransform(RectTransform rect, bool inside = false)
        {
            var name = rect.name.Substring(rect.name.IndexOf('$') + 1);

            var ExportFormatString = inside ? "{0}: UnityEngine.UI.RectTransform," : " {0}: UnityEngine.UI.RectTransform;";

            ExportConstStringBuilder.AppendLine(string.Format(ExportFormatString, name));

            var typeString = "";

            var FormatString = inside ?
                               "{0} = transform:Find(\"{1}\"):GetComponent(\"RectTransform\")," :
                               "self.{0} = transform:Find(\"{1}\"):GetComponent(\"RectTransform\");";

            ConstStringBuilder.AppendLine(string.Format(typeString + FormatString, name, GetFullPath(rect.transform)));
        }
Example #8
0
        private void exportSlider(Slider slider, bool inside = false)
        {
            var name = slider.name.Substring(slider.name.IndexOf('$') + 1);

            var typeString = "";

            var ExportFormatString = inside ? "{0}: UnityEngine.UI.Slider," : " {0}: UnityEngine.UI.Slider;";

            ExportConstStringBuilder.AppendLine(string.Format(ExportFormatString, name));

            var FormatString = inside ?
                               "{0} = self.transform:Find(\"{1}\"):GetComponent(\"Slider\")," :
                               "self.{0} = self.transform:Find(\"{1}\"):GetComponent(\"Slider\");";

            ConstStringBuilder.AppendLine(string.Format(typeString + FormatString, name, GetFullPath(slider.transform)));
        }
Example #9
0
        private void exportText(Text text, bool inside = false)
        {
            // export var Text_time: UnityEngine.UI.Text;
            // Text_time = transform:Find("Texts/Text_time"):GetComponent("Button");
            var name = "Text_" + text.name.Substring(text.name.IndexOf('$') + 1);

            var typeString = "";

            var ExportFormatString = inside ? "{0}: UnityEngine.UI.Text," : " {0}: UnityEngine.UI.Text;";

            ExportConstStringBuilder.AppendLine(string.Format(ExportFormatString, name));

            var FormatString = inside ?
                               "{0} = transform:Find(\"{1}\"):GetComponent(\"Text\")," :
                               "self.{0} = transform:Find(\"{1}\"):GetComponent(\"Text\");";

            ConstStringBuilder.AppendLine(string.Format(typeString + FormatString, name, GetFullPath(text.transform)));
        }
Example #10
0
        private void exportButton(Button button, bool inside = false)
        {
            var name = button.name.Substring(button.name.IndexOf('$') + 1);
            // if (button.name[0] == '-')
            // Debug.Log(button.name + " " + button.name.IndexOf('$') + " " + button.name.Substring(button.name.IndexOf('$') + 1));

            var typeString = "";

            var ExportFormatString = inside ? "{0}: UnityEngine.UI.Button," : " {0}: UnityEngine.UI.Button;";

            ExportConstStringBuilder.AppendLine(string.Format(ExportFormatString, name));

            var FormatString = inside ?
                               "{0} = transform:Find(\"{1}\"):GetComponent(\"Button\")," :
                               "self.{0} = transform:Find(\"{1}\"):GetComponent(\"Button\");";

            ConstStringBuilder.AppendLine(string.Format(typeString + FormatString, name, GetFullPath(button.transform)));
        }