public static void CreatePrefab() { GameObject[] objectArray = Selection.gameObjects; foreach (GameObject gameObject in objectArray) { string localPath = Path.Combine(ModPacker.GetProjectPath(), gameObject.name + ".prefab").Replace("\\", "/"); Debug.Log(localPath); if (AssetDatabase.LoadAssetAtPath(localPath, typeof(GameObject))) { CreateNew(gameObject, localPath); } else { Debug.Log(gameObject.name + " is not a prefab, will convert"); CreateNew(gameObject, localPath); } } }
public void DrawModBuilder(SerializedObject serializedObject) { var packingObjectsField = serializedObject.FindProperty("packingObjects"); foldoutMod = EditorGUILayout.Foldout(foldoutMod, "Build Mod", true, Style.Foldout); if (!foldoutMod) { return; } GUILayout.BeginVertical("box"); if (packingObjects == null || packingObjects.Length <= 0) { EditorGUILayout.HelpBox( "You didn't specified the mod xml scripts. It will automatically try to get *.xml files from the folder you're looking at in Project Window.", MessageType.Info, true); } if (!Directory.Exists(GameExportPath)) { EditorGUILayout.HelpBox("You need to provide Output Directory to build mods.", MessageType.Error, true); } GUILayout.Label("Build Mod Targets", Style.Header); EditorGUILayout.PropertyField(packingObjectsField, new GUIContent("Target Mod XML Files"), true); GUILayout.Space(10); EditorPrefs.SetString("hoohTool_exportPath", EditorGUILayout.TextField("Output Destination: ", GameExportPath)); GameExportPath = EditorPrefs.GetString("hoohTool_exportPath"); GUILayout.BeginHorizontal(); GUI.backgroundColor = HoohWindowStyles.green; if (GUILayout.Button("Build Mod", Style.ButtonDark)) { SetEvent(() => { ModPacker.PackMod(packingObjects, GameExportPath); }); } GUI.backgroundColor = HoohWindowStyles.red; if (GUILayout.Button("Remove All", Style.ButtonDark)) { SetEvent(() => { var check = EditorUtility.DisplayDialog("Are you sure?", "Just checking, did you really tried to remove all target xml files?", "Yes", "No"); if (check) { packingObjects = null; } }); } GUI.backgroundColor = Color.white; if (GUILayout.Button("Add Folder", Style.Button)) { SetEvent(() => { var folderAssets = ModPacker.GetProjectDirectoryTextAssets(); if (folderAssets.Length > 0) { packingObjects = packingObjects != null ? packingObjects.Concat(folderAssets).Distinct().ToArray() : folderAssets; } else { EditorUtility.DisplayDialog("Oh noes", "There is no xml files in project window.", "Okay i'll go to folder where has some xml files."); } }); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Dry Run", Style.Button)) { SetEvent( () => { ModPacker.PackMod(packingObjects, GameExportPath, true); } ); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); }
private void OnGUI() { InitStyle(); if (GUILayout.Button("Check Updates")) { Application.OpenURL("https://github.com/hooh-hooah/ModdingTool/tree/release/"); } if (GUILayout.Button("How to make mods for AI?")) { Application.OpenURL("https://github.com/hooh-hooah/AI_Tips"); } DrawUILine(new Color(0, 0, 0)); EditorGUILayout.BeginVertical(); scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(0), GUILayout.Height(0)); { foldoutElement = EditorGUILayout.Foldout(foldoutElement, "Element Generator", true, foldoutStyle); if (foldoutElement) { EditorPrefs.SetInt("hoohTool_category", int.Parse(EditorGUILayout.TextField("Big Category Number: ", category.ToString()))); EditorPrefs.SetInt("hoohTool_categorysmall", int.Parse(EditorGUILayout.TextField("Mid Category Number: ", categorySmall.ToString()))); EditorPrefs.SetString("hoohTool_sideloadString", EditorGUILayout.TextField("Game Assetbundle Path: ", sideloaderString)); category = EditorPrefs.GetInt("hoohTool_category"); // this is mine tho sideloaderString = EditorPrefs.GetString("hoohTool_sideloadString"); categorySmall = EditorPrefs.GetInt("hoohTool_categorysmall"); // this is mine tho if (GUILayout.Button("Generate And Fill Item List in mod.xml")) { if (CheckGoodSelection()) { try { GameObject[] selections = Selection.gameObjects; string path = Path.Combine(Path.Combine(Directory.GetCurrentDirectory(), ModPacker.GetProjectPath()), "mod.xml").Replace("\\", "/"); XDocument document = TouchXML.GetXMLObject(path); TouchXML.GenerateObjectString(document, selections); TouchXML.GenerateBundleString(document, selections); Debug.Log(path); document.Save(path); } catch (InvalidCastException e) { Debug.LogError("You've selected wrong kind of object. You should only select prefabs!"); } catch (Exception e) { Debug.LogError(e); } } } if (GUILayout.Button("Add Bone Information of this object")) { if (CheckGoodSelection()) { try { GameObject[] selections = Selection.gameObjects; string path = Path.Combine(Path.Combine(Directory.GetCurrentDirectory(), ModPacker.GetProjectPath()), "mod.xml").Replace("\\", "/"); XDocument document = TouchXML.GetXMLObject(path); TouchXML.GenerateBoneString(document, selections); Debug.Log(path); document.Save(path); } catch (InvalidCastException e) { Debug.LogError("You've selected wrong kind of object. You should only select prefabs!"); } catch (Exception e) { Debug.LogError(e); } } } } foldoutMacros = EditorGUILayout.Foldout(foldoutMacros, "Quick Unity Macros", true, foldoutStyle); if (foldoutMacros) { gap = EditorGUILayout.IntField("Showcase Gap: ", gap); cols = EditorGUILayout.IntField("Showcase Columns: ", cols); if (GUILayout.Button("Showcase Mode")) { if (CheckGoodSelection()) { ShowcaseMode(); } } if (GUILayout.Button("Randomize Rotation")) { if (CheckGoodSelection()) { RandomizeRotation(); } } if (GUILayout.Button("Wrap Object with new GameObject and Scale")) { if (CheckGoodSelection()) { WrapObjectScale(); } } if (GUILayout.Button("Wrap Object with new GameObject")) { if (CheckGoodSelection()) { WrapObject(); } } if (GUILayout.Button("Create Prefab from Selected Objects")) { if (CheckGoodSelection()) { CreatePrefab(); } } lightScaleSize = EditorGUILayout.FloatField("Light Scale Size: ", lightScaleSize); if (GUILayout.Button("Scale Lights and Probes")) { if (CheckGoodSelection()) { ScaleLightsAndProbes(); } } } foldoutProbeset = EditorGUILayout.Foldout(foldoutProbeset, "LightProbe Adjustment", true, foldoutStyle); if (foldoutProbeset) { if (inputNumber > 5.0f) { sliderValue = 5.0f; } else if (inputNumber < 1) { sliderValue = 1; } string inputText = " "; sliderValue = EditorGUILayout.Slider(sliderValue, minSliderValue, maxSliderValue); if (inputNumber != sliderValue) { if (float.TryParse(inputText, out inputNumber)) { sliderValue = Mathf.Clamp(inputNumber, minSliderValue, maxSliderValue); } else if (inputText == " ") { inputNumber = sliderValue; } } EditorPrefs.SetFloat("hoohTool_probeStrength", sliderValue); if (GUILayout.Button("Increase Intensity")) { ProbeIntensity.ScaleLightProbeData(sliderValue); ProbeIntensity.DisplayWarning(); } if (GUILayout.Button("Decrease Intensity")) { ProbeIntensity.ScaleLightProbeData(1 / Mathf.Abs(sliderValue)); } if (GUILayout.Button("Reset Intensity")) { ProbeIntensity.ResetProbeData(); ProbeIntensity.DisplayWarning(); } } foldoutScaffolding = EditorGUILayout.Foldout(foldoutScaffolding, "Mod Scaffolding", true, foldoutStyle); if (foldoutScaffolding) { if (GUILayout.Button("Initialize Hair")) { if (CheckGoodSelection()) { AIObjectHelper.InitializeHair((GameObject)Selection.activeObject); } } if (GUILayout.Button("Initialize Accessory")) { if (CheckGoodSelection()) { AIObjectHelper.InitializeAccessory((GameObject)Selection.activeObject); } } if (GUILayout.Button("Initialize Clothes")) { if (CheckGoodSelection()) { AIObjectHelper.InitializeClothes((GameObject)Selection.activeObject); } } if (GUILayout.Button("Initialize Studio Item (If it has more info)")) { if (CheckGoodSelection()) { AIObjectHelper.InitializeItem((GameObject)Selection.activeObject); } } } foldoutMod = EditorGUILayout.Foldout(foldoutMod, "Build Mod", true, foldoutStyle); if (foldoutMod) { EditorPrefs.SetString("hoohTool_exportPath", EditorGUILayout.TextField("Zipmod Destination: ", gameExportPath)); gameExportPath = EditorPrefs.GetString("hoohTool_exportPath"); if (GUILayout.Button("Build Mod")) { ModPacker.PackMod(gameExportPath); } } foldoutBundler = EditorGUILayout.Foldout(foldoutBundler, "Assetbundle Builder", true, foldoutStyle); if (foldoutBundler) { if (GUILayout.Button("Build All Assetbundles")) { BuildAllAssetBundles(); } } } EditorPrefs.SetBool("hoohTool_foldoutElement", foldoutElement); EditorPrefs.SetBool("hoohTool_foldoutMacros", foldoutMacros); EditorPrefs.SetBool("hoohTool_foldoutProbeset", foldoutProbeset); EditorPrefs.SetBool("hoohTool_foldoutScaffolding", foldoutScaffolding); EditorPrefs.SetBool("hoohTool_foldoutMod", foldoutMod); EditorPrefs.SetBool("hoohTool_foldoutBundler", foldoutBundler); EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); }
public static void InitializeHair(GameObject selectedObject) { GameObject hairObject = selectedObject; hairObject.layer = 10; if (hairObject != null) { AIChara.CmpHair hairComponent = hairObject.GetComponent <AIChara.CmpHair>(); if (hairComponent == null) { hairComponent = hairObject.AddComponent <AIChara.CmpHair>(); } FindAssist findAssist = new FindAssist(); findAssist.Initialize(hairComponent.transform); hairComponent.rendHair = (from x in hairComponent.GetComponentsInChildren <Renderer>(true) where !x.name.Contains("_acs") select x).ToArray(); // remove all dynamic bones. smh... DynamicBone[] components = hairComponent.GetComponents <DynamicBone>(); foreach (var comp in components) { Object.DestroyImmediate(comp); } DevPreviewHair previewComp = hairObject.GetComponent <DevPreviewHair>(); if (previewComp == null) { previewComp = hairObject.AddComponent <DevPreviewHair>(); } previewComp.hairTexturePath = ModPacker.GetProjectPath().Replace("Assets/", ""); var dynBones = (from x in findAssist.dictObjName where x.Value.transform.name.Contains("_s") select x.Value).ToArray(); foreach (GameObject bone in dynBones) { DynamicBone dynBone = hairObject.AddComponent <DynamicBone>(); dynBone.m_Root = bone.transform; dynBone.m_UpdateRate = 60; dynBone.m_UpdateMode = DynamicBone.UpdateMode.AnimatePhysics; dynBone.m_Damping = 0.102f; dynBone.m_Elasticity = 0.019f; dynBone.m_ElasticityDistrib = new AnimationCurve(); dynBone.m_ElasticityDistrib.AddKey(0f, 0.969f); dynBone.m_ElasticityDistrib.AddKey(1f, 0.603f); dynBone.m_Stiffness = 0.144f; dynBone.m_Inert = 0.072f; dynBone.m_Radius = 0.1f; dynBone.m_RadiusDistrib = new AnimationCurve(); dynBone.m_RadiusDistrib.AddKey(0f, 1f); dynBone.m_RadiusDistrib.AddKey(1f, 0.5f); dynBone.m_EndLength = 0f; dynBone.m_Force = new Vector3(0, -0.005f, 0); } components = hairComponent.GetComponents <DynamicBone>(); KeyValuePair <string, GameObject> keyValuePair = findAssist.dictObjName.FirstOrDefault((KeyValuePair <string, GameObject> x) => x.Key.Contains("_top")); if (keyValuePair.Equals(default(KeyValuePair <string, GameObject>))) { return; } hairComponent.boneInfo = new AIChara.CmpHair.BoneInfo[keyValuePair.Value.transform.childCount]; for (int i = 0; i < hairComponent.boneInfo.Length; i++) { Transform child = keyValuePair.Value.transform.GetChild(i); findAssist.Initialize(child); AIChara.CmpHair.BoneInfo boneInfo = new AIChara.CmpHair.BoneInfo(); KeyValuePair <string, GameObject> keyValuePair2 = findAssist.dictObjName.FirstOrDefault((KeyValuePair <string, GameObject> x) => x.Key.Contains("_s")); if (!keyValuePair2.Equals(default(KeyValuePair <string, GameObject>))) { Transform transform = keyValuePair2.Value.transform; boneInfo.trfCorrect = transform; boneInfo.basePos = boneInfo.trfCorrect.transform.localPosition; boneInfo.posMin.x = boneInfo.trfCorrect.transform.localPosition.x + 0.5f; boneInfo.posMin.y = boneInfo.trfCorrect.transform.localPosition.y; boneInfo.posMin.z = boneInfo.trfCorrect.transform.localPosition.z + 0.5f; boneInfo.posMax.x = boneInfo.trfCorrect.transform.localPosition.x - 0.5f; boneInfo.posMax.y = boneInfo.trfCorrect.transform.localPosition.y - 0.5f; boneInfo.posMax.z = boneInfo.trfCorrect.transform.localPosition.z - 0.5f; boneInfo.baseRot = boneInfo.trfCorrect.transform.localEulerAngles; boneInfo.rotMin.x = boneInfo.trfCorrect.transform.localEulerAngles.x - 30f; boneInfo.rotMin.y = boneInfo.trfCorrect.transform.localEulerAngles.y - 30f; boneInfo.rotMin.z = boneInfo.trfCorrect.transform.localEulerAngles.z - 30f; boneInfo.rotMax.x = boneInfo.trfCorrect.transform.localEulerAngles.x + 30f; boneInfo.rotMax.y = boneInfo.trfCorrect.transform.localEulerAngles.y + 30f; boneInfo.rotMax.z = boneInfo.trfCorrect.transform.localEulerAngles.z + 30f; boneInfo.moveRate.x = Mathf.InverseLerp(boneInfo.posMin.x, boneInfo.posMax.x, boneInfo.basePos.x); boneInfo.moveRate.y = Mathf.InverseLerp(boneInfo.posMin.y, boneInfo.posMax.y, boneInfo.basePos.y); boneInfo.moveRate.z = Mathf.InverseLerp(boneInfo.posMin.z, boneInfo.posMax.z, boneInfo.basePos.z); boneInfo.rotRate.x = Mathf.InverseLerp(boneInfo.rotMin.x, boneInfo.rotMax.x, boneInfo.baseRot.x); boneInfo.rotRate.y = Mathf.InverseLerp(boneInfo.rotMin.y, boneInfo.rotMax.y, boneInfo.baseRot.y); boneInfo.rotRate.z = Mathf.InverseLerp(boneInfo.rotMin.z, boneInfo.rotMax.z, boneInfo.baseRot.z); } List <DynamicBone> list = new List <DynamicBone>(); DynamicBone[] array = components; for (int j = 0; j < array.Length; j++) { DynamicBone n = array[j]; if (!findAssist.dictObjName.FirstOrDefault((KeyValuePair <string, GameObject> x) => x.Key == n.m_Root.name).Equals(default(KeyValuePair <string, GameObject>))) { list.Add(n); } } boneInfo.dynamicBone = list.ToArray(); hairComponent.boneInfo[i] = boneInfo; } findAssist = new FindAssist(); findAssist.Initialize(hairComponent.transform); hairComponent.rendAccessory = (from s in findAssist.dictObjName where s.Key.Contains("_acs") select s into x select x.Value.GetComponent <Renderer>() into r where null != r select r).ToArray <Renderer>(); SkinnedMeshRenderer[] renderers = hairObject.GetComponentsInChildren <SkinnedMeshRenderer>(); hairComponent.rendCheckVisible = new SkinnedMeshRenderer[renderers.Length]; for (int i = 0; i < renderers.Length; i++) { renderers[i].gameObject.layer = 10; hairComponent.rendCheckVisible[i] = renderers[i]; } } }