- Home /
How do I change Mesh Filter of an object with playerprefs?
Hi there! :) I've got a game with a certain objects that moves, It's level - based game, and it has a store scene, now what I mean I want to do is if someone spends coins in the shop scene I want to have PlayerPrefs of the mesh-filter of the object, let's say if he spends 500 coins, I want the object to have that exact X mesh-filter and if 1000 coins then that Y one. How can I do that? I mean I know I can use like PlayerPrefs.SetInt("Mesh-Filter-Choice",2) but how do I continue from there? create an array of mesh-filters on the object? How do I access that array from the store scene and how do I apply that exact mesh-filter into my gameObject? help would be MUCH appreciated! :) Thanks guys
Answer by OtunGroup · Sep 24, 2018 at 12:47 AM
Hi,
Try creating a script with a public mesh array on it. Then, you can drag and drop your meshes from your assets onto the array in the editor.
From here, you can store the index of the array that corresponds to the currently equipped mesh. Then to actually load the mesh onto the object, you'd say something like:
GetComponent<MeshFilter>().mesh = cosmetics[PlayerPrefs.GetInt("CurrentMesh");
Hope this points you in the right direction. -Greg
Your answer
Follow this Question
Related Questions
Mesh dissapearing from Resources 0 Answers
Why vertex positions appear (0.0, 0.0, 0.0) ? 1 Answer
Using MeshFilter.mesh with static ground plane makes object turn into a plane. 0 Answers
Copying a mesh filter component through script. 0 Answers
How come my code-created cuboids visually have no distinct edges? 1 Answer