/*OLD VERSION OF INSPECTOR UPDATE: IT'S REALLY BADLY MADE * void OnInspectorUpdate() * { * //If the mod database exists, set both the Texture and InGame preview to what they currently look like. This basically refreshes previews every 10 frames or so. * if (AssetDatabase.IsValidFolder ("Assets/Pants_Assets")) { * PantsTex = AssetDatabase.LoadAssetAtPath<Texture2D> ("Assets/Pants_Assets/Resources/Bundles/Items/Pants/Jeans_Work/Pants.png"); * PantsEm = AssetDatabase.LoadAssetAtPath<Texture2D> ("Assets/Pants_Assets/Resources/Bundles/Items/Pants/Jeans_Work/Emission.png"); * PantsPreview = AssetPreview.GetAssetPreview (PantsTex); * * } else { * //If the mod data folder is missing/damaged, this will display the null icon for the PantsPreview instead rather than displaying nothing. * PantsPreview = AssetDatabase.LoadAssetAtPath<Texture2D> ("Assets/ClothingCreator/Icons/Null.png"); * //If I'm being honest, I'm unsure why this is here. It clearly won't work outside of the OnGui void in it's current state, but yet I kept it here anyways. Hmmm * Debug.Log("ERROR"); * } * /*This is my pitiful attempt to check whether or not the .unitypackage had imported without using those gay-ass IEnumerator thingies. It's such a pain in the ass to make a new void just for waiting, so I said f**k it and just made this. * It checks whether or not the folder that should be present once the package has imported exists, and if it does it runs a one-time setup process to create the InGame preview window basis, as well as potentially the emission map when I * add it. I'm using a boolean to check whether or not to run the void again, and once the void has been run once, it turns the boolean true so it can never run again. * * if (AssetDatabase.IsValidFolder ("Assets/Pants_Assets")) { * UnityEngine.Object prefab = AssetDatabase.LoadAssetAtPath ("Assets/Pants_Assets/Resources/Bundles/Items/Pants/Jeans_Work/Item.prefab", typeof(GameObject)); * if (!clone.activeInHierarchy) { * clone = Instantiate (prefab, Vector3.zero, Quaternion.identity) as GameObject; * clone.name = "New Cam"; * clone.transform.Rotate (-90, 0, 0); * } * /*MeshRenderer meshrend = clone.GetComponent<MeshRenderer> (); * if (PantsEm != null) { * meshrend.material.SetTexture ("_EmissionMap", PantsEm); * } * //Make a copy of the Main Camera and place it 2 units above the origin. * if (!cam.activeInHierarchy) { * cam = Instantiate (GameObject.FindWithTag ("MainCamera"), Vector3.zero, Quaternion.identity) as GameObject; * cam.transform.Translate (0, 2, 0); * cam.transform.Rotate (90, 90, 0); * } * //Set the InGame preview's render texture to a 210x128 pixel texture with a depth of 16. I actually have no f*****g idea what the RenderTextureFormat does, but it was on the docs so I assumed it was probably necessary. * if (PantsScenePreview.Equals (null)) { * PantsScenePreview = new RenderTexture (210, 128, 16, RenderTextureFormat.ARGB32); * //Without this, the texture will never be uploaded to the GPU. It's literally essential or else your texture won't work. * PantsScenePreview.Create (); * } * //Registering the actual camera component of the Main Camera duplicate we made earlier. * if (camera.Equals (null)) { * camera = cam.GetComponent<Camera> (); * camera.targetTexture = PantsScenePreview; * } * //Creating a new GameObject called Holder that will serve as the point of rotation for the Camera, so it can rotate around the pants properly. * if (!holder.activeInHierarchy) * { * holder = new GameObject ("Holder"); * //Set the camera GameObject's parent to Holder, so it will follow the Holder's rotation. * cam.transform.parent = holder.transform; * //Guarantee that this void will never run again, as this will create an endless stream of new GameObjects (don't remove me or you will lag & or crash) * } * } * //Updating the rotation of the Holder depending on the rotation setting on the Rotate Preview slider. * holder.transform.eulerAngles = new Vector3 (camRotation, 0, 0); * //Redraw the window, updating any previews about every 10 frames. * Repaint (); * }*/ void OnInspectorUpdate() { if (PantsScenePreview == null) { PantsScenePreview = new RenderTexture(210, 128, 16, RenderTextureFormat.ARGB32); //Without this, the texture will never be uploaded to the GPU. It's literally essential or else your texture won't work. PantsScenePreview.Create(); } if (!displayErrors) { ClearLogConsole(); } if (AssetDatabase.IsValidFolder("Assets/Pants_Assets")) { mat = AssetDatabase.LoadAssetAtPath <Material> ("Assets/Pants_Assets/Resources/Bundles/Items/Pants/Jeans_Work/Material.mat"); PantsTex = AssetDatabase.LoadAssetAtPath <Texture2D> ("Assets/Pants_Assets/Resources/Bundles/Items/Pants/Jeans_Work/Pants.png"); PantsEm = AssetDatabase.LoadAssetAtPath <Texture2D> ("Assets/Pants_Assets/Resources/Bundles/Items/Pants/Jeans_Work/Emission.png"); PantsMet = AssetDatabase.LoadAssetAtPath <Texture2D> ("Assets/Pants_Assets/Resources/Bundles/Items/Pants/Jeans_Work/Metallic.png"); mat.SetFloat("_GlossMapScale", smoothness); mat.SetFloat("_Glossiness", smoothness); mat.SetFloat("_Metallic", 0); PantsPreview = AssetDatabase.LoadAssetAtPath <Texture2D> ("Assets/Pants_Assets/Resources/Bundles/Items/Pants/Jeans_Work/Pants.png"); UnityEngine.Object prefab = AssetDatabase.LoadAssetAtPath("Assets/Pants_Assets/Resources/Bundles/Items/Pants/Jeans_Work/Item.prefab", typeof(GameObject)); if (GameObject.Find("Pants") == null) { clone = Instantiate(prefab, Vector3.zero, Quaternion.identity) as GameObject; clone.name = "Pants"; clone.transform.Rotate(-90, 0, 0); } if (GameObject.Find("View Cam") == null) { cam = Instantiate(GameObject.FindWithTag("MainCamera"), Vector3.zero, Quaternion.identity) as GameObject; cam.transform.Translate(0, 2, 0); cam.transform.Rotate(90, 90, 0); cam.name = "View Cam"; camera = cam.GetComponent <Camera> (); camera.targetTexture = PantsScenePreview; camera.orthographic = true; camera.orthographicSize = 0.6f; } else if (GameObject.Find("View Cam")) { cam = GameObject.Find("View Cam"); camera = cam.GetComponent <Camera> (); camera.targetTexture = PantsScenePreview; } if (GameObject.Find("Holder") != null) { holder = GameObject.Find("Holder"); cam.transform.parent = holder.transform; } } if (GameObject.Find("Holder") == null) { holder = new GameObject("Holder"); cam.transform.parent = holder.transform; } else if (!AssetDatabase.IsValidFolder("Assets/Pants_Assets")) { PantsPreview = AssetDatabase.LoadAssetAtPath <Texture2D> ("Assets/ClothingCreator/Icons/Null.png"); } if (AssetDatabase.IsValidFolder("Assets/Pants_Assets") && hasRan == false) { mat.SetColor("_EmissionColor", Color.black); mat.SetTexture("_MetallicGlossMap", null); hasRan = true; } if (holder != null) { holder.transform.eulerAngles = new Vector3(camRotation, 0, 0); } else { if (GameObject.Find("Holder")) { holder = GameObject.Find("Holder"); } else { window.EndWindows(); } } //Redraw the window, updating any previews about every 10 frames. Repaint(); }