Beispiel #1
0
    public void onSelectChange(AtlasListView view, SpriteAtlasData atlas, SpriteAtlasData.SpriteInfo sprite, Sprite origin)
    {
        if (m_ReferenceListView == null)
        {
            return;
        }

        // m_ReferenceListView = new ReferenceListView();
        // m_ReferenceListView.Reload();

        if (origin != null)
        {
            var r = SpriteReferenceInfo.Instance.FindSpriteInfo(origin);
            m_ReferenceListView.refs = (r != null) ? r.objInfo : null;
        }
        else if (sprite != null)
        {
            var r = SpriteReferenceInfo.Instance.FindSpriteInfo(sprite.packed);
            m_ReferenceListView.refs = (r != null) ? r.objInfo : null;
        }
        else
        {
            m_ReferenceListView.refs = null;
        }

        m_ReferenceListView.ExpandAll();
    }
Beispiel #2
0
    void OnGUI()
    {
        if (Application.isPlaying)
        {
            GUILayout.Label("playing");
            SpriteReferenceInfoDetector.watchEditorChange = false;
            return;
        }

        GUILayout.BeginHorizontal();
        bool scanAtlas      = GUILayout.Button("Scan Atlas", GUILayout.Width(100));
        bool scanGameObject = GUILayout.Button("Scan Reference", GUILayout.Width(100));
        bool updateAtlas    = GUILayout.Button("Update Atlas", GUILayout.Width(100));

        SpriteReferenceInfoDetector.watchEditorChange = GUILayout.Toggle(SpriteReferenceInfoDetector.watchEditorChange, "watching");
        scan_scene = GUILayout.Toggle(scan_scene, "scan scene");
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();

        Rect atlasRect = new Rect(0, 30, position.width / 2 - 5, position.height);

        if (m_AtlasListTree == null)
        {
            m_AtlasListTree = new AtlasListView(this);
            ReloadTreeView();
        }
        m_AtlasListTree.OnGUI(atlasRect);

        if (m_ReferenceListView == null)
        {
            m_ReferenceListView = new ReferenceListView();
            m_ReferenceListView.Reload();
        }

        Rect refRect = new Rect(position.width / 2 + 5, 30, position.width / 2 - 5, position.height);

        m_ReferenceListView.OnGUI(refRect);

        if (scanAtlas)
        {
            ScanSpriteAtlas();
        }

        if (scanGameObject)
        {
            SpriteReferenceInfo.Instance.Scan(scan_scene);
        }

        if (updateAtlas)
        {
            SpriteAtlasData            atlas  = null;
            SpriteAtlasData.SpriteInfo sprite = null;
            Sprite origin = null;
            if (m_AtlasListTree.GetSelectAtlas(out atlas, out sprite, out origin))
            {
                TexturePacker.Pack(atlas.sprites, atlas.texture);
                atlas.Scan();
            }
        }
    }