This file contains 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
import SwiftUI | |
import CoreMotion | |
// Main View | |
struct AppleLogoWithRgbOffset: View { | |
// Initiate and pass a motion manager instance as | |
// an enviromental dependency when you initilize this view | |
@EnvironmentObject var motion: MotionManager | |
This file contains 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
// An object that is serialized and saved as a sketchInfo.json in a sketch folder | |
[Serializable] | |
public class SketchInfo | |
{ | |
public string sketchName; | |
public string dateCreated; | |
public string sketchID; | |
public Vector3 parentPosition; // Position of the container where boxels live. | |
public Quaternion parentRotation; // Rotation of the container where boxels live. | |
public string appVersion; |
This file contains 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 System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class Planet : MonoBehaviour | |
{ | |
[SerializeField] List<Color> colors; | |
[SerializeField] MeshRenderer meshRenderer; | |
[SerializeField] Vector2 scaleRange; | |
This file contains 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 System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using Random = UnityEngine.Random; | |
public class PlanetSpawner : MonoBehaviour | |
{ | |
[SerializeField] List<GameObject> planets; | |
[SerializeField] Vector3 spawnVolume; |
This file contains 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
import SwiftUI | |
import PlaygroundSupport | |
struct MyExperimentalView: View | |
{ | |
@State private var count: Int = 10 | |
var body: some View | |
{ | |
Text("Count: \(count)") |
This file contains 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; | |
public static class ExtensionMethods | |
{ | |
public static float Remap (this float from, float fromMin, float fromMax, float toMin, float toMax) | |
{ | |
float fromAbs = from - fromMin; | |
float fromMaxAbs = fromMax - fromMin; | |
float normal = fromAbs / fromMaxAbs; | |
float toMaxAbs = toMax - toMin; |
This file contains 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
namespace ExtensionMethods | |
{ | |
public static class MyExtensions | |
{ | |
public static void Next(this ref MyEnum item) | |
{ | |
int count = Enum.GetNames(typeof(MyEnum)).Length; | |
int index = item.GetHashCode(); | |
int nextIndex = index + 1; | |
if (nextIndex >= count) nextIndex = 0; |
This file contains 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.UI; | |
public class ToggleColorManager : MonoBehaviour | |
{ | |
[Header("Elements")] | |
public Toggle toggle; | |
public Image icon; | |
[Space(16)] |
This file contains 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
Number(thisComp.layer("CounterController").effect("Slider Control")("Slider")).toFixed(1) | |
// 2.0 |
This file contains 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
// Vectors | |
Debug.Log(Vector3.forward); // (0, 0, 1.0) | |
Debug.Log(Vector3.right); // (1.0, 0, 0) | |
Debug.Log(Vector3.up); // (0, 1.0, 0) | |
// Rotation toward a direction | |
// https://answers.unity.com/questions/803365/make-the-player-face-his-movement-direction.html | |
float moveHorizontal = Input.GetAxisRaw ("Horizontal"); | |
float moveVertical = Input.GetAxisRaw ("Vertical"); |
NewerOlder