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 Bewegen : MonoBehaviour | |
{ | |
// public member eines Scripts können bequem | |
// im Unity Editor gesetzt und auch während | |
// das Spiel getestet wird verändert werden. | |
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 CameraFollowObject : MonoBehaviour | |
{ | |
public Transform TargetObject; | |
public float MoveSmoothTime = 0.3F; | |
public float RotationSpeed = 6f; | |
public Vector3 Offset = new Vector3(0f, 15f, 0f); |
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 { |
OlderNewer