Giter Site home page Giter Site logo

gimchuang / unityphototool Goto Github PK

View Code? Open in Web Editor NEW
17.0 3.0 2.0 2.74 MB

Scripts for taking screenshots with countdown animation and chroma keying in Unity. ๐Ÿณโ€๐ŸŒˆ

C# 94.81% HLSL 2.35% ShaderLab 2.85%
unity screenshot photos chroma-key countdown

unityphototool's Introduction

UnityPhotoTool

Features

There are 3 sample scenes in this project:

  • Test_PhotoTool takes a screenshot and display it on a GUI Raw Image.
  • Test_PhotoAnim demonstrates how to set up simple count down and flash light animation.
  • Test_Keying applies chroma keying and color adjustment onto textures.

๐ŸŒŸ While the above scenes demonstrate how I use the scripts individually, UnityPhotoBooth is a complete photo booth game using all these scripts together. Please check it out if you need it.

How to Use

PhotoTool.cs

Sample_PhotoTool

Settings in the Inspector

  • Set startX, startY, width, and height for the region you want to take screenshots with. You can view the region you've set by checking Debug On GUI.

Scripting Reference

  • Init() initializes a Texture2D for screenshots with startX, startY, width, and height. There's also an overload function Init(int _startX, int _startY, int _width, int _height) for overriding the settings.
  • TakePhoto() takes a screenshot and apply it to tex2d_photo.
  • OnPhotoTaken(tex2d_photo) is called after the screenshot is taken.

PhotoAnimController.cs

Sample_PhotoAnimController

Settings in the Inspector

  • Drag some Transform components into the countDownElements array. These GameObjects will be used in the countdown animation, which is driven by a DOTween Sequence.
  • Type in duration_countDown (in seconds). It's the duration of each countDownElements's scaling animation.
  • Assign a UI Image to Img_shot. It'll be used in a "flash" animation driven by DOTween, too. duration_shot is the duration of the animation.
  • (Optional) You can also assign an AudioSource to audio_shot and it will be played with the flash animation.

Scripting Reference

  • Init() MUST be called to initialize the DOTween tweeners/sequences.
  • PlayCountDownAnim() plays the countdown animation. OnCountDownFinish() is called when the animation finishes.
  • PlayShotAnim() plays the flash light animation (along with the audio_shot sound effect if it's assigned). OnShotFinish() is called when the animation finishes.

KeyingColorPickers.cs, KeyingSliders.cs, and KeyingToggle.cs

Sample_Keying

These scripts are used to control values on materials using ProcAmp shader.

  • Assign a material using Klak/Video/ProcAmp shader to keyingMaterial
  • Type in propertyName eg. _KEYING, _Brightness. They are internally used by some functions such as Material.SetFloat and PlayerPref.SetFloat.
  • (Optional) If btn_resetDefault is assigned, value of the color picker, sliders, and toggle will be set to default when btn_resetDefault is pressed.
  • (Optional) There is a Panel-Keying Prefab inside gm_PhotoTool/Prefab/Panel-Keying. It's a UI Panel which already contains a color picker, a toggle, and sliders. You can put it onto a UI Canvas and then set up values followng steps above.

Notes

This project uses Git submodule gm_PhotoTool. If you want to clone this reposiory, you need to call

git clone --recurse-submodules <URL>

License

MIT

Acknowledgement

This project uses ProcAmp by Keijiro and HSV Color Picker by judah4 to achieve chroma keying. Also uses PlayerPrefsX by Eric Haines to save colors with PlayerPrefs! ๐Ÿ™‡โ€โ™€๏ธ

unityphototool's People

Contributors

gimchuang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

jonike arcadeindy

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.