示例#1
0
    void OnDrawImageSettings(int _id)
    {
        m_spriteFrameTimeScroll = GUILayout.BeginScrollView(m_spriteFrameTimeScroll);
        bool dirty = false;

        bool before = m_currentImageConfig.m_importAsSprite;

        m_currentImageConfig.m_importAsSprite = GUILayout.Toggle(before, "Import as sprite");
        if (m_currentImageConfig.m_importAsSprite != before)
        {
            dirty = true;
        }

        if (m_currentImageConfig.m_importAsSprite)
        {
            bool beforeB = m_currentImageConfig.m_importAsBSprite;
            m_currentImageConfig.m_importAsBSprite = GUILayout.Toggle(beforeB, "Import as B-sprite");
            if (m_currentImageConfig.m_importAsBSprite != beforeB)
            {
                dirty = true;
            }

            GUILayout.Label("Sprite w=" + m_currentImageConfig.GetSpriteWidth() + ", h=" + m_currentImageConfig.GetSpriteHeight());

            GUILayout.BeginHorizontal();
            GUILayout.Label("Num frames");
            string beforeString = m_currentFramesString;
            string newstring    = GUILayout.TextField(beforeString);
            GUILayout.EndHorizontal();
            m_currentFramesString = newstring;

            if (beforeString.CompareTo(newstring) != 0)
            {
                int newint;
                if (int.TryParse(newstring, out newint))
                {
                    m_currentImageConfig.SetNumFrames(newint);
                    dirty = true;
                }
            }

            GUILayout.Label("");
            GUILayout.Label("Frame times");

            int i;
            for (i = 0; i < m_currentImageConfig.GetNumFrames(); i++)
            {
                int time = m_currentImageConfig.GetFrameTime(i);

                GUILayout.BeginHorizontal();
                GUILayout.Label("Frame " + i + ":");
                if (m_currentFrameTimesString.ContainsKey(i) == false)
                {
                    m_currentFrameTimesString[i] = m_currentImageConfig.GetFrameTime(i).ToString();
                }
                beforeString = m_currentFrameTimesString[i];
                string newString = GUILayout.TextField(beforeString);;
                m_currentFrameTimesString[i] = newString;
                if (beforeString != newString)
                {
                    int newValue;
                    if (int.TryParse(newString, out newValue))
                    {
                        m_currentImageConfig.SetFrameTime(i, newValue);
                        dirty = true;
                    }
                }
                GUILayout.EndHorizontal();
            }

            GUILayout.Label("Hotspot");
            m_currentImageConfig.m_hotSpotX = EditorGUILayout.IntField("X:", m_currentImageConfig.m_hotSpotX);
            m_currentImageConfig.m_hotSpotY = EditorGUILayout.IntField("Y:", m_currentImageConfig.m_hotSpotY);
        }

        if (dirty)
        {
            m_currentImageConfig.Save();
        }
        GUI.DragWindow();

        GUILayout.EndScrollView();
    }