Exemplo n.º 1
0
    public void Init(FacebookGift gift)
    {
        Gift = gift;
        string    fileName  = Gift.FromId + ".png";
        Texture2D texture2D = PngTexture.LoadPNGAsTexture2D(fileName, 120, 120);

        if (texture2D != null)
        {
            Material material = new Material(m_friendImage.material);
            material.SetTexture("_MainTex", texture2D);
            m_friendImage.material = material;
        }
        if (PersistentSingleton <FacebookAPIService> .Instance.FBPlayers.ContainsKey(Gift.FromId))
        {
            m_friendName.text = PersistentSingleton <FacebookAPIService> .Instance.FBPlayers[Gift.FromId].Name;
        }
        (from g in Singleton <FacebookRunner> .Instance.GiftConsuming
         where g.FromId == Gift.FromId
         select g).Subscribe(delegate
        {
            m_button.SetActive(value: false);
        }).AddTo(this);
        (from g in Singleton <FacebookRunner> .Instance.GiftConsumeFailed
         where g.FromId == Gift.FromId
         select g).Subscribe(delegate
        {
            m_button.SetActive(value: true);
        }).AddTo(this);
    }
Exemplo n.º 2
0
 private void SaveProfilePictureToFile(Texture2D tex, string FBID)
 {
     try
     {
         PngTexture.SaveTexture2DAsPNG(tex, FBID + ".png");
         UnityEngine.Object.Destroy(tex);
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 3
0
    private void Start()
    {
        Image image = GetComponent <Image>();

        Singleton <FacebookRunner> .Instance.PlayerID.Subscribe(delegate(string id)
        {
            Texture2D value   = PngTexture.LoadPNGAsTexture2D(id + ".png", 120, 120);
            Material material = new Material(image.material);
            material.SetTexture("_MainTex", value);
            image.material = material;
        }).AddTo(this);
    }
Exemplo n.º 4
0
    protected void Start()
    {
        Image image = GetComponent <Image>();
        IReadOnlyReactiveProperty <string> property = GetProperty <string>();

        (from path in property.TakeUntilDestroy(this)
         select PngTexture.LoadPNGAsTexture2D(path, 120, 120)).Subscribe(delegate(Texture2D texture)
        {
            if (texture != null)
            {
                Material material = new Material(image.material);
                material.SetTexture("_MainTex", texture);
                image.material = material;
            }
        }).AddTo(this);
    }
Exemplo n.º 5
0
    public void Init(string id)
    {
        FriendId = id;
        string    fileName  = FriendId + ".png";
        Texture2D texture2D = PngTexture.LoadPNGAsTexture2D(fileName, 120, 120);

        if (texture2D != null)
        {
            Material material = new Material(m_friendImage.material);
            material.SetTexture("_MainTex", texture2D);
            m_friendImage.material = material;
        }
        if (PersistentSingleton <FacebookAPIService> .Instance.FBPlayers.ContainsKey(FriendId))
        {
            m_friendName.text = PersistentSingleton <FacebookAPIService> .Instance.FBPlayers[FriendId].Name;
        }
    }
Exemplo n.º 6
0
        private ShaderBlob BuildProgramInternal(ShaderCreationArguments args)
        {
            try
            {
                StaticLogger.Logger.DebugFormat("Starting Creation of {0}", args.ConvenientName());

                PngTexture texture = null;

                if (args.Type.UseTexture)
                {
                    texture = new PngTexture(args.TexturePath);
                    texture.Load();
                    texture.Create();
                    GlErrorLogger.Check();

                    // Do I even need this?
                    Gl.BindTexture(TextureTarget.Texture2d, texture.TextureName);
                    GlErrorLogger.Check();
                }

                var vertexSource = VertexShaderSource.VertexSourceLookup(args.Type.VertexFormat, args.Type.VertexShaderVersion);

                var _Program = new ShaderProgram(args.FragmentShaderSource, vertexSource, args.Type.Uniforms, args.Type.VertexFormat);
                GlErrorLogger.Check();

                _Program.Link();
                GlErrorLogger.Check();

                IVertexArray _VertexArray = BuildVertexArray(_Program.VertexLocations, args);

                GlErrorLogger.Check();

                return(new ShaderBlob()
                {
                    DisplayName = args.ConvenientName(),
                    CreationArguments = args,
                    TreatAsGood = true,
                    Program = _Program,
                    VertexArray = _VertexArray,
                    TextureName = !args.Type.UseTexture ? 0 : texture.TextureName,
                });
            }
            catch (Exception e)
            {
                StaticLogger.Logger.ErrorFormat("{1} - Shader Error {0}", args.SimpleName, e.ToString());

                if (BadShader == null)
                {
                    throw new InvalidOperationException("Could not build BadShader!");
                }

                return(new ShaderBlob()
                {
                    DisplayName = args.ConvenientName(),
                    CreationArguments = BadShader.CreationArguments,
                    TreatAsGood = false,
                    ErrorMessage = e.ToString(),
                    Program = BadShader.Program,
                    VertexArray = BadShader.VertexArray
                });
            }
        }