예제 #1
0
    override protected void OnInit()
    {
        mTexture = mWidget as UITexture;
        if (!string.IsNullOrEmpty(mTexture.MaterialPath) && mTexture.MaterialPath.StartsWith("Textures/UITexture/"))
        {
            mTexture.MaterialPath = mTexture.MaterialPath.Replace('\\', '/');
            string[] splits = mTexture.MaterialPath.Split('/');
            if (splits != null && splits.Length == 4)
            {
                pathSelection    = splits[2];
                textureSelection = splits[3];

                if (mTexture.material == null)
                {
                    Shader s = Shader.Find("Unlit/Transparent Colored");
                    mTexture.material = new Material(s);
                }
                Resources.UnloadAsset(mTexture.material.mainTexture);
                mTexture.material.mainTexture = mTexture.AysnLoadTex(mTexture.MaterialPath) as Texture;
            }
        }

        FolderList = NGUIEditorTools.GetSonDirectoryNameWithoutPath(UITextureParentPath);
        InsertOneAtHead <string>(ref FolderList, "None");
        TextureList = NGUIEditorTools.GetFilesInDirectoryWithoutPathAndExtension(UITextureParentPath + pathSelection, ".png");
        InsertOneAtHead <string>(ref TextureList, "None");
    }