Example #1
0
        void PlatformField(Rect itemPosition, DefineSymbolPlatformData platform, GUIStyle backStyle)
        {
            var togglePosition = new Rect(
                itemPosition.xMax - 32f,
                itemPosition.y + (itemPosition.height - 16f) * 0.5f,
                16f, 16f);

            var ev = Event.current;

            switch (ev.type)
            {
            case EventType.Repaint:
                backStyle.Draw(itemPosition, false, false, platform == m_current, false);

                var icon = itemPosition;
                icon.x    += 2;
                icon.y    += (icon.height - kTargetIconSize) * 0.5f;
                icon.width = icon.height = kTargetIconSize;
                GUI.DrawTexture(icon, platform.icon);

                m_platformStyle.Draw(itemPosition,
                                     new GUIContent(platform.name),
                                     focusedWindow == this, false, platform == m_current, false);
                break;

            case EventType.MouseDown:
                if (itemPosition.Contains(ev.mousePosition) && ev.button == 0)
                {
                    // トグルにかぶってたら処理しない = ev.Use()しちゃうとトグルが反応しなくなる
                    if (!togglePosition.Contains(ev.mousePosition))
                    {
                        m_current = platform;
                        ev.Use();
                    }
                }
                break;
            }

            var isTarget = m_data.targets.Contains(platform.target);

            if (GUI.Toggle(togglePosition, isTarget, GUIContent.none) != isTarget)
            {
                if (!isTarget)
                {
                    m_data.targets.Add(platform.target);
                    m_data.targets.Sort((x, y) => Array.FindIndex(m_platforms, i => i.target == x).CompareTo(Array.FindIndex(m_platforms, i => i.target == y)));
                }
                else
                {
                    m_data.targets.Remove(platform.target);
                }
            }
        }
Example #2
0
        void DrawBuildTargetIcon(Rect itemPosition, DefineSymbolPlatformData platform)
        {
            var icon = itemPosition;

            icon.x    += 2;
            icon.y    += (icon.height - kTargetIconSize) * 0.5f;
            icon.width = icon.height = kTargetIconSize;
            GUI.DrawTexture(icon, platform.icon);

            itemPosition.x      = icon.xMax + 4f;
            itemPosition.y     += (itemPosition.height - 16f) * 0.5f;
            itemPosition.height = 16f;
            GUI.Label(itemPosition, platform.target.ToString());
        }
Example #3
0
        //------------------------------------------------------
        // unity system function
        //------------------------------------------------------

        void OnEnable()
        {
            s_instane = this;

            titleContent = new GUIContent("DefineSymbol Editor");
            minSize      = new Vector2(570f, 380f);

            m_platforms = Array.ConvertAll(kTargets, i => new DefineSymbolPlatformData(i));
            m_current   = Array.Find(m_platforms, i => i.target == EditorUserBuildSettings.selectedBuildTargetGroup) ?? m_platforms[0];

            m_data    = DefineSymbolData.Load();
            m_context = new DefineSymbolContext(m_data.context);

            InitGUI();
            UpdatePresetLabels();
            SetSymbolMode();
        }