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
public Vector3 MouseToWorldPoint(Camera cam, float distance) | |
{ | |
var m = Input.mousePosition; | |
m.z = distance; | |
return cam.ScreenToWorldPoint(m); | |
} |
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
public bool CheckMouseHitObjectByTag(Camera cam, string tag) | |
{ | |
Ray ray = cam.ScreenPointToRay(Input.mousePosition); | |
RaycastHit hit; | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (tag == hit.collider.tag) | |
{ | |
return true; | |
} |
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 ParticleAutoDestroy : MonoBehaviour | |
{ | |
private ParticleSystem ps; | |
void Start() | |
{ | |
ps = GetComponent<ParticleSystem>(); |
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; |
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 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 { 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 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
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
// 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); |
OlderNewer