This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| blueprint: | |
| name: NRGkick solar surplus charging | |
| description: >- | |
| Charges your car with solar power that would otherwise be exported to the | |
| grid. The NRGkick charging current follows the available surplus. Charging | |
| uses 1 phase, 3 phases, or switches between them automatically, and pauses | |
| when the surplus is too small. Phase changes and pauses only happen after | |
| they have been needed for a while. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Disable instantiated prefabs that are no longer being actively tracked | |
| foreach (var trackedImage in eventArgs.updated) { | |
| _instantiatedPrefabs[trackedImage.referenceImage.name] | |
| .SetActive(trackedImage.trackingState == TrackingState.Tracking); | |
| } | |
| // Remove is called if the subsystem has given up looking for the trackable again. | |
| // (If it's invisible, its tracking state would just go to limited initially). | |
| // Note: ARCore doesn't seem to remove these at all; if it does, it would delete our child GameObject | |
| // as well. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private void OnTrackedImagesChanged(ARTrackedImagesChangedEventArgs eventArgs) | |
| { | |
| // Go through all tracked images that have been added | |
| // (-> new markers detected) | |
| foreach (var trackedImage in eventArgs.added) | |
| { | |
| // Get the name of the reference image to search for the corresponding prefab | |
| var imageName = trackedImage.referenceImage.name; | |
| foreach (var curPrefab in ArPrefabs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ARAnchor CreateAnchor(in ARRaycastHit hit) | |
| { | |
| ARAnchor anchor; | |
| // ... here, we'll place the plane anchoring code! | |
| // If we hit a plane, try to "attach" the anchor to the plane | |
| if (hit.trackable is ARPlane plane) | |
| { | |
| var planeManager = GetComponent<ARPlaneManager>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ARAnchor CreateAnchor(in ARRaycastHit hit) | |
| { | |
| ARAnchor anchor; | |
| // ... here, we'll place the plane anchoring code! | |
| // Otherwise, just create a regular anchor at the hit pose | |
| // Note: the anchor can be anywhere in the scene hierarchy | |
| var instantiatedObject = Instantiate(_prefabToPlace, hit.pose.position, hit.pose.rotation); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void Update() | |
| { | |
| // Only consider single-finger touches that are beginning | |
| Touch touch; | |
| if (Input.touchCount < 1 || (touch = Input.GetTouch(0)).phase != TouchPhase.Began) { return; } | |
| // Perform AR raycast to any kind of trackable | |
| if (_raycastManager.Raycast(touch.position, Hits, TrackableType.AllTypes)) | |
| { | |
| // Raycast hits are sorted by distance, so the first one will be the closest hit. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ARPlaceHologram : MonoBehaviour | |
| { | |
| // The prefab to instantiate on touch. | |
| [SerializeField] | |
| private GameObject _prefabToPlace; | |
| // Cache ARRaycastManager GameObject from ARCoreSession | |
| private ARRaycastManager _raycastManager; | |
| // List for raycast hits is re-used by raycast manager |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| using UnityEngine.XR.ARFoundation; | |
| public class PointCloudInfo : MonoBehaviour | |
| { | |
| // The AR Foundation PointCloud script | |
| private ARPointCloud _pointCloud; | |
| // Reference to logging UI element in the canvas | |
| public UnityEngine.UI.Text Log; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Define number of choices available. | |
| // Generated options: 0.. < num_max | |
| const num_max = 5; | |
| // Randomize array in-place using Durstenfeld shuffle algorithm | |
| // Based on: https://stackoverflow.com/questions/2450954/how-to-randomize-shuffle-a-javascript-array | |
| function shuffleArray(array) { | |
| for (var i = array.length - 1; i > 0; i--) { | |
| var j = Math.floor(Math.random() * (i + 1)); | |
| var temp = array[i]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Get the aspect ratio for the current texture. | |
| var textureAspectRatio = (float)texture.width / texture.height; | |
| // Determine the raw image rectSize preserving the texture aspect ratio, matching the screen orientation, | |
| // and keeping a minimum dimension size. | |
| const float minDimension = 480.0f; | |
| var maxDimension = Mathf.Round(minDimension * textureAspectRatio); | |
| var rectSize = new Vector2(maxDimension, minDimension); | |
| //var rectSize = new Vector2(minDimension, maxDimension); //Portrait | |
| rawImage.rectTransform.sizeDelta = rectSize; |
NewerOlder