A new PlayMaker custom action, GetARCameraTexture, has been added.
GetARCameraTexture allows you to capture images or video information from your smartphone’s camera onto a texture in real time.
To use the GetARCameraTexture feature, the STYLY plugin and PlayMaker must be installed as prerequisites.
Sample scene (Every Frame)
https://gallery.styly.cc/scene/92c29701-0d1b-4ccb-b3ca-64b4efc634ad
What are Custom Actions
PlayMaker comes with a variety of features for creating game logic and interactions.
Each of these features is called an action.
In STYLY, multiple actions are implemented independently to expand the expressiveness of VR / AR scenes.
These “independently implemented actions” are called custom actions.
Custom actions are available when you download the STYLY Plugin for Unity (PlayMaker is required to use custom actions).
Also, see the article below for a list of custom actions available for STYLY.
Operating Platforms
GetARCameraTexture” works only in Mobile environment
.
Platforms |
Operation |
VR | ×Mobile |
Web | ×Mobile |
Mobile | 0 |
Sample Scene Creation
In this article we will use GetARCameraTexture to create an asset that will continue to transfer the smartphone video to the Cube texture.
Create Material
Create a RenderTexture: project window > right click on Assets and select Create→RenderTexture.
Change the Resolution of RenderTexture (where Size is located) to 1024. This time we set it to 1024, but this resolution can be arbitrary.
Create a material and select Unlit→Texture from the shader in the inspector.
Drag and drop the RenderTexture you just created at None(Texture).
Add a Cube to the scene and apply the material created here. this Cube will be used to project the camera information.
To make it easier to see the texture of the Cube in the AR scene, add a rotation animation. add PlayMaker FSM to the Cube and add rotate from the Action Browser.
Change the X,Y,Z values to 0.1.
Creating the Main System
Next, create the main FSM.
Right click in the hierarchy and add a GameObject, then add the FSM in the PlayMaker editor.
You may rename the GameObject for clarity.
Add an action to the added FSM.
Select state 1, search for Get AR in the Action Browser and add Get AR Camera Texture.
Create a new variable “RenderTexture” by clicking on the two-line icon in RenderTexture.
Create a new variable called “error” in the Error Event section as well.
Check the Every Frame check box.
If you check the Every Frame checkbox, the camera information will be repeated every frame, so you will naturally get the camera image in real time.
Right click on state 1 and add the error you just created from Add Transiton.
Once this is done, create a new State and connect it to State 1.
Enter Cube in the New Variable of Variables in the FSM, change Variable Type to GameObject and add it with Add.
Once added, checkmark Input for both Cube and Render Texture.
Then the FSM inspector will show a list of Inputs and you can specify the Cube and RenderTexture you created earlier.
Once this is done, delete the hierarchy PlayMakerGUI, create a new GameObject to contain the Cube and FSM and put them together.
Then drag and drop the GameObjec into Assets to Prefab it and upload it STYLY
Uploading to STYLY
Let’s actually upload the scene to STYLY and use it.
This time we will upload the Unity scene directly to STYLY.
account
This article is an overview of GetARCameraTexture, and detailed explanations of specific examples of its use can be found in the following articles.