public virtual void Start() { //for changing direction on click playerDirectional = gameObject.GetComponent <Rotatable>(); playerMove = GetComponent <PlayerMove>(); lightingSystem = Camera.main.GetComponent <LightingSystem>(); }
private void Start() { lightingSystem = Camera.main.GetComponent <LightingSystem>(); //cache all known usages of the RightClickMethod annotation attributedTypes = GetRightClickAttributedMethods(); }
private void Start() { //for changing direction on click playerDirectional = gameObject.GetComponent <Directional>(); playerMove = GetComponent <PlayerMove>(); lightingSystem = Camera.main.GetComponent <LightingSystem>(); }
void Awake() { layerMask = LayerMask.GetMask("Furniture", "Machines", "Unshootable Machines", "Items", "Objects"); escapeKeyTarget = GetComponent <EscapeKeyTarget>(); lightingSystem = Camera.main.GetComponent <LightingSystem>(); ToState(State.SELECTING); }
private void Awake() { if (followControl == null) { followControl = this; cam = GetComponent <Camera>(); lightingSystem = GetComponent <LightingSystem>(); } else { Destroy(gameObject); } }
private void Start() { //for changing direction on click playerDirectional = gameObject.GetComponent <Directional>(); playerMove = GetComponent <PlayerMove>(); objectBehaviour = GetComponent <ObjectBehaviour>(); lightingSystem = Camera.main.GetComponent <LightingSystem>(); //Do not include the Default layer! Assign your object to one of the layers below: layerMask = LayerMask.GetMask("Furniture", "Walls", "Windows", "Machines", "Unshootable Machines", "Players", "Items", "Door Open", "Door Closed", "WallMounts", "HiddenWalls", "Objects", "Matrix", "Floor"); }
void Start() { mouseDrops = GetComponents <IBaseInteractable <MouseDrop> >(); shadowPrefab = Resources.Load <GameObject>("MouseDragShadow"); if (shadow == null) { shadow = GetComponentInChildren <SpriteRenderer>()?.sprite; if (shadow == null) { Logger.LogWarning("No drag shadow sprite was set and no sprite renderer found for " + name + " so there will be no drag shadow for this object."); } } lightingSystem = Camera.main.GetComponent <LightingSystem>(); }
private void OnGUI() { if (FindObjectOfType <LightingSystem>()) { GUILayout.Label("WARNING: existing lighting system is found.\nIt is recommended to remove it first, before adding new one.", EditorStyles.boldLabel); } GUILayout.Label("Select layers you wish to use. You could modify them later in created object."); _lightObstaclesLayer = EditorGUILayout.LayerField("Light Obstacles", _lightObstaclesLayer); _lightSourcesLayer = EditorGUILayout.LayerField("Light Sources", _lightSourcesLayer); _ambientLightLayer = EditorGUILayout.LayerField("Ambient Light", _ambientLightLayer); if (GUILayout.Button("Create")) { Camera mainCamera = Camera.main; LightingSystem lighingSystem = mainCamera.GetComponent <LightingSystem>() ?? mainCamera.gameObject.AddComponent <LightingSystem>(); GameObject prefab = Resources.Load <GameObject>("Lighting Camera"); GameObject lightingSystemObj = Instantiate(prefab); lightingSystemObj.name = lightingSystemObj.name.Replace("(Clone)", ""); lightingSystemObj.transform.parent = mainCamera.transform; lightingSystemObj.transform.localPosition = Vector3.zero; lightingSystemObj.transform.localScale = Vector3.one; lightingSystemObj.transform.localRotation = Quaternion.identity; LightingSystemPrefabConfig config = lightingSystemObj.GetComponent <LightingSystemPrefabConfig>(); lighingSystem.LightCamera = lightingSystemObj.GetComponent <Camera>(); lighingSystem.AmbientLightComputeMaterial = config.AmbientLightComputeMaterial; lighingSystem.LightOverlayMaterial = config.LightOverlayMaterial; lighingSystem.AmbientLightBlurMaterial = lighingSystem.LightSourcesBlurMaterial = config.BlurMaterial; DestroyImmediate(config); lighingSystem.LightCamera.depth = mainCamera.depth - 1; lighingSystem.LightCamera.cullingMask = 1 << _lightSourcesLayer; lighingSystem.LightSourcesLayer = _lightSourcesLayer; lighingSystem.AmbientLightLayer = _ambientLightLayer; lighingSystem.LightObstaclesLayer = _lightObstaclesLayer; mainCamera.cullingMask &= ~((1 << _lightSourcesLayer) | (1 << _ambientLightLayer) | (1 << _lightObstaclesLayer)); Close(); } }
/// <summary> /// Updates the transform's position to be filtered / clamped. Invoke this when transform position changes to ensure /// it wil. /// </summary> /// <param name="toClamp">transform whose position should be filtered</param> /// <param name="curPosition">unfiltered position of the transform</param> /// <param name="flyingDirection">current flying direction</param> public void FilterPosition(Transform toClamp, Vector3 curPosition, Orientation flyingDirection) { Vector2 filteredPos = LightingSystem.GetPixelPerfectPosition(curPosition, mPreviousPosition, mPreviousFilteredPosition); //pixel perfect position can induce lateral movement at the beginning of motion, so we must prevent that if (flyingDirection == Orientation.Right || flyingDirection == Orientation.Left) { filteredPos.y = (float)Math.Round(filteredPos.y); } else { filteredPos.x = (float)Math.Round(filteredPos.x); } toClamp.position = filteredPos; mPreviousPosition = curPosition; mPreviousFilteredPosition = toClamp.position; }
private void OnEnable() { escapeKeyTarget = GetComponent <EscapeKeyTarget>(); lightingSystem = Camera.main.GetComponent <LightingSystem>(); }
private void OnEnable() { escapeKeyTarget = GetComponent <EscapeKeyTarget>(); lightingSystem = Camera.main.GetComponent <LightingSystem>(); UpdateManager.Add(CallbackType.UPDATE, UpdateMe); }
public override void OnInspectorGUI() { // Update the serializedProperty - always do this in the beginning of OnInspectorGUI. serializedObject.Update(); if (Application.isPlaying) { GUI.enabled = false; } LightingSystem lightingSystem = (LightingSystem)target; Camera cam = lightingSystem.GetComponent <Camera>(); bool isMobileTarget = EditorUserBuildSettings.activeBuildTarget == BuildTarget.iOS || EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android; if (cam == null) { EditorGUILayout.LabelField("WARNING: No attached camera found."); } EditorGUILayout.PropertyField(_lightPixelSize, new GUIContent("Light Pixel Size")); bool sizeChanged = false; #if LIGHT2D_2DTK var tk2dCamera = lightingSystem.GetComponent <tk2dCamera>(); var tk2dCamSize = tk2dCamera == null ? (cam == null ? 0 : cam.orthographicSize) : tk2dCamera.ScreenExtents.yMax; var currSizeChanged = !Mathf.Approximately(tk2dCamSize, _old2dtkCamSize); _old2dtkCamSize = tk2dCamSize; if (currSizeChanged) { _sizeChangeTime = DateTime.Now; } sizeChanged = (DateTime.Now - _sizeChangeTime).TotalSeconds < 0.2f; #endif if (cam != null) { float size; if (cam.orthographic) { #if LIGHT2D_2DTK float zoom = (tk2dCamera == null ? 1 : tk2dCamera.ZoomFactor); size = (cam.orthographicSize * zoom + _lightCameraSizeAdd.floatValue) * 2f; #else size = (cam.orthographicSize + _lightCameraSizeAdd.floatValue) * 2f; #endif } else { float halfFov = (cam.fieldOfView + _lightCameraFovAdd.floatValue) * Mathf.Deg2Rad / 2f; size = Mathf.Tan(halfFov) * _lightObstaclesDistance.floatValue * 2; } if (!Application.isPlaying) { int lightTextureHeight = Mathf.RoundToInt(size / _lightPixelSize.floatValue); int oldSize = lightTextureHeight; lightTextureHeight = EditorGUILayout.IntField("Light Texture Height", lightTextureHeight); if (lightTextureHeight % 2 != 0) { lightTextureHeight++; } if (lightTextureHeight < 16) { if (lightTextureHeight < 8) { lightTextureHeight = 8; } EditorGUILayout.LabelField("WARNING: Light Texture Height is too small."); EditorGUILayout.LabelField(" 50-200 (mobile) and 200-1000 (pc) is recommended."); } if (lightTextureHeight > (isMobileTarget ? 200 : 1000)) { if (lightTextureHeight > 2048) { lightTextureHeight = 2048; } EditorGUILayout.LabelField("WARNING: Light Texture Height is too big."); EditorGUILayout.LabelField(" 50-200 (mobile) and 200-1000 (pc) is recommended."); } if (oldSize != lightTextureHeight && !sizeChanged) { _lightPixelSize.floatValue = size / lightTextureHeight; } } } if (cam == null || cam.orthographic) { EditorGUILayout.PropertyField(_lightCameraSizeAdd, new GUIContent("Light Camera Size Add")); } else { EditorGUILayout.PropertyField(_lightCameraFovAdd, new GUIContent("Light Camera Fov Add")); EditorGUILayout.PropertyField(_lightObstaclesDistance, new GUIContent("Camera To Light Obstacles Distance")); } EditorGUILayout.PropertyField(_hdr, new GUIContent("64 Bit Color")); EditorGUILayout.PropertyField(_lightObstaclesAntialiasing, new GUIContent("Light Obstacles Antialiasing")); EditorGUILayout.PropertyField(_enableNormalMapping, new GUIContent("Normal Mapping")); if (_enableNormalMapping.boolValue && isMobileTarget) { EditorGUILayout.LabelField("WARNING: Normal mapping is not supported on mobiles."); } EditorGUILayout.PropertyField(_affectOnlyThisCamera, new GUIContent("Affect Only This Camera")); _lightTexturesFilterMode.enumValueIndex = (int)(FilterMode)EditorGUILayout.EnumPopup("Texture Filtering", (FilterMode)_lightTexturesFilterMode.enumValueIndex); EditorGUILayout.PropertyField(_blurLightSources, new GUIContent("Blur Light Sources")); if (_blurLightSources.boolValue && _enableNormalMapping.boolValue) { EditorGUILayout.LabelField(" Blurring light sources with normal mapping enabled\n"); EditorGUILayout.LabelField(" could significantly reduce lighting quality."); } bool normalGuiEnableState = GUI.enabled; if (!_blurLightSources.boolValue) { GUI.enabled = false; } EditorGUILayout.PropertyField(_lightSourcesBlurMaterial, new GUIContent(" Light Sources Blur Material")); GUI.enabled = normalGuiEnableState; EditorGUILayout.PropertyField(_enableAmbientLight, new GUIContent("Enable Ambient Light")); if (!_enableAmbientLight.boolValue) { GUI.enabled = false; } EditorGUILayout.PropertyField(_blurAmbientLight, new GUIContent(" Blur Ambient Light")); bool oldEnabled = GUI.enabled; if (!_blurAmbientLight.boolValue) { GUI.enabled = false; } EditorGUILayout.PropertyField(_ambientLightBlurMaterial, new GUIContent(" Ambient Light Blur Material")); GUI.enabled = oldEnabled; EditorGUILayout.PropertyField(_ambientLightComputeMaterial, new GUIContent(" Ambient Light Compute Material")); GUI.enabled = normalGuiEnableState; EditorGUILayout.PropertyField(_lightOverlayMaterial, new GUIContent("Light Overlay Material")); EditorGUILayout.PropertyField(_lightCamera, new GUIContent("Lighting Camera")); EditorGUILayout.PropertyField(_BgCamera, new GUIContent("BG Camera")); _lightSourcesLayer.intValue = EditorGUILayout.LayerField(new GUIContent("Light Sources Layer"), _lightSourcesLayer.intValue); _lightObstaclesLayer.intValue = EditorGUILayout.LayerField(new GUIContent("Light Obstacles Layer"), _lightObstaclesLayer.intValue); _ambientLightLayer.intValue = EditorGUILayout.LayerField(new GUIContent("Ambient Light Layer"), _ambientLightLayer.intValue); // Apply changes to the serializedProperty - always do this in the end of OnInspectorGUI. serializedObject.ApplyModifiedProperties(); }
private void OnEnable() { lightingSystem = Camera.main.GetComponent <LightingSystem>(); }
private void Start() { lightingSystem = Camera.main.GetComponent <LightingSystem>(); }
/// <summary> /// Be careful when you use this. /// </summary> public static void OnGDMCreation(Effect shader, Texture2D texture) { #if DEBUG vertices = new VertexPositionColor[6]; vertices[0] = new VertexPositionColor(new Vector3(0, 0, 0), Color.Red); vertices[1] = new VertexPositionColor(new Vector3(10000, 0, 0), Color.Red); vertices[2] = new VertexPositionColor(new Vector3(0, 0, 0), Color.Green); vertices[3] = new VertexPositionColor(new Vector3(0, 10000, 0), Color.Green); vertices[4] = new VertexPositionColor(new Vector3(0, 0, 0), Color.Blue); vertices[5] = new VertexPositionColor(new Vector3(0, 0, 10000), Color.Blue); xyz = new BasicEffect(GraphicsDevice); vertexBuff = new VertexBuffer(GraphicsDevice, VertexPositionColor.VertexDeclaration, vertices.Length, BufferUsage.None); #endif lights = new LightingSystem(shader, texture); SpriteBatch = new SpriteBatch(GraphicsDevice); //untexturedModels.Clear(); texturedModels.Clear(); shaderModels.Clear(); glassModels.Clear(); masterDict.Clear(); if(Resources.boxModel != null) { Box b = new Box(Vector3.Zero); // necessary because otherwise it looks for the current level's Add(b); RemovePermanent(b); // this gets the box model in the masterDict for the spinning saving box } primitives.Clear(); onGDMReset(new object(), EventArgs.Empty); if(manager != null) manager.DestroyAndRemoveAllParticleSystems(); if(GameManager.CurrentLevel != null) GameManager.CurrentLevel.AddModels(); }
void Awake() { layerMask = LayerMask.GetMask("Furniture", "Machines", "Unshootable Machines", "Items", "Objects"); lightingSystem = Camera.main.GetComponent <LightingSystem>(); }
void Awake() { escapeKeyTarget = GetComponent <EscapeKeyTarget>(); lightingSystem = Camera.main.GetComponent <LightingSystem>(); ToState(State.SELECTING); }
private void OnEnable() { _instance = this; _camera = GetComponent <Camera>(); }