UpdateAtlasesInfromation() публичный статический Метод

public static UpdateAtlasesInfromation ( ) : void
Результат void
    private void renderAtlasPreview()
    {
        string[] atlasesNames = TPAssetPostprocessor.atlasesNames;
        if (atlasesNames.Length == 0)
        {
            return;
        }

                #if UNITY_4_3
                #else
        EditorGUIUtility.LookLikeInspector();
                #endif

        GUILayout.BeginHorizontal(TexturePackerStyles.toolBarBoxStyle);
        GUILayout.FlexibleSpace();

        EditorGUI.BeginChangeCheck();

        if (atlasIndex == -1)
        {
            int    i = 0;
            string n = TPEditorData.selectedAtlasName;
            foreach (string atName in atlasesNames)
            {
                if (atName.Equals(n))
                {
                    atlasIndex = i;
                    break;
                }
                i++;
            }
            if (atlasIndex == -1)
            {
                atlasIndex = 0;
            }
        }

        atlasIndex = EditorGUI.Popup(
            new Rect(-10, 0, TexturePackerStyles.ATLAS_POPUP_WIDTH, 20),
            "",
            atlasIndex,
            atlasesNames, TexturePackerStyles.toolBarDropDwonStyle);
        if (EditorGUI.EndChangeCheck())
        {
            images.Clear();
            selection.Clear();
            TPEditorData.selectedAtlasName = atlasesNames [atlasIndex];
        }


        GUIStyle btnStyle = EditorStyles.toolbarButton;

        if (GUILayout.Button("Refresh", btnStyle))
        {
            TPackManager.clear();
            TPAssetPostprocessor.UpdateAtlasesInfromation();
        }


        if (GUILayout.Button(addButtonText, btnStyle))
        {
            addSelectedFrameToAnimation();
        }


        if (TPEditorData.isExtensionsEnabled)
        {
            btnStyle = TexturePackerStyles.toobarEnabledButton;
        }



        if (GUILayout.Button("Extensions", btnStyle))
        {
            TPEditorData.isExtensionsEnabled = !TPEditorData.isExtensionsEnabled;
        }



        search = GUILayout.TextField(search, GUI.skin.FindStyle("ToolbarSeachTextField"), TexturePackerStyles.FixedWidth(200f));


        if (GUILayout.Button("", GUI.skin.FindStyle("ToolbarSeachCancelButton")))
        {
            // Remove focus if cleared
            search = "";
            GUI.FocusControl(null);
        }


        GUILayout.EndHorizontal();



        scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(editor.position.width), GUILayout.Height(editor.position.height - 17f));

        GUILayout.Box("", GUIStyle.none, new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(_maxY) });
        _maxY = 0f;


        TextureNodeRenderer.calculateVars(editor.position.width - 10f);
        currentAtlas = getAtlas(atlasesNames[atlasIndex]);
        Rect r;
        int  index = 0;
        images.Clear();
        foreach (string name in currentAtlas.frameNames)
        {
            if (search != string.Empty)
            {
                if (!name.ToLower().Contains(search.ToLower()))
                {
                    continue;
                }
            }

            r = TextureNodeRenderer.RenderNode(index, currentAtlas, name);
            rememberImageRect(name, r);
            setNodeY(r.y + r.height * 1.5f);
            index++;
        }


        EditorGUILayout.EndScrollView();
    }
Пример #2
0
    //--------------------------------------
    // PUBLIC METHODS
    //--------------------------------------

    public override void OnInspectorGUI()
    {
        if (TPAssetPostprocessor.atlasesNames.Length == 0)
        {
            setMessage("No Atlas Found", MessageType.Error);
        }

        if (msgType != MessageType.Info)
        {
            EditorGUILayout.HelpBox(msg, msgType);
        }

        if (msgType != MessageType.Error)
        {
            string[] atlasesNames = TPAssetPostprocessor.atlasesNames;

            EditorGUI.BeginChangeCheck();
            helper.atlasID = EditorGUILayout.Popup("Atlas: ", helper.atlasID, atlasesNames);
            if (EditorGUI.EndChangeCheck())
            {
                helper.OnAtlasChange(atlasesNames[helper.atlasID]);
                if (helper.meshTexture.TextureAtlas == null)
                {
                    TPAssetPostprocessor.UpdateAtlasesInfromation();
                    return;
                }
                string[] textures = helper.meshTexture.TextureAtlas.frameNames;
                helper.textureID = 0;
                helper.OnTextureChange(textures[helper.textureID]);
            }



            if (helper.meshTexture != null)
            {
                TPAtlas atlas = helper.meshTexture.TextureAtlas;
                if (atlas != null)
                {
                    string[] textures = atlas.frameNames;

                    EditorGUI.BeginChangeCheck();
                    helper.textureID = EditorGUILayout.Popup("Texture: ", helper.textureID, textures);
                    if (EditorGUI.EndChangeCheck())
                    {
                        helper.OnTextureChange(textures[helper.textureID]);
                    }
                }
            }


            helper.replaceMaterial = EditorGUILayout.Toggle("Replace Material", helper.replaceMaterial);
        }

        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();


        GUILayout.FlexibleSpace();
        if (GUILayout.Button(new GUIContent("Update"), GUILayout.Width(100)))
        {
            TPAssetPostprocessor.UpdateAtlasesInfromation();


            if (helper.meshTexture != null)
            {
                TPAtlas atlas = helper.meshTexture.TextureAtlas;
                if (atlas != null)
                {
                    string[] atlasesNames = TPAssetPostprocessor.atlasesNames;
                    helper.OnAtlasChange(atlasesNames[helper.atlasID]);

                    string[] textures = helper.meshTexture.TextureAtlas.frameNames;
                    helper.OnTextureChange(textures[helper.textureID]);
                }
            }
        }



        EditorGUILayout.EndHorizontal();

        updateStatus();
    }