In Place Retexturing

A guide to player created transfer textures on to an existing in-game object, rather than instantiating a new one.

Prerequisites

  • You should've completed the Get Started guide and already have the SDK setup.

  • You should have the same model you uploaded to Player Make available in your Unity project to transfer textures on to.

Step 1: Place your target object into a scene

Assuming you've got the SDK working locally, your first step should now be to bring your target object into the scene you want to use it in. For instance, as you can see in our example below we have imported the tank from the demo creator.

Step 2: Create the script

With your object in the scene, we're now going to create an example script that will pull the latest creation from the API, and then use a reference to this game object to overwrite its texture. Create a new script copying the script below.

using PlayerMake.V1;
using UnityEngine;

public class InplaceRetexturingExample : MonoBehaviour
{
    public GameObject target;

    async void Start()
    {
        (var creations, var pagination) = await PlayerMakeSdk.ListCreationsAsync(
            statuses: new string[] { "APPROVED", "PENDING_APPROVAL" }
        );

        await PlayerMakeSdk.ApplySkinAsync(creations[0], target);
    }
}

Step 3: Bring the script into the scene

Now that you have your new script, bring it into the active scene, and assign your model that's already in the scene as the target variable.

Step 4: Hit play

Now hit play, and assuming you have at least 1 creation, and that the mesh hierarchy of your target object matches that creation, then your skin will be applied.

(Optional) Step 5: Consider multiple different models

In the scenario where you have multiple models you want to do in-place texture swapping for, you need a way to work out which creation was made for which model. For this you can use the Asset property on the Creation object. On that property you will find an ID field that will be unique to each base asset uploaded to Player Make. You can use this to work out which models you should be applying skins to on your side.

Conclusion

You now have a working instance of in place retexturing, which can come in very handy for those situations where you've got a lot of custom logic on a game object already and you don't want to instantiate a whole new model.