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 System.Collections; | |
public class Bewegen : MonoBehaviour | |
{ | |
// public member eines Scripts können bequem im Unity Editor gesetzt | |
// und auch während das Spiel getestet wird verändert werden. | |
public float Geschwindigkeit; | |
public float Beschleunigung; |
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
// Objekt bewegt sich mit einer Geschwindigkeit von 10 nach rechts | |
var Geschwindigkeit = 10f; | |
var Richtung = new Vector3(1f, 0f, 0f); | |
this.transform.position += Richtung * Geschwindigkeit * Time.deltaTime; | |
// Objekt bewegt sich mit einer Geschwindigkeit von 5 nach oben und mit 10 nach hinten | |
var Geschwindigkeit = 10f; | |
var Richtung = new Vector3(0f, 0.5f, -1f); | |
this.transform.position += Richtung * Geschwindigkeit * Time.deltaTime; |
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
// Setzt die Position des script ausführenden GameObjects | |
// auf x:1, y:0, z:5 | |
this.transform.position.Set(1f, 0f, 5f); | |
// Hat den selben Effekt, nur weisen wir hier einen | |
// neuen Vector3 zu | |
this.transform.position = new Vector3(1f, 0f, 5f); | |
// Setzt das script ausführende GameObject auf die | |
// selbe Position wie anderesGameObject |
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
// Setzt die Position des script ausführenden GameObjects | |
// auf x:1, y:0, z:5 | |
this.transform.position.Set(1f, 0f, 5f); | |
// Hat den selben Effekt, nur weisen wir hier einen | |
// neuen Vector3 zu | |
this.transform.position = new Vector3(1f, 0f, 5f); |
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
const randomString = (length) => { | |
return [...Array(length)].map(() => Math.random().toString(36)[2]).join(''); | |
} | |
export default randomString; |
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 React from 'react'; | |
import useDataFetch from './useDataFetch'; | |
const app = () => { | |
const data = useDataFetch('https://jsonplaceholder.typicode.com/posts/1'); | |
const postTitle = () => { | |
if (data) { | |
return <h2>{data.title}</h2>; | |
else { |
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 { useState, useEffect } from 'react'; | |
const useDataFetch = url => { | |
const [data, setData] = useState(null); | |
useEffect(() => { | |
const loadData = async url => { | |
const response = await fetch(url); | |
const json = await response.json(); | |
setData(json); | |
}; |
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 React, { useState, useEffect } from 'react'; | |
const beispiel = () => { | |
const [count, setCount] = useState(0); | |
useEffect(() => { | |
document.title = `Du hast ${count} mal geklickt!`; | |
}); | |
return ( |
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 React, { useState } from 'react'; | |
const beispiel = () => { | |
const [count, setCount] = useState(0); | |
return ( | |
<div> | |
<p>Du hast {count} mal geklickt!</p> | |
<button onClick={() => setCount(count + 1)}> | |
Klick mich! | |
</button> |
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 { useState, useEffect } from "react"; | |
const useFetch = url => { | |
const [data, setData] = useState(null); | |
const [loading, setLoading] = useState(true); | |
useEffect(async () => { | |
const response = await fetch(url); | |
const data = await response.json(); | |
const [item] = data.results; |
NewerOlder