Advertisement
Guest User

Untitled

a guest
Jan 16th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. 1.Start a new project in Lens Studio
  2.  
  3. 2.In the Objects pannel select `add New` -> `billboard`
  4.  
  5. https://imgur.com/ScMwh9Q
  6. This creates an orthogonal camera and a 2D sprite that is set to cover the screen by default.
  7.  
  8. 3. Uncheck the tick box next to `Sprite` in the Inspector pannel, so that it is initially hidden.
  9. https://imgur.com/znBMkN6
  10.  
  11. 4.In the Resources pannel select `add New` -> `script`.
  12. https://imgur.com/8Ai7Fzv
  13.  
  14. 5. Select this script and in the inspector pannel change its contents to:
  15.  
  16. // -----JS CODE-----
  17.  
  18. //Add inputs which can be acccessed using script.inputName
  19.  
  20. //@input Component.Camera camera
  21. //@input Asset.Texture deviceCameraTexture
  22. //@input Component.SpriteVisual spriteVisual
  23.  
  24. //Takes a screenshot which we can access with textureCopy
  25. var textureCopy = script.deviceCameraTexture.copyFrame();
  26.  
  27. //Applies textureCopy to the sprite
  28. script.spriteVisual.mainPass.baseTex = textureCopy;
  29.  
  30. //Shows the sprites visual that was hidden in step 3
  31. script.spriteVisual.enabled = true;
  32.  
  33. https://imgur.com/QBZN6zU
  34.  
  35. 6. Select the 2D sprite added in step 2 and add a script component in the Inspector pannel.
  36. https://imgur.com/9UUgLwp
  37.  
  38. 7. Select `Tapped` in the drop down next to the newly added script so it runs when the user taps.
  39.  
  40. 8. Finally set the inputs you added in script (using @input)
  41. camera -> Orthographic Camera
  42. device camera texture -> Device Camera Texture
  43. Sprite Visual -> 2D sprite
  44.  
  45. https://imgur.com/GuWoiKK
  46.  
  47. Credit to u/maddogmular for the script since I have only slightly altered theirs.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement