void Start() { LIGHRecord LIGH = (LIGHRecord)record; lightData = new LightData(); lightData.lightComponent = gameObject.GetComponentInChildren <Light>(true); if (LIGH.FNAM != null) { objData.name = LIGH.FNAM.value; } objData.interactionPrefix = "Take "; if (LIGH.LHDT != null) { lightData.flags = LIGH.LHDT.flags; if (Utils.ContainsBitFlags((uint)lightData.flags, (uint)LightData.LightFlags.CanCarry)) { gameObject.AddComponent <BoxCollider>().size *= 0.5f; //very weak-- adding a box collider to light objects so we can interact with them //adding kinematic rigidbodies to static colliders prevents the physics collision tree from being rebuilt, which impacts performance if (TESUnity.instance.useKinematicRigidbodies) { gameObject.AddComponent <Rigidbody>().isKinematic = true; } } StartCoroutine(ConfigureLightComponent()); } }
private GameObject InstantiateLight(LIGHRecord LIGH, bool indoors) { var lightObj = new GameObject("Light"); var lightComponent = lightObj.AddComponent <Light>(); lightComponent.range = 3 * (LIGH.LHDT.radius / Convert.meterInMWUnits); lightComponent.color = new Color32(LIGH.LHDT.red, LIGH.LHDT.green, LIGH.LHDT.blue, 255); lightComponent.intensity = 1.5f; lightComponent.bounceIntensity = 0f; lightComponent.shadows = TESUnity.instance.renderLightShadows ? LightShadows.Soft : LightShadows.None; if (!indoors && !TESUnity.instance.renderExteriorCellLights) // disabling exterior cell lights because there is no day/night cycle { lightComponent.enabled = false; } return(lightObj); }
GameObject InstantiateLight(LIGHRecord LIGH, bool indoors) { var lightObj = new GameObject("Light") { isStatic = true }; var lightComponent = lightObj.AddComponent <Light>(); lightComponent.range = 3 * (LIGH.DATA.Radius / ConvertUtils.MeterInUnits); lightComponent.color = LIGH.DATA.LightColor.ToColor32(); lightComponent.intensity = 1.5f; lightComponent.bounceIntensity = 0f; lightComponent.shadows = RenderLightShadows ? LightShadows.Soft : LightShadows.None; if (!indoors && !RenderExteriorCellLights) // disabling exterior cell lights because there is no day/night cycle { lightComponent.enabled = false; } return(lightObj); }