What Shader HotSwap is
The Shader HotSwap allows you to hot-swap shaders running on a device.
- Shader Debugging – Sometimes shaders don’t work properly on devices. You can save a great amount of time by using Shader HotSwap when you repeatedly edit your shaders and test them on the devices.
- Performance Tuning – Turn on/off some features of your shaders without rebuilding the binary. You can see the change of frame time immediately.
Setup for Player
Just drop the ShaderHotSwapServer prefab in your first scene. The prefab has a small web server in it. And it communicates with the Unity Editor parts through the network.
That’s it. You can build your binary now.
Setup for Unity Editor
Assign shaders that you want to hot-swap.
If your PC and your mobile device are in the same network, just type the IP address of your mobile device and the port, and click the Swap Shaders button in the HotSwap window. The default port is 8090. Or you can change the default port in the ShaderHotSwapServer prefab.
If your Android device is connected to your PC through a USB cable, you can make use of ADB’s port forwarding feature. The following command adds a port forwarding setting. If it is succeeded, type ‘localhost:8090’ and click the Swap Shaders button in the HotSwap window. See Unity document’s ADB profiling section for details.
adb forward tcp:8090 tcp:8090
If everything is ok, you can now hot-swap your shaders. Edit your shaders and click the Swap Shader button.
Net Error:Cannot connect to the destination host
First, make sure your game is running with Shader HotSwap enabled. Next, you need to check if you can connect to your mobile device from your PC. Type
http://[IP Address]:[Port] in the address bar of your web browser on the PC. Replace the
[IP Address] and
[Port] with the values you typed in the HotSwap window. If everything is OK, you can see the message
Welcome to Shader HotSwap!.
If you are trying to connect your device through WIFI, make sure that your PC and your device are in the same network.
Or, you are trying to connect your Android device through USB/ADB, make sure of your ADB forwarding settings. type below in the command line.
adb forward --list
It will show you the current forward settings like below.
1515fa33f65c3282 tcp:8090 tcp:8090