Exemple #1
0
        public override void CollectObjectProperty(Object obj)
        {
            var i    = (Image)obj;
            var name = SLUILuaBuilderSyntax.CollectVar(i);

            string sprite = null;

            if (i.sprite != null)
            {
                sprite = SLUIResourcesConverter.CollectResourceName(i.sprite);
                SLUIResourcesConverter.WriteSprite($"{Parent.ResourcesPathFull}\\{sprite}", i.sprite);
                sprite = $"{Parent.ResourcesPath}\\{sprite}".Replace("\\", "//");
            }

            String.AppendLine($"{name}.imageType = '{i.type.ToString()}'");
            if (i.color != Color.white)
            {
                String.AppendLine($"{name}.color = {SLUILuaBuilderSyntax.CollectColor(i.color)}");
            }
            if (!i.raycastTarget)
            {
                String.AppendLine($"{name}.raycastTarget = false");
            }
            if (i.preserveAspect)
            {
                String.AppendLine($"{name}.preserveAspect = true");
            }
            if (!i.fillCenter)
            {
                String.AppendLine($"{name}.fillCenter = false");
            }
            if (!string.IsNullOrEmpty(sprite))
            {
                //if (File.Exists(sprite))
                String.AppendLine($"{name}.sprite = '{sprite}'");
                //else Debug.LogError($"Sprite generation failed. Target file not exist. ({sprite})");
            }
        }
        public override void CollectObjectProperty(Object obj)
        {
            var t    = (Text)obj;
            var name = SLUILuaBuilderSyntax.CollectVar(t);

            String.AppendLine($"{name}.text = {'"'}{t.text}{'"'}");
            if (t.fontSize != 14)
            {
                String.AppendLine($"{name}.fontSize = {t.fontSize}");
            }
            if (t.fontStyle != FontStyle.Normal)
            {
                String.AppendLine($"{name}.fontStyle = '{t.fontStyle.ToString()}'");
            }
            if (t.alignment != TextAnchor.UpperLeft)
            {
                String.AppendLine($"{name}.alignment = '{t.alignment.ToString()}'");
            }
            if (t.resizeTextForBestFit)
            {
                String.AppendLine($"{name}.resizeTextForBestFit = true");
            }
            if (t.resizeTextMinSize != 10)
            {
                String.AppendLine($"{name}.resizeTextMinSize = {t.resizeTextMinSize}");
            }
            if (t.resizeTextMaxSize != 40)
            {
                String.AppendLine($"{name}.resizeTextMaxSize = {t.resizeTextMaxSize}");
            }
            String.AppendLine($"{name}.color = {SLUILuaBuilderSyntax.CollectColor(t.color)}");
            if (!t.raycastTarget)
            {
                String.AppendLine($"{name}.raycastTarget = false");
            }
        }
        public override void CollectObjectProperty(Object obj)
        {
            var b    = (Button)obj;
            var name = SLUILuaBuilderSyntax.CollectVar(b);

            String.AppendLine(
                $"{name}.targetGraphic = {(b.targetGraphic == null ? "nil" : SLUILuaBuilderSyntax.CollectVar(b.image))}");
            if (!b.interactable)
            {
                String.AppendLine($"{name}.interactable = false");
            }
            String.AppendLine($"{name}.normalColor = {SLUILuaBuilderSyntax.CollectColor(b.colors.normalColor)}");
            String.AppendLine(
                $"{name}.highlightedColor = {SLUILuaBuilderSyntax.CollectColor(b.colors.highlightedColor)}");
            String.AppendLine($"{name}.pressedColor = {SLUILuaBuilderSyntax.CollectColor(b.colors.pressedColor)}");
            String.AppendLine($"{name}.selectedColor = {SLUILuaBuilderSyntax.CollectColor(b.colors.selectedColor)}");
            String.AppendLine($"{name}.disabledColor = {SLUILuaBuilderSyntax.CollectColor(b.colors.disabledColor)}");

            if (b.onClick.GetPersistentEventCount() != 0)
            {
                String.AppendLine(SLUILuaBuilderSyntax.CollectEvent(b, b.onClick, b.GetComponent <SLUIUnityEventHelper>(), out var eventName));
                String.AppendLine($"{name}.onClickUnityEvent = {eventName}");
            }
        }