void LateUpdate() { // if (Input.GetMouseButton(0) || m_alwaysOn) { Ray ray = Camera.main.ScreenPointToRay(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0f)); RaycastHit hitInfo = new RaycastHit(); if (m_particlesArea.GetComponent <Collider>().Raycast(ray, out hitInfo, 100)) { float fWidth = m_particlesArea.GetComponent <Renderer>().bounds.extents.x * 2f; float fRadius = (m_particlesRadius * m_particlesArea.GetWidth()) / fWidth; m_particlesArea.AddParticles(hitInfo.textureCoord, fRadius, m_particlesStrength * Time.deltaTime); } } //if (Input.GetMouseButtonDown(1)) { m_previousMousePosition = Input.mousePosition; } //if (Input.GetMouseButton(1) || m_alwaysOn) { Ray ray = Camera.main.ScreenPointToRay(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0f)); RaycastHit hitInfo = new RaycastHit(); if (m_fluid.GetComponent <Collider>().Raycast(ray, out hitInfo, 100)) { Vector3 direction = (Input.mousePosition - m_previousMousePosition + Vector3.up * 10f) * m_velocityStrength * Time.deltaTime; float fWidth = m_fluid.GetComponent <Renderer>().bounds.extents.x * 2f; float fRadius = (m_velocityRadius * m_fluid.GetWidth()) / fWidth; m_fluid.AddVelocity(hitInfo.textureCoord, direction, fRadius); } m_previousMousePosition = Input.mousePosition; } }
void LateUpdate() { if (m_particlesArea && !bdone) { //bdone = true; Ray ray = new Ray(transform.position, new Vector3(0, 0, 1)); RaycastHit hitInfo = new RaycastHit(); if (m_particlesArea.GetComponent <Collider>().Raycast(ray, out hitInfo, 10)) { float fWidth = m_particlesArea.GetComponent <Renderer>().bounds.extents.x * 2f; float fRadius = (GetRadius() * m_particlesArea.GetWidth()) / fWidth; m_particlesArea.AddParticles(hitInfo.textureCoord, fRadius, m_strength * Time.deltaTime); } } }
void LateUpdate() { for (int i = 0; i < Input.touchCount; ++i) { Touch touch = Input.GetTouch(i); Ray ray = Camera.main.ScreenPointToRay(new Vector3(touch.position.x, touch.position.y, 0f)); RaycastHit hitInfo = new RaycastHit(); if (m_particlesArea.GetComponent <Collider>().Raycast(ray, out hitInfo, 100)) { float fWidth = m_particlesArea.GetComponent <Renderer>().bounds.extents.x * 2f; float fRadius = (m_particlesRadius * m_particlesArea.GetWidth()) / fWidth; m_particlesArea.AddParticles(hitInfo.textureCoord, fRadius, m_particlesStrength * Time.deltaTime); if (touch.phase == TouchPhase.Moved) { Vector3 direction = new Vector3(touch.deltaPosition.x, touch.deltaPosition.y) * m_velocityStrength * touch.deltaTime; fWidth = m_fluid.GetComponent <Renderer>().bounds.extents.x * 2f; fRadius = (m_velocityRadius * m_fluid.GetWidth()) / fWidth; m_fluid.AddVelocity(hitInfo.textureCoord, direction, fRadius); } } } }