1. import girl charater model to unity
2. Create Canvas Button with canvas. change name to 'Click to Change Girl Dress'.
3. Attach below code to Canvas. Show to button OnClick(). show to 'Change_Dress()' function.
4. Last Step - You should show 'Girl Texture' and 'Girl Material(it is located at girls model)' to script.
Click the button and Change Girl Dress.
Code :-
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class CharacterHiding : MonoBehaviour {
public Texture NewDressTexture = new Texture ();
public Renderer rend;
void Start () {
// Find girl shader material at charater childern
Renderer rend = GetComponentInChildren<Renderer>();
}
public void Change_Dress() // Attach this function to Button (Dress change button)
{
rend.material.mainTexture = NewDressTexture;
}
}
No comments:
Post a Comment