Skip to content

Library for using the GiphyAPI in Unity to get and play random Gifs as MP4s

License

Notifications You must be signed in to change notification settings

coryleach/UnityGiphy

Repository files navigation

Gameframe.Giphy 👋

Codacy Badge GitHub release (latest by date including pre-releases) openupm license

twitter

This package contains a simple implementation of the Giphy API required to display random Gif images in Unity as MP4 videos.
This package does not provide a means to display a gif directly but does provide urls to gif version of the images.
Instead this package uses the mp4 links provided by giphy's api to display the gifs as movies

Quick Package Install

Using UnityPackageManager (for Unity 2019.3 or later)

Open the package manager window (menu: Window > Package Manager)
Select "Add package from git URL...", fill in the pop-up with the following link:
https://github.com/coryleach/UnityGiphy.git#2.0.0

Using UnityPackageManager (for Unity 2019.1 or later)

Find the manifest.json file in the Packages folder of your project and edit it to look like this:

{
  "dependencies": {
    "com.gameframe.giphy": "https://github.com/coryleach/UnityGiphy.git#2.0.0",
    ...
  },
}

Using OpenUPM

The package is available on the openupm registry. It's recommended to install it via openupm-cli.

openupm add com.gameframe.giphy

Usage

To get started you must create an app and get an API key on the https://developers.giphy.com/ website.
Create your GiphyConfig asset by using the Create->Gameframe->Giphy->Config in the project tab's Create menu.
Once you have created your GiphyConfig asset you should add your API key to it that you got from the Giphy developer website.
You can use your config asset and the demo scene included in this package to get started.

This library provides a GiphyRawImageController component that can be used with RawImage and VideoPlayer for displaying random giphy images in your UI but example API code is also shown below.

//You can make basic queries to Giphy using the API provide in the GiphyQuery class.
//As of this writing only Random and Search endpoints are supported.
//For more info on the query results please see the following documentation
// https://developers.giphy.com/docs/api/endpoint

//Example code that loads a random image and plays it as a video
public async void ShowRandomImage()
{
  //Get a single random result
  var randomResult = await GiphyQuery.Random(apiKey,searchKeywords);

  //Display the random image result using Unity's video player
  videoPlayer.source = VideoSource.url;
  videoPlayer.url = randomResult.result.data.images.original_mp4.mp4;
  videoPlayer.Play();
}

Author

👤 Cory Leach

Show your support

Give a ⭐️ if this project helped you!


This README was generated with ❤️ by Gameframe.Packages

About

Library for using the GiphyAPI in Unity to get and play random Gifs as MP4s

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages