Skip to content

Instantly share code, notes, and snippets.

Kamen Dimitrov kamend

Block or report user

Report or block kamend

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kamend
kamend / WorldToCanvasPosition.cs
Created Mar 10, 2017
Position a UI element based on a World Position
View WorldToCanvasPosition.cs
Vector2 screenPos = camera.WorldToViewportPoint( worldPosition );
screenPos.x *= guiCanvas.rect.width;
screenPos.y *= guiCanvas.rect.height;
// the element should be anchored bottom/left
uiElement.anchoredPosition = screenPos;
@kamend
kamend / FlatSubdivide.js
Created Jul 23, 2016
THREE.js Flat Triangle Subdivide
View FlatSubdivide.js
// Triangle Subdivision based on http://wiki.unity3d.com/index.php?title=MeshHelper
// There is not smoothing of any sort, it will just divide the triangles
// hence the FlatSubdivide name
THREE.FlatSubdivide = function () {
};
// Applies the "modify" pattern
@kamend
kamend / AssetPathAttribute.cs
Created Nov 3, 2015
A custom attribute to easily link prefab's paths instead of linking directly the prefab itself, especially useful inside scriptable objects and if you don't want Unity to load all the prefabs' resources as soon as the Scriptable Object loads.
View AssetPathAttribute.cs
using UnityEngine;
using System;
using System.Collections;
public class AssetPathAttribute : PropertyAttribute {
System.Type type;
string label;
public bool isResource;
public AssetPathAttribute(string l, System.Type t, bool isR) {
@kamend
kamend / RaycastCollisionDetection.cs
Created Sep 27, 2015 — forked from NickDiMucci/RaycastCollisionDetection.cs
Raycast collision detection in Unity from a box collider, with diagonal raycasts from the corners to guard against corner collisions.
View RaycastCollisionDetection.cs
using com.mindshaft.overtime.collision;
using UnityEngine;
namespace com.mindshaft.overtime.physics {
public class RaycastCollisionDetection : IEntityCollisionDetection {
private BoxCollider _collider;
private Rect _collisionRect;
private LayerMask _collisionMask;
private LayerMask _playerMask;
@kamend
kamend / AssetProcessing.cs
Last active Aug 8, 2016
Unity: An example how to set different Texture options based on the import directory. Copy this in the Editor folder.
View AssetProcessing.cs
using UnityEngine;
using UnityEditor;
public enum TextureType {
NONE = -1,
GUI = 0,
CHARACTERS = 1
}
public class AssetProcessing : AssetPostprocessor {
View PointerInputModule.cs
using System.Collections.Generic;
using System.Text;
namespace UnityEngine.EventSystems
{
public abstract class PointerInputModule : BaseInputModule
{
public const int kMouseId = -1;
public const int kFakeTouchesId = -2;
View CustomEvents.cs
using System;
using System.Collections.Generic;
using UnityEngine.Events;
// interface you implement in your MB to receive events
public interface ICustomHandler : IEventSystemHandler
{
void OnCustomCode(CustomEventData eventData);
}
View CoroutineData.cs
//#define DEBUG_THREADING
using UnityEngine;
using System.Collections;
using System.Threading;
using System.Reflection;
public delegate IEnumerator MonitorCoroutine<T> (CoroutineData<T> data);
@kamend
kamend / Image2Tumblr.cs
Created May 24, 2014
How post an image to Tumblr via their V2 API, inside Unity
View Image2Tumblr.cs
using UnityEngine;
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Globalization;
using System.Security.Cryptography;
using System.IO;
View gist:11256148
// Adjust dSYM generation
var xcodeProjectPath = Path.Combine(xcodeProjectDir, "Unity-iPhone.xcodeproj");
var pbxPath = Path.Combine(xcodeProjectPath, "project.pbxproj");
var sb = new System.Text.StringBuilder();
var xcodeProjectLines = File.ReadAllLines(pbxPath);
foreach (var line in xcodeProjectLines)
{
// Remove from OTHER_LDFLAGS
You can’t perform that action at this time.