Skip to content

Instantly share code, notes, and snippets.

View kirevdokimov's full-sized avatar
:octocat:

Kir Evdokimov kirevdokimov

:octocat:
  • Diagnocat.com
  • Nomading, Currently in Yerevan, Armenia
View GitHub Profile
@kirevdokimov
kirevdokimov / 123
Last active August 28, 2017 13:23
456
======================================================================================================
ObjectField
var newMaterial = (Material) EditorGUILayout.ObjectField("Material", currentMaterial, typeof(Material),false);
======================================================================================================
@kirevdokimov
kirevdokimov / Generic Menu
Last active August 4, 2017 21:34
Generic Menu
if (GUILayout.Button("Select GUI Color")){
GenericMenu menu = new GenericMenu();
// GUIContent, IsOn, listener, userData
menu.AddItem(new GUIContent(menuPath), m_Color.Equals(color), OnColorSelected, color);
...
menu.AddSeparator(""); // an empty string will create a separator at the top level
menu.AddSeparator("CMYK/"); // a trailing slash will nest a separator in a submenu
menu.ShowAsContext();
}
@kirevdokimov
kirevdokimov / Right-Bottom Window on sceneView
Last active August 11, 2017 15:21
Content as camera GUI on scene
Handles.BeginGUI();
GUILayout.Window(2, new Rect(Screen.width-110, Screen.height-130, 100, 100), (id)=> {
// Content of window here
GUILayout.Button("A Button");
}, "Title");
Handles.EndGUI();
@kirevdokimov
kirevdokimov / Custom HandleCap
Created August 11, 2017 15:19
Custom Handles Unity
using UnityEditor;
using UnityEngine;
public class MyCap{
static Texture2D _mainTexture;
private static GUIContent _mainHandle;
private static GUIContent mainHandle{
using UnityEditor;
using UnityEngine;
//http://answers.unity3d.com/questions/463207/how-do-you-make-a-custom-handle-respond-to-the-mou.html
// Author http://answers.unity3d.com/users/57609/higekun.html
public class MyHandles{
public enum DragHandleResult{
none = 0,
LMBPress,
@kirevdokimov
kirevdokimov / Thumbnail
Last active August 24, 2017 15:03
Asset preview thumbnail
AssetPreview.GetAssetPreview(Object o);
@kirevdokimov
kirevdokimov / Script recompilation event
Last active August 24, 2017 10:35
Add this attribute to a method to get a notification after scripts have been reloaded. Recompile, recompilation, DidReloadScripts
[DidReloadScripts] //Add this attribute to a method to get a notification after scripts have been reloaded.
static void A(){
Debug.Log("Hello");
}
public class ToolBarWindow : EditorWindow{
private static Texture image;
[MenuItem("Window/TestChamber/ToolBar")]
public static void Init(){
b();
GetWindow<ToolBarWindow>().Show();
}
private void OnGUI(){DrawToolbar();}
@kirevdokimov
kirevdokimov / correct
Last active October 7, 2017 17:08
mongo
mongod.exe --dbpath=M:\Dev\Database\Mongo\db\ --install --logpath=M:\Dev\Database\Mongo\logs\mongo.log --smallfiles
net start MongoDB
@kirevdokimov
kirevdokimov / no.cs
Created February 4, 2018 19:00
Get mouse position z = 0
public static Vector3 GetWorldPointFromMouse(bool plane = true, float planeLevel = 0)
{
var groundPlane = new Plane(Vector3.up, new Vector3(0, planeLevel, 0));
var ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
RaycastHit rayHit;
Vector3 hit = new Vector3();
float dist;
if(plane)