Skip to content

Instantly share code, notes, and snippets.

View Logarithmusregel
# Beweis Logarithmusregel
## Logarithmisch Differenzieren
**zz:** $ log_a(x) = \frac 1{x * ln(a)} $
### teil 1:
##### sonderfall $ a = e $ → $ log_a = ln $
**zz:** $ ln(x) = \frac1x$
$$ e^{ln(x)} = x \ \ | \frac d{dx}$$
@soraphis
soraphis / arctan
Created Feb 16, 2014
arctan differenzieren
View arctan
## Arkustangenz ableiten
$ f(x) = tan(x) $ und $ \bar f = arctan(x)$
$$ f(\bar f(x)) = x$$
$$ \frac{\delta f(\bar f(x))}{\delta x} = \frac{\delta x}{\delta x} $$
$$ \frac{\delta tan(arctan(x))}{\delta x} = \frac{\delta x}{\delta x} $$
@soraphis
soraphis / PositionHandleEditor.cs
Created Apr 1, 2016
Unity3D Handles by Propertydrawer
View PositionHandleEditor.cs
#if UNITY_EDITOR
namespace Editor {
using UnityEditor;
[CustomEditor(typeof(MonoBehaviour), true, isFallback = true)]
public class PositionHandleEditor : UnityEditor.Editor {
void OnSceneGUI() {
var t = target as MonoBehaviour;
if(t == null) return;
@soraphis
soraphis / CamerFadeScript.cs
Last active Mar 13, 2018
Implementation of an CameraFadeScript for Unity 5 with Code only, no gameobjects or ui elements needed. (There has to be a main camera in the scene :P)
View CamerFadeScript.cs
using System.Collections;
using UnityEngine;
// does need UnityStandardAssets > ImageEffects
// does not work if you use the ImageEffect "ScreenOverlay" on your camera for visual effects
// Usage:
// From a MonoBehaviour-Class: StartCoroutine(CameraFade.FadeOut(0.8f));
// From inside a coroutine (if you want to wait for finished fading): yield return CameraFade.FadeOut(0.5f);
// From inside a coroutine (if you dont want to wait): CameraFade.FadeOut(0.5f);
@soraphis
soraphis / MatrixLoop.cs
Last active Apr 17, 2016
Three equivalent ways to loop over an 2D array. the second one has less indentation.
View MatrixLoop.cs
/*
watching this video: https://unity3d.com/learn/tutorials/modules/advanced/scripting/procedural-cave-generation-pt1
made me scream because of this much copy-and-paste the nested-loop thing
so here are a few workarounds:
*/
int width = 3, height = 2;
int[,] fields = new int[height, width]; // (m x n)-matrix
// ---------------------
View League of Legends Healthbar-System
using UnityEngine;
public class HealthBarRenderer : MonoBehaviour {
/// <summary>
/// This attributes should be read from a unit's Health-Component
/// </summary>
[Header("Health Attributes")]
public int Health;
public int PhysicalShield;
public int MagicalShield;
@soraphis
soraphis / MultiTransformClipboard.cs
Created Jul 30, 2016
Unity Script to be able to copy multiple transform components in edito mode (preview here: https://sendvid.com/w7i0jddd)
View MultiTransformClipboard.cs
using UnityEngine;
using System.Collections.Generic;
using UnityEditor;
[InitializeOnLoad]
public class MultiTransformClipboard {
const string ComponentName = "Transform";
static MultiTransformClipboard()
@soraphis
soraphis / ClickWordInTextTest.cs
Created Aug 8, 2016
Test Unity script to handle clicks on specific words in UI-Text components
View ClickWordInTextTest.cs
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace DefaultNamespace {
public class ClickWordInTextTest : MonoBehaviour, IPointerClickHandler{
public Text TheTextComponent; // filled in the inspector or somewhere else
@soraphis
soraphis / AdditionalTextAttribute.cs
Last active Sep 20, 2017
A small editor extension to add additional text informations into the Inspectors TextFields
View AdditionalTextAttribute.cs
using UnityEngine;
namespace Assets.Soraphis.MiniScripts {
public class AdditionalTextAttribute : PropertyAttribute {
public readonly string Text;
public AdditionalTextAttribute(string text) {
Text = text;
}
}
@soraphis
soraphis / PhysicsDisposable.cs
Last active Aug 16, 2016
Reduces code clutter when using sphere casts or raycasts when the actual object should be ignored
View PhysicsDisposable.cs
/// <summary>
/// This class uses the decorator pattern and the Idisposable interface to allow a cleaner usage of raycast/spherecasts
/// or other physic quarrys, which should not hit the gameobject
/// </summary>
class PhysicsDisposable : IDisposable {
private static Stack<PhysicsDisposable> Pool = new Stack<PhysicsDisposable>(4);
private List<Collider> colliders = new List<Collider>(2);
private List<int> originalLayer;