Skip to content

Instantly share code, notes, and snippets.

View pr00thmatic's full-sized avatar

Ruth García pr00thmatic

View GitHub Profile
RaycastHit hitInfo;
Ray worldRay = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
return Physics.Raycast(worldRay, out hitInfo);
if (Event.current.type == EventType.MouseDown) {
// el usuario hizo click en la escena!
GUIUtility.hotControl = GUIUtility.GetControlID(FocusType.Passive);
Event.current.Use();
// las dos líneas de código anteriores cancelan el evento.
}
public static GameObject SafePrefabInstantiate(GameObject reference){
return SafePrefabInstantiate(reference,Vector3.zero,Quaternion.identity);
}
public static GameObject SafePrefabInstantiate (GameObject reference,
Vector3 position,
Quaternion rotation) {
#if UNITY_EDITOR
if (Application.isPlaying) {
return GameObject.Instantiate(reference, position, rotation);
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class ThingCreator : MonoBehaviour {
public GameObject prototype;
public Transform positionIndicator;
void Update () {
if (Input.GetKeyDown(KeyCode.Space)) {
public interface IMage {
public Mage Mage { get; }
}
public static string ToggleGroup (string current, string[] options) {
foreach (string option in options) {
if (GUILayout.Toggle(current == option, option, "Button")) {
current = option;
}
}
return current;
}
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Practice : MonoBehaviour {
public float radius = 3;
public GameObject prototype;
public List<GameObject> r;
public List<GameObject> Search () {
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
[CustomEditor(typeof(Prueba))]
public class PruebaEditor : Editor {
Prueba Target { get => (Prueba) target; }
void OnSceneGUI () {
Ray rayo = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
public Vector3 ThrowBall (Vector3 origin, Vector3 destination,
float overHeight = 0.5f, bool hProportionalToDistance = true,
float maximumDistanceToCapHeight = 1) {
Vector3 force = Vector3.zero;
float distance = (Utils.SetY(0, origin) - Utils.SetY(0, destination)).magnitude;
float height = Mathf.Abs(origin.y - destination.y) + overHeight *
(hProportionalToDistance? Mathf.Max(maximumDistanceToCapHeight, distance): 1);
float gravity = Physics.gravity.magnitude;
@pr00thmatic
pr00thmatic / asdf.cs
Created May 6, 2021 15:08
SimpleJSON i keep forgetting how to use :v
using SimpleJSON;
JSONNode parsed = JSON.Parse(request.downloadHandler.text);
list.list.Add(new OnlineListData.OnlineMediaData() { url = parsed[i]["url"], title = parsed[i]["title"] });
using UnityEngine;
using UnityEngine.InputSystem;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
// jugando con el vibrador del gamepad...
// a mi me pasó que la primera vez que intenté usar el vibrador no me funcionó porque Unity dejaba de detectar mi gamepad
// de forma intermitente... uso un control de PS4 que me da montón de problemas!
// para probarlo, dale play, y mueve el stick izquierdo de tu control, debería vibrar intermitentemente...