// Use this for initialization void Start() { #if UNITY_EDITOR animator = GetComponent <Animator>(); if (animator != null) { animator.enabled = false; } #endif // UNITY_EDITOR allGOCs = this.gameObject.GetComponentsInChildren <GameObjectCtrl>(true); allLSs = this.gameObject.GetComponentsInChildren <LightmapSwitcher>(true); allPPCs = this.gameObject.GetComponentsInChildren <PostProcessCtrl>(true); allLMs = this.gameObject.GetComponentsInChildren <SetLightMapWithDynamicLightColor>(true); fogCtrl = this.gameObject.GetComponentInChildren <FogCtrl>(); #if UNITY_EDITOR maxIndex = GetKeyFrameNum(); if (!LBoot.LBootApp.Running) { animator.enabled = true; animator.speed = 0; } #endif }
void OnDestroy() { allGOCs = null; allLSs = null; allLMs = null; fogCtrl = null; animator = null; }
static public int get_fogColor(IntPtr l) { try { FogCtrl self = (FogCtrl)checkSelf(l); pushValue(l, self.fogColor); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int DoRefresh(IntPtr l) { try { FogCtrl self = (FogCtrl)checkSelf(l); self.DoRefresh(); return(0); } catch (Exception e) { return(error(l, e)); } }
static public int get_fogMode(IntPtr l) { try { FogCtrl self = (FogCtrl)checkSelf(l); pushEnum(l, (int)self.fogMode); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int set_fogColor(IntPtr l) { try { FogCtrl self = (FogCtrl)checkSelf(l); UnityEngine.Color v; checkType(l, 2, out v); self.fogColor = v; return(0); } catch (Exception e) { return(error(l, e)); } }
static public int set_fogMode(IntPtr l) { try { FogCtrl self = (FogCtrl)checkSelf(l); UnityEngine.FogMode v; checkEnum(l, 2, out v); self.fogMode = v; return(0); } catch (Exception e) { return(error(l, e)); } }
static public int set_fogEnabled(IntPtr l) { try { FogCtrl self = (FogCtrl)checkSelf(l); System.Boolean v; checkType(l, 2, out v); self.fogEnabled = v; return(0); } catch (Exception e) { return(error(l, e)); } }
static public int set_fogEndDistance(IntPtr l) { try { FogCtrl self = (FogCtrl)checkSelf(l); System.Single v; checkType(l, 2, out v); self.fogEndDistance = v; return(0); } catch (Exception e) { return(error(l, e)); } }
public void GenerateReflectionProbes() { DayNightConfig dnc = GameObject.FindObjectOfType <DayNightConfig>(); GameObject parent = Selection.activeGameObject; if (dnc == null || parent == null) { return; } LightmapSwitcher ls = GameObject.FindObjectOfType <LightmapSwitcher>(); if (ls != null) { ls.initData(); } FogCtrl fc = GameObject.FindObjectOfType <FogCtrl>(); IgnoreFarClip[] ifcs = Resources.FindObjectsOfTypeAll <IgnoreFarClip> (); EnterBusyState("正在烘焙ReflectionProbes,请别乱动!"); curIndex = 0; string productionScenePath = EditorApplication.currentScene; string ppath = Path.GetDirectoryName(productionScenePath) + "/"; string pname = Path.GetFileNameWithoutExtension(productionScenePath); string lightmapTgtPath = ppath + pname + "/"; string[] wrps = Directory.GetFiles(lightmapTgtPath, "water_reflection_probe_*.exr"); foreach (string wrpname in wrps) { FileUtil.DeleteFileOrDirectory(wrpname); } AssetDatabase.Refresh(); actions.Clear(); actions.Add(delegate(int a) { // disable all IgnoreFarClips for (int i = 0; i < ifcs.Length; ++i) { IgnoreFarClip ifc = ifcs[i]; ifc.gameObject.isStatic = true; Renderer rdr = ifc.gameObject.GetComponent <Renderer>(); if (rdr == null) { continue; } foreach (Material m in rdr.sharedMaterials) { m.SetInt("_ifc", 0); m.DisableKeyword("IGNORE_FAR_CLIP"); } } }); for (int i = 0; i < weatherNames.Length; ++i) { // create gameobject and reflection probe actions.Add(delegate(int a) { string wname = weatherNames[curIndex]; string goname = "water_reflection_probe_" + wname; Transform probTrans = parent.transform.Find(goname); if (probTrans == null) { GameObject probGO = new GameObject(); probGO.name = goname; probGO.transform.SetParent(parent.transform, false); probTrans = probGO.transform; } ReflectionProbe rp = probTrans.GetComponent <ReflectionProbe>(); if (rp == null) { rp = probTrans.gameObject.AddComponent <ReflectionProbe>(); } rp.size = new Vector3(400, 200, 400); rp.resolution = 128; rp.nearClipPlane = 0.5f; rp.farClipPlane = 3000.0f; rp.cullingMask = ~0; rp.mode = UnityEngine.Rendering.ReflectionProbeMode.Baked; curProbe = rp; // FVWaterCubemapLoader cl = probTrans.GetComponent<FVWaterCubemapLoader>(); // if (cl == null) // { // cl = probTrans.gameObject.AddComponent<FVWaterCubemapLoader>(); // } // curLoader = cl; }); // if (Application.isPlaying) { // switch weather actions.Add(delegate(int a) { dnc.SetToWeather(curIndex); }); actions.Add(delegate(int a) { if (ls != null) { ls.DoRefresh(); } if (fc != null) { fc.DoRefresh(); } }); actions.Add(delegate(int a) { string wname = weatherNames[curIndex]; string goname = "water_reflection_probe_" + wname; string path = AssetDatabase.GenerateUniqueAssetPath(Path.Combine(lightmapTgtPath, goname + ".exr")); Lightmapping.BakeReflectionProbe(curProbe, path); curProbe.mode = UnityEngine.Rendering.ReflectionProbeMode.Custom; curProbe.customBakedTexture = UnityEditor.AssetDatabase.LoadAssetAtPath <Texture>(path); // curLoader.texPath = path; }); } actions.Add(delegate(int a) { ++curIndex; }); } actions.Add(delegate(int a) { // disable all IgnoreFarClips for (int i = 0; i < ifcs.Length; ++i) { IgnoreFarClip ifc = ifcs[i]; ifc.gameObject.isStatic = false; Renderer rdr = ifc.gameObject.GetComponent <Renderer>(); if (rdr == null) { continue; } foreach (Material m in rdr.sharedMaterials) { m.SetInt("_ifc", 1); m.EnableKeyword("IGNORE_FAR_CLIP"); } } }); actions.Add(delegate(int a) { dnc.SetToWeather(0); }); actions.Add(delegate(int a) { if (ls != null) { ls.DoRefresh(); } if (fc != null) { fc.DoRefresh(); } }); actions.Add(delegate(int a) { RefreshEditorStateDisp(); }); haltFrame = 0; }