Exemplo n.º 1
0
        /// <inheritdoc />
        public override void CollectObjectProperty(Object obj)
        {
            var t    = (RectTransform)obj;
            var name = SLUILuaBuilderSyntax.CollectVar(t);

            // activeState
            if (!t.gameObject.activeSelf)
            {
                String.AppendLine($"{name}:SetActive(false)");
            }

            // transform
            if (Math.Abs(t.pivot.x - 0.5f) > float.Epsilon || Math.Abs(t.pivot.y - 0.5f) > float.Epsilon)
            {
                String.AppendLine($"{name}.rectTransform.pivot = {SLUILuaBuilderSyntax.CollectVector2(t.pivot)}");
            }

            String.AppendLine($"{name}.rectTransform.anchoredPosition = {SLUILuaBuilderSyntax.CollectVector2(t.anchoredPosition)}");
            String.AppendLine($"{name}.rectTransform.sizeDelta = {SLUILuaBuilderSyntax.CollectVector2(t.sizeDelta)}");

            if (t.localRotation != Quaternion.identity)
            {
                String.AppendLine($"{name}.rectTransform.localRotation = {SLUILuaBuilderSyntax.CollectQuaternion(t.localRotation)}");
            }

            if (t.localScale != Vector3.one)
            {
                String.AppendLine($"{name}.rectTransform.localScale = {SLUILuaBuilderSyntax.CollectVector2(t.localScale)}");
            }
        }
Exemplo n.º 2
0
        /// <inheritdoc />
        public override void CollectObjectDefinitionExtras(Object obj)
        {
            var t    = (RectTransform)obj;
            var name = SLUILuaBuilderSyntax.CollectVar(t);

            // NOTE: Parent and anchor need to be applied at the definition stage, to not lost the original rectTransform's state.
            // parent
            if (t.parent.parent != null) // only if not a child of root
            {
                var parentName = SLUILuaBuilderSyntax.CollectVar((RectTransform)t.parent);
                String.AppendLine($"{name}.rectTransform:SetParent({parentName}.rectTransform)");
            }

            // anchor
            var anchor = SLUIRectTransform.GetAnchor(t);

            if (anchor != SLUIRectAnchorName.Unknown)
            {
                String.AppendLine($"{name}.rectTransform.anchor = '{SLUIRectTransform.GetAnchor(t)}'");
            }
            else
            {
                String.AppendLine($"{name}.rectTransform.anchorMin = {SLUILuaBuilderSyntax.CollectVector2(t.anchorMin)}");
                String.AppendLine($"{name}.rectTransform.anchorMax = {SLUILuaBuilderSyntax.CollectVector2(t.anchorMax)}");
            }
        }
Exemplo n.º 3
0
        /// <inheritdoc />
        public override void CollectObjectDefinition(Object obj)
        {
            var t    = (RectTransform)obj;
            var name = SLUILuaBuilderSyntax.CollectVar(t);

            String.AppendLine($"local {name} = core:Create('{t.name}')");
        }
        public override void CollectObjectDefinition(Object obj)
        {
            var i          = (JEMInterfaceFadeAnimation)obj;
            var name       = SLUILuaBuilderSyntax.CollectVar(i);
            var parentName = SLUILuaBuilderSyntax.CollectVar(i.GetComponent <RectTransform>());

            String.AppendLine($"local {name} = {parentName}:AddComponent('{nameof(SLUIJEMFadeAnimation)}')");
        }
        public override void CollectObjectDefinition(Object obj)
        {
            var t          = (Text)obj;
            var parentName = SLUILuaBuilderSyntax.CollectVar(t.GetComponent <RectTransform>());
            var name       = SLUILuaBuilderSyntax.CollectVar(t);

            String.AppendLine($"local {name} = {parentName}:AddComponent('Text')");
        }
Exemplo n.º 6
0
        public override void CollectObjectDefinition(Object obj)
        {
            var i          = (Image)obj;
            var name       = SLUILuaBuilderSyntax.CollectVar(i);
            var parentName = SLUILuaBuilderSyntax.CollectVar(i.rectTransform);

            String.AppendLine($"local {name} = {parentName}:AddComponent('Image')");
        }
        public override void CollectObjectProperty(Object obj)
        {
            var i    = (JEMInterfaceFadeAnimation)obj;
            var name = SLUILuaBuilderSyntax.CollectVar(i);

            if (i.AnimationSpeed != 10f)
            {
                String.AppendLine($"{name}.animationSpeed = {i.AnimationSpeed.ToString(CultureInfo.InvariantCulture)}");
            }
            if (i.AnimationEnterScale != 0.9f)
            {
                String.AppendLine($"{name}.animationEnterScale = {i.AnimationEnterScale.ToString(CultureInfo.InvariantCulture)}");
            }
            if (i.AnimationEnterScale != 1.1f)
            {
                String.AppendLine($"{name}.animationExitScale = {i.AnimationExitScale.ToString(CultureInfo.InvariantCulture)}");
            }
            if (i.AnimationMode != JEMFadeAnimationMode.UsingLocalScale)
            {
                String.AppendLine($"{name}:SetAnimationMode('{i.AnimationMode.ToString()}')");
            }
        }
Exemplo n.º 8
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}");
            }
        }