~[Loading Custom 3D Models]~ (if you're new to this modding series, please go to part 1) Before we start, make sure that you have the MeshLoader DLL downloaded. We're going to add this DLL to the references, so that visual studio recognizes the MeshLoader classes. Right Click on References in the Solution Explorer>Add Reference Spoiler: step 1 Create a new class so that we can keep all our code ordered. We're going to give pirizuka a cube hat. Spoiler: step 2 Remove all the code in ur class & replace it with the following: PHP: using System.Collections;using UnityEngine;[Mod_Instance]public class <InsertClassName> : MonoBehaviour{} In Unity any code that we put into the Start() function, it'll run once. So we're going to load in the hat once when we load in the mod. The API to load in a model is very simple: PHP: StartCoroutine(Mod_MeshLoader.LoadObject(GameObject obj, string object_path, string texture_path)); obj is an empty gameobject that u want to attach the 3d model on. I've made a simple 3D model to demonstrate the script. 3D Model: http://puu.sh/ieGKv.obj Texture: http://puu.sh/ieGGY.png Now we'll some code to make a new gameobject for the 3D model. Spoiler: step 3 PHP: void Start() { //Spawns in an empty gameobject, we will attach a 3d model to this. GameObject hat = new GameObject("custom hat"); //Apply the 3D Model to the empty gameobject. StartCoroutine(Mod_MeshLoader.LoadObject(hat, "http://puu.sh/ieGKv.obj", "http://puu.sh/ieGGY.png")); //In order for the hat to follow the player we'll have to add this as a child to the Player(Player is called pirizuka). Transform pirizuka = GameObject.Find("Pirizuka").transform; hat.transform.parent = pirizuka; //Make sure that the hat is positioned correctly above the player's head. hat.transform.position = pirizuka.position + new Vector3(0, 2, 0); } Now rebuild/recompile the code & go to the output folder. There should be a DLL file with the name of ur Mod. Move this file into the Zerahypt/Zerahypt_Data/Mods/ folder. Now run Zerahypt & let the magic happen! Spoiler: step 4 The hat seems to be a little big xD But you can fix that by changing the transform scale.
I'll look at it tomorrow Disclaimer: when I'll see this tomorrow it'll be today thus not tomorrow thus I'll do it tomorrow but then it's today again so I can't do it then because today is not tomorrow, that's tomorrow Looks interesting
Also, for anyone who wants their object to be persistent across levels, load the object in OnLevelWasLoaded() as well as in Start().
Can this load a file off your computer, like if I wanted to load "file:///C:/Users/username/Documents/UnityStuff/Resources/somethinginsignificant.fbx", would that somehow be possible?
I don't think so, since it's using a webrequest. You could use puush or dropbox to upload your models though.
Well, if I put something in that format in the URL bar in Firefox, it will push the file to the computer again, or open it (depending on the file). I suppose I can give it a shot, and see what happens.
Can confirm, the method I mentioned above (adding "file:///" to the beginning of a file location for windows) does work. I don't know why I waited around so long to test this, but it has been tested now.