Skip to content

Commit

Permalink
Add Spook Mode
Browse files Browse the repository at this point in the history
Doot Doot
  • Loading branch information
Xiexe committed Oct 1, 2018
1 parent 36bef14 commit 44c2314
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
XSBoner/Generated
Binary file added XSBoner/Editor/Doot.mp3
Binary file not shown.
22 changes: 22 additions & 0 deletions XSBoner/Editor/Doot.mp3.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 24 additions & 6 deletions XSBoner/Editor/XSBonerGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public class XSBonerGenerator : EditorWindow {
private Material boneMaterial;
private Material ikMaterial;
private bool haveIKLines;
private Animator ani;
private bool spookMode;
private Animator ani;

private List<Transform> bones;
private Hashtable bonesByHash;
Expand All @@ -22,6 +23,7 @@ public class XSBonerGenerator : EditorWindow {
private List<Color> coloUrs;
private Object startingBone;


[MenuItem("Xiexe/Tools/XSBonerGenerator")]
static void Init()
{
Expand Down Expand Up @@ -87,6 +89,9 @@ private void OnGUI()
{
haveIKLines = false;
}

//Toggle for Spook Mode
spookMode = EditorGUILayout.Toggle("Spook Mode (Optional)", spookMode);

bool error = false;
if (armatureObj == null)
Expand Down Expand Up @@ -128,12 +133,13 @@ private void OnGUI()

ArrayUtility.RemoveAt(ref splitString, splitString.Length - 1);
ArrayUtility.RemoveAt(ref splitString, splitString.Length - 1);

string finalFilePath = string.Join("/", splitString);
finalFilePath += "/Generated";
string pathToGenerated = finalFilePath + "/Generated";
string editorPath = string.Join("/", splitString) + "/Editor";

if (!Directory.Exists(finalFilePath)) {
Directory.CreateDirectory(finalFilePath);
if (!Directory.Exists(pathToGenerated)) {
Directory.CreateDirectory(pathToGenerated);
}

bone = AssetDatabase.LoadAssetAtPath(AssetDatabase.GetAssetPath(bone), typeof(Object));
Expand Down Expand Up @@ -178,6 +184,18 @@ private void OnGUI()
{
name = name + "_" + bonename + "_YourBones"
};

//Adding Audio Source for Super Spooky Mode.
if (spookMode){
yourBones.AddComponent<AudioSource>();
AudioSource doot = yourBones.GetComponent<AudioSource>();
doot.clip = (AudioClip)AssetDatabase.LoadAssetAtPath(editorPath + "/Doot.mp3", typeof(AudioClip));
doot.spatialBlend = 1;
doot.dopplerLevel = 0;
doot.minDistance = 2;
doot.maxDistance = 10;
}
//----
yourSkinnedMeshRenderer.sharedMesh.CombineMeshes(combineInstances.ToArray());

Vector3 scale = ani.transform.localScale;
Expand Down Expand Up @@ -219,7 +237,7 @@ private void OnGUI()

yourSkinnedMeshRenderer.sharedMesh.RecalculateBounds();

AssetDatabase.CreateAsset(yourSkinnedMeshRenderer.sharedMesh, finalFilePath + "/" + name + "_" + bonename + "_YourBones.asset");
AssetDatabase.CreateAsset(yourSkinnedMeshRenderer.sharedMesh, pathToGenerated + "/" + name + "_" + bonename + "_YourBones.asset");
AssetDatabase.SaveAssets();

armatureObj = null;
Expand Down

0 comments on commit 44c2314

Please sign in to comment.