protected virtual void Update() { // Main camera exists? var mainCamera = Camera.main; if (mainCamera != null) { // World position of the mouse var position = D2dHelper.ScreenToWorldPosition(Input.mousePosition, Intercept, mainCamera); // Begin dragging if (Input.GetKey(Requires) == true && down == false) { down = true; } // End dragging if (Input.GetKey(Requires) == false && down == true) { down = false; // Stamp everything at this point? if (Hit == HitType.All) { D2dStamp.All(Paint, position, Size, Angle, Shape, Color, Layers); } // Stamp the first thing at this point? if (Hit == HitType.First) { var destructible = default(D2dDestructible); if (D2dDestructible.TrySampleThrough(position, ref destructible) == true) { destructible.Paint(Paint, D2dStamp.CalculateMatrix(position, Size, Angle), Shape, Color); } } } // Update indicator? if (down == true && IndicatorPrefab != null) { if (indicatorInstance == null) { indicatorInstance = Instantiate(IndicatorPrefab); indicatorScale = indicatorInstance.transform.localScale; indicatorInstance.SetActive(true); } indicatorInstance.transform.position = position; indicatorInstance.transform.localScale = Vector3.Scale(indicatorScale, new Vector3(Size.x, Size.y, 1.0f)); } // Destroy indicator? else if (indicatorInstance != null) { Destroy(indicatorInstance.gameObject); } } }
protected virtual void Update() { // Update input inputManager.Update(Requires); // Make sure the camera exists var camera = D2dHelper.GetCamera(null); if (camera != null) { // Loop through all non-gui fingers foreach (var finger in inputManager.Fingers) { if (finger.StartedOverGui == false) { // Grab extra finger data and position var link = D2dInputManager.Link.FindOrCreate(ref links, finger); var position = D2dHelper.ScreenToWorldPosition(finger.PositionA, Intercept, camera); // Create indiactor? if (finger.Down == true && IndicatorPrefab != null) { link.Visual = Instantiate(IndicatorPrefab); link.Scale = link.Visual.transform.localScale; link.Visual.SetActive(true); } // Update indicator? if (finger.Set == true && link.Visual != null) { link.Visual.transform.position = position; link.Visual.transform.localScale = Vector3.Scale(link.Scale, new Vector3(Size.x, Size.y, 1.0f)); } // Clear indicator then stamp? if (finger.Up == true) { // Stamp everything at this point? if (Hit == HitType.All) { D2dStamp.All(Paint, position, Size, Angle, Shape, Color, Layers); } // Stamp the first thing at this point? if (Hit == HitType.First) { var destructible = default(D2dDestructible); if (D2dDestructible.TrySampleThrough(position, ref destructible) == true) { destructible.Paint(Paint, D2dStamp.CalculateMatrix(position, Size, Angle), Shape, Color); } } // Destroy indicator link.Clear(); } } } } }