public void OFRim() { if (RimButton.GetComponent <Toggle>().isOn) { RimLight.SetActive(true); } else { RimLight.SetActive(false); } }
void OnGUI() { //set window title this.titleContent = new GUIContent("Rim Light Profile"); profileName = EditorGUILayout.TextField(profileName); if (GUILayout.Button("Save Profile")) { GameObject rimLight = GameObject.Find("Rim Light"); float rimIntensity = rimLight.GetComponent <Light>().intensity; Vector3 rimAngle = new Vector3(rimLight.transform.localEulerAngles.x, rimLight.transform.localEulerAngles.y, rimLight.transform.localEulerAngles.z); Color Colour = rimLight.GetComponent <Light>().color; LightProperties rim = new LightProperties(); rim.Intensity = rimIntensity; rim.Angle = rimAngle; rim.Colour = Colour; string json = JsonUtility.ToJson(rim, true); string path = "Assets/Resources/Profiles/rimlight/" + profileName + ".json"; //Write some text to the test.txt file StreamWriter writer = new StreamWriter(path, false); writer.Write(json); writer.Close(); } GUILayout.Space(60); string[] rimProfileNames = new String[options.Length]; for (int runs = 0; runs < options.Length; runs++) { string[] profileSplit = options[runs].Split('\\'); string nameSplit = profileSplit[profileSplit.Length - 1].Split('.')[0]; rimProfileNames[runs] = nameSplit; } index = EditorGUILayout.Popup(index, rimProfileNames); if (GUILayout.Button("Load Profile")) { GameObject cam = GameObject.Find("CAM"); Debug.Log("Profiles/rimlight" + rimProfileNames[index]); RimLight.createRimLight(cam, "Profiles/rimlight/" + rimProfileNames[index]); } }
void OnGUI() { //set window title this.titleContent = new GUIContent("IoM - Build Scene"); //object field GUILayout.BeginHorizontal("box"); source = EditorGUILayout.ObjectField(source, typeof(TextAsset), true); if (GUILayout.Button("Scene Name", GUILayout.Width(100))) { //get name of scene Scene scene = SceneManager.GetActiveScene(); //look for corresponding json file var jsonFile = Resources.Load <UnityEngine.Object>("JSON/" + scene.name); //set object feild text asset to use json file source = EditorGUILayout.ObjectField(jsonFile, typeof(TextAsset), true); } GUILayout.EndHorizontal(); if (GUILayout.Button("Add to scene", GUILayout.Height(60))) { //clear out any existing timeline objects if (GameObject.Find("TIMELINE") != null) { DestroyImmediate(GameObject.Find("TIMELINE")); } //create new timeline GameObject timeline = new GameObject("TIMELINE"); PlayableDirector director = timeline.AddComponent <PlayableDirector>(); TimelineAsset timelineAsset = CreateInstance <TimelineAsset>(); timelineAsset.editorSettings.fps = 25; director.playableAsset = timelineAsset; //load json into class string jsonText = File.ReadAllText(Application.dataPath + "/Resources/json/" + source.name + ".json"); PlayerStatsList myPlayerStatsList = new PlayerStatsList(); JsonUtility.FromJsonOverwrite(jsonText, myPlayerStatsList); //add abc cache to scene foreach (PlayerStats e in myPlayerStatsList.extras) { MyClass abcObject = new MyClass(); abcObject.characterPath = e.abc; Extras.addExtras(abcObject, director, timelineAsset); } //add camera to scene foreach (PlayerStats c in myPlayerStatsList.cameras) { //place asset in scene MyClass myObject = new MyClass(); myObject.cameraPath = c.model; tempobj = (GameObject)Instantiate(Resources.Load(myObject.cameraPath), new Vector3(0, 0, 0), Quaternion.identity); tempobj.name = c.name; //create animation track on TIMELINE AnimationTrack newTrack = timelineAsset.CreateTrack <AnimationTrack>(null, "Animation Track " + tempobj.name); director.SetGenericBinding(newTrack, tempobj); myObject.animPath = c.anim; AnimationClip animClip = Resources.Load <AnimationClip>(myObject.animPath); TimelineClip timelineClip = newTrack.CreateClip(animClip); //Turn remove start offset off to fix camera position var animPlayableAsset = (AnimationPlayableAsset)timelineClip.asset; animPlayableAsset.removeStartOffset = false; //make rim light myObject.rimPath = c.rimProfile; RimLight.createRimLight(tempobj, myObject.rimPath); //add post processing PostProcessing.addPostProcessing(tempobj, c.profile); } //add characters and props to scene foreach (PlayerStats p in myPlayerStatsList.characters) { //place asset in scene MyClass myObject = new MyClass(); myObject.characterPath = p.model; tempobj = (GameObject)Instantiate(Resources.Load(myObject.characterPath), new Vector3(0, 0, 0), Quaternion.identity); tempobj.name = p.name; foreach (Transform trans in tempobj.GetComponentsInChildren <Transform>(true)) { trans.gameObject.layer = LayerMask.NameToLayer("Characters"); } //create animation track on TIMELINE AnimationTrack newTrack = timelineAsset.CreateTrack <AnimationTrack>(null, "Animation Track " + tempobj.name); director.SetGenericBinding(newTrack, tempobj); myObject.animPath = p.anim; AnimationClip animClip = Resources.Load <AnimationClip>(myObject.animPath); TimelineClip timelineClip = newTrack.CreateClip(animClip); //Turn remove start offset off to fix camera position var animPlayableAsset = (AnimationPlayableAsset)timelineClip.asset; animPlayableAsset.removeStartOffset = false; } //add sets to scene foreach (PlayerStats s in myPlayerStatsList.sets) { //place asset in scene MyClass myObject = new MyClass(); myObject.setPath = s.model; tempobj = (GameObject)Instantiate(Resources.Load(myObject.setPath), new Vector3(0, 0, 0), Quaternion.identity); tempobj.name = s.name; } //button to add post effects if it doesn't get added automaticly (or changes) } if (GUILayout.Button("Add Post Effects")) { GameObject cam = GameObject.Find("CAM"); MyClass myObject = new MyClass(); string jsonText = File.ReadAllText(Application.dataPath + "/Resources/json/" + source.name + ".json"); PlayerStatsList myPlayerStatsList = new PlayerStatsList(); JsonUtility.FromJsonOverwrite(jsonText, myPlayerStatsList); PlayerStats c = myPlayerStatsList.cameras[0]; PostProcessing.addPostProcessing(cam, c.profile); } }
static void PerformBuild() { //clear out any existing timeline objects if (GameObject.Find("TIMELINE") != null) { DestroyImmediate(GameObject.Find("TIMELINE")); } //create new timeline GameObject timeline = new GameObject("TIMELINE"); PlayableDirector director = timeline.AddComponent <PlayableDirector>(); TimelineAsset timelineAsset = ScriptableObject.CreateInstance <TimelineAsset>(); timelineAsset.editorSettings.fps = 25; director.playableAsset = timelineAsset; //load json into class string jsonText = File.ReadAllText(Application.dataPath + "/Resources/json/" + GetArg("-shotName") + ".json"); PlayerStatsList myPlayerStatsList = new PlayerStatsList(); JsonUtility.FromJsonOverwrite(jsonText, myPlayerStatsList); //add abc cache to scene foreach (PlayerStats e in myPlayerStatsList.extras) { BuildScene.MyClass abcObject = new BuildScene.MyClass(); abcObject.characterPath = e.abc; Extras.addExtras(abcObject, director, timelineAsset); } //add camera to scene foreach (PlayerStats c in myPlayerStatsList.cameras) { //place asset in scene MyClass myObject = new MyClass(); myObject.cameraPath = c.model; GameObject tempobj = (GameObject)Instantiate(Resources.Load(myObject.cameraPath), new Vector3(0, 0, 0), Quaternion.identity); tempobj.name = c.name; //create animation track on TIMELINE AnimationTrack newTrack = timelineAsset.CreateTrack <AnimationTrack>(null, "Animation Track " + tempobj.name); director.SetGenericBinding(newTrack, tempobj); myObject.animPath = c.anim; AnimationClip animClip = Resources.Load <AnimationClip>(myObject.animPath); TimelineClip timelineClip = newTrack.CreateClip(animClip); //Turn remove start offset off to fix camera position var animPlayableAsset = (AnimationPlayableAsset)timelineClip.asset; animPlayableAsset.removeStartOffset = false; //make rim light myObject.rimPath = c.rimProfile; RimLight.createRimLight(tempobj, myObject.rimPath); //add post processing PostProcessing.addPostProcessing(tempobj, c.profile); } //loop through objects in class foreach (PlayerStats p in myPlayerStatsList.characters) { //place asset in scene MyClass myObject = new MyClass(); myObject.characterPath = p.model; GameObject tempobj = (GameObject)Instantiate(Resources.Load(myObject.characterPath), new Vector3(0, 0, 0), Quaternion.identity); tempobj.name = p.name; //set objects to "Characters" layer foreach (Transform trans in tempobj.GetComponentsInChildren <Transform>(true)) { trans.gameObject.layer = LayerMask.NameToLayer("Characters"); } //create animation track on TIMELINE AnimationTrack newTrack = timelineAsset.CreateTrack <AnimationTrack>(null, "Animation Track " + tempobj.name); director.SetGenericBinding(newTrack, tempobj); myObject.animPath = p.anim; AnimationClip animClip = Resources.Load <AnimationClip>(myObject.animPath); TimelineClip timelineClip = newTrack.CreateClip(animClip); //Turn remove start offset off to fix camera position var animPlayableAsset = (AnimationPlayableAsset)timelineClip.asset; animPlayableAsset.removeStartOffset = false; } //add sets to scene foreach (PlayerStats s in myPlayerStatsList.sets) { //place asset in scene MyClass myObject = new MyClass(); myObject.setPath = s.model; GameObject tempobj = (GameObject)Instantiate(Resources.Load(myObject.setPath), new Vector3(0, 0, 0), Quaternion.identity); tempobj.name = s.name; } //add post processing to camera /* * GameObject cam = GameObject.Find("CAM"); * if (cam != null) * { * cam.AddComponent<PostProcessLayer>(); * ppv = cam.AddComponent<PostProcessVolume>(); * ppp = Resources.Load<PostProcessProfile>("Profiles/MainCameraProfile1"); * ppv.profile = ppp; * } * else * { * Debug.LogWarning("No Camera found. The camera must be named - CAM"); * } */ //save scene EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene(), GetArg("-scenePath")); }