*
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
[CustomEditor(typeof(AdvancedPhysicsMaterial))]
|
||||
[CanEditMultipleObjects]
|
||||
public class AdvancedPhysicsMaterialEditor : Editor {
|
||||
public override void OnInspectorGUI(){
|
||||
AdvancedPhysicsMaterial mat = (AdvancedPhysicsMaterial)target;
|
||||
serializedObject.Update();
|
||||
EditorGUIUtility.LookLikeInspector();
|
||||
if (mat != null) {
|
||||
|
||||
EditorGUILayout.LabelField("Selection name: " + mat.name.ToString());
|
||||
|
||||
var mt = typeof(AdvancedPhysics.Matters);
|
||||
var matters = mt.GetFields();
|
||||
|
||||
int selectedMatter = 0;
|
||||
List<string> matterNames = new List<string>();
|
||||
for(int i = 0; i < matters.Length; ++i){
|
||||
var m = matters[i];
|
||||
if(m.FieldType == typeof(AdvancedPhysics.Matter)){
|
||||
matterNames.Add(m.Name);
|
||||
}
|
||||
if(mat.matter != null && (mat.matter == m.GetValue(null))){
|
||||
//Debug.Log("LOL " + i);
|
||||
selectedMatter = i;
|
||||
}
|
||||
}
|
||||
EditorGUILayout.LabelField("Matter:");
|
||||
selectedMatter = EditorGUILayout.Popup(selectedMatter, matterNames.ToArray());
|
||||
mat.matter = (AdvancedPhysics.Matter)matters[selectedMatter].GetValue(null);
|
||||
|
||||
EditorGUILayout.LabelField("Volume (m^3): " + mat.Volume);
|
||||
EditorGUILayout.LabelField("Mass (kg): " + mat.Mass);
|
||||
mat.UpdateParameters();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e5708ff13c0b0d48817b9d96fefc8ff
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
@@ -0,0 +1,62 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections;
|
||||
|
||||
public class LevelEditor : EditorWindow
|
||||
{
|
||||
string myString = "Hello World";
|
||||
bool groupEnabled;
|
||||
bool myBool = true;
|
||||
float myFloat = 1.23f;
|
||||
|
||||
// Add menu item named "My Window" to the Window menu
|
||||
[MenuItem("Window/LevelEditor")]
|
||||
public static void ShowWindow()
|
||||
{
|
||||
//Show existing window instance. If one doesn't exist, make one.
|
||||
EditorWindow.GetWindow(typeof(LevelEditor));
|
||||
}
|
||||
|
||||
float AlingToGrid(float value, float gridStep = 0.5f){
|
||||
float div = value / gridStep;
|
||||
int cellId = Mathf.FloorToInt (div);
|
||||
float frac = div - (float)cellId;
|
||||
return (float)cellId * gridStep + (Mathf.Abs(frac) > 0.5f ? gridStep : 0.0f);
|
||||
}
|
||||
|
||||
Vector3 AlingToGrid(Vector3 value, float gridStep = 0.5f){
|
||||
return new Vector3 (
|
||||
AlingToGrid(value.x, gridStep),
|
||||
AlingToGrid(value.y, gridStep),
|
||||
AlingToGrid(value.z, gridStep));
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
GUILayout.Label ("Blocks alignment", EditorStyles.boldLabel);
|
||||
if (GUILayout.Button ("Aling position to grid")) {
|
||||
foreach(var obj in Selection.objects){
|
||||
GameObject go = obj as GameObject;
|
||||
if(go != null){
|
||||
go.transform.position = AlingToGrid(go.transform.position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (GUILayout.Button ("Aling rotation to grid")) {
|
||||
foreach(var obj in Selection.objects){
|
||||
GameObject go = obj as GameObject;
|
||||
if(go != null){
|
||||
go.transform.rotation = Quaternion.Euler(AlingToGrid(go.transform.rotation.eulerAngles, 45.0f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*myString = EditorGUILayout.TextField ("Text Field", myString);
|
||||
|
||||
groupEnabled = EditorGUILayout.BeginToggleGroup ("Optional Settings", groupEnabled);
|
||||
myBool = EditorGUILayout.Toggle ("Toggle", myBool);
|
||||
myFloat = EditorGUILayout.Slider ("Slider", myFloat, -3, 3);
|
||||
EditorGUILayout.EndToggleGroup ();*/
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 543c11bf5e047644c850e14160bcb163
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
@@ -0,0 +1,131 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public interface IMeshGenerator{
|
||||
void OnGUI();
|
||||
}
|
||||
|
||||
public class NodeEditor : EditorWindow {
|
||||
|
||||
|
||||
|
||||
List<Rect> windows = new List<Rect>();
|
||||
|
||||
List<int> windowsToAttach = new List<int>();
|
||||
|
||||
List<int> attachedWindows = new List<int>();
|
||||
|
||||
|
||||
|
||||
[MenuItem("Window/Node editor")]
|
||||
|
||||
static void ShowEditor() {
|
||||
|
||||
NodeEditor editor = EditorWindow.GetWindow<NodeEditor>();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void OnGUI() {
|
||||
|
||||
if (windowsToAttach.Count == 2) {
|
||||
|
||||
attachedWindows.Add(windowsToAttach[0]);
|
||||
|
||||
attachedWindows.Add(windowsToAttach[1]);
|
||||
|
||||
windowsToAttach = new List<int>();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (attachedWindows.Count >= 2) {
|
||||
|
||||
for (int i = 0; i < attachedWindows.Count; i += 2) {
|
||||
|
||||
DrawNodeCurve(windows[attachedWindows[i]], windows[attachedWindows[i + 1]]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
BeginWindows();
|
||||
|
||||
|
||||
|
||||
if (GUILayout.Button("Create Node")) {
|
||||
|
||||
windows.Add(new Rect(10, 10, 100, 100));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i < windows.Count; i++) {
|
||||
|
||||
windows[i] = GUI.Window(i, windows[i], DrawNodeWindow, "Window " + i);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
EndWindows();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void DrawNodeWindow(int id) {
|
||||
|
||||
if (GUILayout.Button("Attach")) {
|
||||
|
||||
windowsToAttach.Add(id);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
GUI.DragWindow();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void DrawNodeCurve(Rect start, Rect end) {
|
||||
|
||||
Vector3 startPos = new Vector3(start.x + start.width, start.y + start.height / 2, 0);
|
||||
|
||||
Vector3 endPos = new Vector3(end.x, end.y + end.height / 2, 0);
|
||||
|
||||
Vector3 startTan = startPos + Vector3.right * 50;
|
||||
|
||||
Vector3 endTan = endPos + Vector3.left * 50;
|
||||
|
||||
Color shadowCol = new Color(0, 0, 0, 0.06f);
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i < 3; i++) {// Draw a shadow
|
||||
|
||||
Handles.DrawBezier(startPos, endPos, startTan, endTan, shadowCol, null, (i + 1) * 5);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Handles.DrawBezier(startPos, endPos, startTan, endTan, Color.black, null, 1);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b5b804e4dc23aa4ab9657639ff5a3d6
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
Reference in New Issue
Block a user