1
This commit is contained in:
@@ -0,0 +1,198 @@
|
||||
#if GRIFFIN
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Pinwheel.Griffin
|
||||
{
|
||||
[CustomEditor(typeof(GAssetExplorer))]
|
||||
public class GAssetExplorerInspector : Editor
|
||||
{
|
||||
private GAssetExplorer instance;
|
||||
|
||||
public GUIStyle titleStyle;
|
||||
public GUIStyle TitleStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
if (titleStyle == null)
|
||||
{
|
||||
titleStyle = new GUIStyle(EditorStyles.label);
|
||||
titleStyle.fontStyle = FontStyle.Bold;
|
||||
titleStyle.fontSize = 13;
|
||||
titleStyle.alignment = TextAnchor.UpperLeft;
|
||||
}
|
||||
return titleStyle;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnEnable()
|
||||
{
|
||||
instance = target as GAssetExplorer;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
DrawInstructionGUI();
|
||||
DrawFeaturedAssetsGUI();
|
||||
DrawCollectionsGUI();
|
||||
DrawCrossPromotionGUI();
|
||||
}
|
||||
|
||||
public override bool RequiresConstantRepaint()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
private void DrawInstructionGUI()
|
||||
{
|
||||
string label = "Instruction";
|
||||
string id = "instruction" + instance.GetInstanceID().ToString();
|
||||
GEditorCommon.Foldout(label, true, id, () =>
|
||||
{
|
||||
EditorGUILayout.LabelField(
|
||||
"Polaris is more than a terrain engine. It's an ecosystem specialized for Low Poly scene creation!\n" +
|
||||
"Below are some asset suggestions which we found helpful to enhance your scene.",
|
||||
GEditorCommon.WordWrapItalicLabel);
|
||||
});
|
||||
}
|
||||
|
||||
private void DrawFeaturedAssetsGUI()
|
||||
{
|
||||
string label = "Featured Assets";
|
||||
string id = "featured-assets" + instance.GetInstanceID();
|
||||
|
||||
GEditorCommon.Foldout(label, true, id, () =>
|
||||
{
|
||||
DrawFeatureAssetEntry(
|
||||
"Assets/Polaris - Low Poly Ecosystem/Polaris - Low Poly Terrain Engine/Editor/Textures/PolarisIcon.png",
|
||||
"Polaris",
|
||||
"Low poly terrain modeling, texturing and planting.",
|
||||
"Leave a review",
|
||||
GAssetExplorer.POLARIS_LINK);
|
||||
|
||||
GEditorCommon.SpacePixel(0);
|
||||
|
||||
DrawFeatureAssetEntry(
|
||||
"Assets/Polaris - Low Poly Ecosystem/Polaris - Low Poly Terrain Engine/Editor/Textures/PoseidonIcon.png",
|
||||
"Poseidon",
|
||||
"Low poly water with high fidelity and performance.",
|
||||
GPackageInitializer.isPoseidonInstalled ? "Leave a review" : "Learn more",
|
||||
GAssetExplorer.POSEIDON_LINK);
|
||||
|
||||
GEditorCommon.SpacePixel(0);
|
||||
|
||||
DrawFeatureAssetEntry(
|
||||
"Assets/Polaris - Low Poly Ecosystem/Polaris - Low Poly Terrain Engine/Editor/Textures/JupiterIcon.png",
|
||||
"Jupiter",
|
||||
"Single-pass procedural sky with day night cycle.",
|
||||
GPackageInitializer.isJupiterInstalled ? "Leave a review" : "Learn more",
|
||||
GAssetExplorer.JUPITER_LINK);
|
||||
|
||||
GEditorCommon.SpacePixel(0);
|
||||
|
||||
DrawFeatureAssetEntry(
|
||||
"Assets/Polaris - Low Poly Ecosystem/Polaris - Low Poly Terrain Engine/Editor/Textures/CSharpWizardIcon.png",
|
||||
"CSharp Wizard",
|
||||
"Skeleton code for C# and Polaris Extension.",
|
||||
GPackageInitializer.isCSharpWizardInstalled ? "Leave a review" : "Learn more",
|
||||
GAssetExplorer.CSHARP_WIZARD_LINK);
|
||||
|
||||
GEditorCommon.SpacePixel(0);
|
||||
|
||||
DrawFeatureAssetEntry(
|
||||
"Assets/Polaris - Low Poly Ecosystem/Polaris - Low Poly Terrain Engine/Editor/Textures/MeshToFileIcon.png",
|
||||
"Mesh To File",
|
||||
"Export mesh and Polaris terrain to 3D files.",
|
||||
GPackageInitializer.isMeshToFileInstalled ? "Leave a review" : "Learn more",
|
||||
GAssetExplorer.MESH_TO_FILE_LINK);
|
||||
});
|
||||
}
|
||||
|
||||
private void DrawFeatureAssetEntry(
|
||||
string iconPath,
|
||||
string title,
|
||||
string description,
|
||||
string cta,
|
||||
string link)
|
||||
{
|
||||
int indent = EditorGUI.indentLevel;
|
||||
EditorGUI.indentLevel = 0;
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
|
||||
EditorGUILayout.GetControlRect(GUILayout.Width(GEditorCommon.indentSpace));
|
||||
Rect iconRect = EditorGUILayout.GetControlRect(GUILayout.Width(64), GUILayout.Height(64));
|
||||
Texture2D icon = AssetDatabase.LoadAssetAtPath<Texture2D>(iconPath);
|
||||
EditorGUI.DrawPreviewTexture(iconRect, icon ?? Texture2D.blackTexture);
|
||||
|
||||
EditorGUILayout.BeginVertical();
|
||||
Rect titleRect = EditorGUILayout.GetControlRect(GUILayout.Height(17));
|
||||
EditorGUI.LabelField(titleRect, title, TitleStyle);
|
||||
EditorGUILayout.LabelField(GEditorCommon.Ellipsis(description, 50), GEditorCommon.WordWrapItalicLabel);
|
||||
Rect ctaRect = EditorGUILayout.GetControlRect();
|
||||
string colorStr = ColorUtility.ToHtmlStringRGBA(GEditorCommon.selectedItemColor);
|
||||
string ctaStr = "<i><color=#" + colorStr + ">" + GEditorCommon.Ellipsis(cta, 25) + "</color></i>";
|
||||
if (GUI.Button(ctaRect, ctaStr, GEditorCommon.RichTextLabel))
|
||||
{
|
||||
Application.OpenURL(link);
|
||||
}
|
||||
EditorGUIUtility.AddCursorRect(ctaRect, MouseCursor.Link);
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUI.indentLevel = indent;
|
||||
}
|
||||
|
||||
private void DrawCollectionsGUI()
|
||||
{
|
||||
string label = "Collections";
|
||||
string id = "collections" + instance.GetInstanceID().ToString();
|
||||
GEditorCommon.Foldout(label, true, id, () =>
|
||||
{
|
||||
Rect r;
|
||||
r = EditorGUILayout.GetControlRect();
|
||||
if (GUI.Button(r, "Other Assets From Pinwheel"))
|
||||
{
|
||||
GAssetExplorer.ShowPinwheelAssets();
|
||||
}
|
||||
|
||||
r = EditorGUILayout.GetControlRect();
|
||||
if (GUI.Button(r, "Vegetation"))
|
||||
{
|
||||
GAssetExplorer.ShowVegetationLink();
|
||||
}
|
||||
|
||||
r = EditorGUILayout.GetControlRect();
|
||||
if (GUI.Button(r, "Rock & Props"))
|
||||
{
|
||||
GAssetExplorer.ShowRockPropsLink();
|
||||
}
|
||||
|
||||
r = EditorGUILayout.GetControlRect();
|
||||
if (GUI.Button(r, "Character"))
|
||||
{
|
||||
GAssetExplorer.ShowCharacterLink();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void DrawCrossPromotionGUI()
|
||||
{
|
||||
string label = "Cross Promotion";
|
||||
string id = "crosspromo" + instance.GetInstanceID().ToString();
|
||||
GEditorCommon.Foldout(label, true, id, () =>
|
||||
{
|
||||
string text = "Are you a Publisher, send us a message to get more expose to the community!";
|
||||
EditorGUILayout.LabelField(text, GEditorCommon.WordWrapItalicLabel);
|
||||
Rect r = EditorGUILayout.GetControlRect();
|
||||
if (GUI.Button(r, "Send an Email"))
|
||||
{
|
||||
GEditorCommon.OpenEmailEditor(
|
||||
GCommon.BUSINESS_EMAIL,
|
||||
"[Polaris] CROSS PROMOTION",
|
||||
"DETAIL ABOUT YOUR ASSET HERE");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f35fe7e4e3721324c90c8a8cc9a5d2ad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,22 @@
|
||||
#if GRIFFIN
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
namespace Pinwheel.Griffin
|
||||
{
|
||||
public static class GAssetLink
|
||||
{
|
||||
public const string LWRP_SUPPORT_EXTENSION = "https://assetstore.unity.com/packages/slug/157782";
|
||||
public const string URP_SUPPORT_EXTENSION = "https://assetstore.unity.com/packages/slug/157785";
|
||||
public const string POSEIDON = "https://assetstore.unity.com/packages/vfx/shaders/substances/poseidon-low-poly-water-system-builtin-lwrp-153826?aid=1100l3QbW&pubref=polaris21-editor";
|
||||
public const string JUPITER = "https://assetstore.unity.com/packages/slug/159992?aid=1100l3QbW&pubref=polaris21-editor";
|
||||
public const string VEGETATION_STUDIO_PRO = "https://assetstore.unity.com/packages/tools/terrain/vegetation-studio-pro-131835?aid=1100l3QbW&pubref=polaris21-editor";
|
||||
public const string VSP_INTEGRATION = "https://assetstore.unity.com/packages/slug/169036";
|
||||
public const string MICRO_SPLAT = "https://assetstore.unity.com/packages/tools/terrain/microsplat-96478";
|
||||
public const string MICRO_SPLAT_INTEGRATION = "https://assetstore.unity.com/packages/slug/166851?aid=1100l3QbW&pubref=polaris21-editor";
|
||||
public const string POLARIS_3 = "https://assetstore.unity.com/packages/tools/terrain/polaris-3-low-poly-terrain-tool-286886?aid=1100l3QbW&pubref=polaris21-editor";
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9861a5e4c8e144740a170bcea6f7039b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,52 @@
|
||||
#if GRIFFIN
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Pinwheel.Griffin
|
||||
{
|
||||
//[CreateAssetMenu(fileName = "Skin", menuName = "Griffin/Skin")]
|
||||
public class GEditorSkin : ScriptableObject
|
||||
{
|
||||
private static GEditorSkin instance;
|
||||
public static GEditorSkin Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = Resources.Load<GEditorSkin>("PolarisSkin");
|
||||
if (instance == null)
|
||||
{
|
||||
instance = ScriptableObject.CreateInstance<GEditorSkin>();
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private List<Texture2D> textures;
|
||||
public List<Texture2D> Textures
|
||||
{
|
||||
get
|
||||
{
|
||||
if (textures == null)
|
||||
{
|
||||
textures = new List<Texture2D>();
|
||||
}
|
||||
return textures;
|
||||
}
|
||||
set
|
||||
{
|
||||
textures = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Texture2D GetTexture(string name)
|
||||
{
|
||||
return Textures.Find(t => t.name.Equals(name));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 74547fd1526184b4088998c69e46ffea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,20 @@
|
||||
#if GRIFFIN
|
||||
using UnityEditor;
|
||||
|
||||
namespace Pinwheel.Griffin
|
||||
{
|
||||
public class GGenericMenuItem
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public bool IsOn { get; set; }
|
||||
public GenericMenu.MenuFunction Action { get; set; }
|
||||
|
||||
public GGenericMenuItem(string name, bool isOn, GenericMenu.MenuFunction action)
|
||||
{
|
||||
Name = name;
|
||||
IsOn = isOn;
|
||||
Action = action;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94084d4f42647ae429710f50731f5039
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,168 @@
|
||||
#if GRIFFIN
|
||||
//using UnityEngine;
|
||||
//using System.Collections;
|
||||
//using System.Collections.Generic;
|
||||
//using UnityEditor;
|
||||
//using Pinwheel.MeshToFile;
|
||||
//using Den.Tools.Matrices;
|
||||
|
||||
//namespace Pinwheel.Griffin
|
||||
//{
|
||||
// public class GGrassMeshGenerator
|
||||
// {
|
||||
// [MenuItem("Window/Griffin/Internal/GenerateGrassMeshes")]
|
||||
// public static void Generate()
|
||||
// {
|
||||
// Mesh quad = GenerateQuad();
|
||||
// Mesh cross = GenerateCross();
|
||||
// Mesh triCross = GenerateTriCross();
|
||||
// Mesh clump = GenerateClump(quad);
|
||||
// SaveToAsset(quad, cross, triCross, clump);
|
||||
// }
|
||||
|
||||
// private static Mesh GenerateQuad()
|
||||
// {
|
||||
// Vector3[] vertices = new Vector3[]
|
||||
// {
|
||||
// new Vector3(-0.5f, 0, 0), new Vector3(-0.5f, 1, 0), new Vector3(0.5f, 1, 0), new Vector3(0.5f, 0, 0)
|
||||
// };
|
||||
// Vector2[] uvs = new Vector2[]
|
||||
// {
|
||||
// Vector2.zero, Vector2.up, Vector2.one, Vector2.right
|
||||
// };
|
||||
// int[] indices = new int[] { 0, 1, 2, 0, 2, 3 };
|
||||
// Mesh quad = new Mesh();
|
||||
// quad.vertices = vertices;
|
||||
// quad.uv = uvs;
|
||||
// quad.triangles = indices;
|
||||
// quad.name = "Quad";
|
||||
// quad.RecalculateBounds();
|
||||
// quad.RecalculateNormals();
|
||||
// quad.RecalculateTangents();
|
||||
// return quad;
|
||||
// }
|
||||
|
||||
// private static Mesh GenerateCross()
|
||||
// {
|
||||
// Vector3[] vertices = new Vector3[]
|
||||
// {
|
||||
// new Vector3(-0.5f, 0, 0), new Vector3(-0.5f, 1, 0), new Vector3(0.5f, 1, 0), new Vector3(0.5f, 0, 0),
|
||||
// new Vector3(0, 0, -0.5f), new Vector3(0, 1, -0.5f), new Vector3(0, 1, 0.5f), new Vector3(0, 0, 0.5f)
|
||||
// };
|
||||
// Vector2[] uvs = new Vector2[]
|
||||
// {
|
||||
// Vector2.zero, Vector2.up, Vector2.one, Vector2.right,
|
||||
// Vector2.zero, Vector2.up, Vector2.one,Vector2.right
|
||||
// };
|
||||
|
||||
// int[] indices = new int[]
|
||||
// {
|
||||
// 0, 1, 2, 0, 2, 3,
|
||||
// 4, 5, 6, 4, 6, 7
|
||||
// };
|
||||
// Mesh cross = new Mesh();
|
||||
// cross.vertices = vertices;
|
||||
// cross.uv = uvs;
|
||||
// cross.triangles = indices;
|
||||
// cross.name = "Cross";
|
||||
// cross.RecalculateBounds();
|
||||
// cross.RecalculateNormals();
|
||||
// cross.RecalculateTangents();
|
||||
// return cross;
|
||||
// }
|
||||
|
||||
// private static Mesh GenerateTriCross()
|
||||
// {
|
||||
// Vector3[] quads = new Vector3[]
|
||||
// {
|
||||
// new Vector3(-0.5f, 0, 0), new Vector3(-0.5f, 1, 0), new Vector3(0.5f, 1, 0),new Vector3(0.5f, 0, 0)
|
||||
// };
|
||||
|
||||
// List<Vector3> vertices = new List<Vector3>();
|
||||
// vertices.AddRange(quads);
|
||||
|
||||
// Matrix4x4 rotate60 = Matrix4x4.Rotate(Quaternion.Euler(0, -60, 0));
|
||||
// for (int i = 0; i < quads.Length; ++i)
|
||||
// {
|
||||
// vertices.Add(rotate60.MultiplyPoint(quads[i]));
|
||||
// }
|
||||
|
||||
// Matrix4x4 rotate120 = Matrix4x4.Rotate(Quaternion.Euler(0, -120, 0));
|
||||
// for (int i = 0; i < quads.Length; ++i)
|
||||
// {
|
||||
// vertices.Add(rotate120.MultiplyPoint(quads[i]));
|
||||
// }
|
||||
|
||||
// Vector2[] uvs = new Vector2[]
|
||||
// {
|
||||
// Vector2.zero, Vector2.up, Vector2.one, Vector2.right,
|
||||
// Vector2.zero, Vector2.up, Vector2.one, Vector2.right,
|
||||
// Vector2.zero, Vector2.up, Vector2.one, Vector2.right
|
||||
// };
|
||||
|
||||
// int[] indices = new int[]
|
||||
// {
|
||||
// 0, 1, 2, 0, 2, 3,
|
||||
// 4, 5, 6, 4, 6, 7,
|
||||
// 8, 9,10, 8,10,11
|
||||
// };
|
||||
// Mesh triCross = new Mesh();
|
||||
// triCross.vertices = vertices.ToArray();
|
||||
// triCross.uv = uvs;
|
||||
// triCross.triangles = indices;
|
||||
// triCross.name = "TriCross";
|
||||
// triCross.RecalculateBounds();
|
||||
// triCross.RecalculateNormals();
|
||||
// triCross.RecalculateTangents();
|
||||
// return triCross;
|
||||
// }
|
||||
|
||||
// private static Mesh GenerateClump(Mesh baseMesh)
|
||||
// {
|
||||
// int count = 7;
|
||||
// Vector3[] verts = baseMesh.vertices;
|
||||
// Vector2[] texcoords = baseMesh.uv;
|
||||
// int[] tris = baseMesh.triangles;
|
||||
|
||||
// List<Vector3> vertices = new List<Vector3>();
|
||||
// List<Vector2> uvs = new List<Vector2>();
|
||||
// List<int> triangles = new List<int>();
|
||||
|
||||
// for (int i = 0; i < count; ++i)
|
||||
// {
|
||||
// Vector3 offset = new Vector3(Random.value, 0, Random.value);
|
||||
// Quaternion rotation = Quaternion.Euler(0, Random.value * 360, 0);
|
||||
// Vector3 scale = Vector3.one * Mathf.Lerp(0.7f, 1f, Random.value);
|
||||
// Matrix4x4 m = Matrix4x4.TRS(offset, rotation, scale);
|
||||
|
||||
// int baseTris = vertices.Count;
|
||||
// for (int j = 0; j < verts.Length; ++j)
|
||||
// {
|
||||
// vertices.Add(m.MultiplyPoint(verts[j]));
|
||||
// uvs.Add(texcoords[j]);
|
||||
// }
|
||||
// for (int j = 0; j < tris.Length; ++j)
|
||||
// {
|
||||
// triangles.Add(baseTris + tris[j]);
|
||||
// }
|
||||
// }
|
||||
|
||||
// Mesh mesh = new Mesh();
|
||||
// mesh.vertices = vertices.ToArray();
|
||||
// mesh.uv = uvs.ToArray();
|
||||
// mesh.triangles = triangles.ToArray();
|
||||
// mesh.name = "Clump";
|
||||
// mesh.RecalculateBounds();
|
||||
// mesh.RecalculateNormals();
|
||||
// mesh.RecalculateTangents();
|
||||
// return mesh;
|
||||
// }
|
||||
|
||||
// private static void SaveToAsset(params Mesh[] meshes)
|
||||
// {
|
||||
// MeshSaver.SaveFbxMultipleMesh(meshes, "Assets/", "GrassMeshes");
|
||||
// AssetDatabase.Refresh();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
#endif
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: abfc1feba43c8de4190dbbb93b2a29a2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,76 @@
|
||||
#if GRIFFIN
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Pinwheel.Griffin
|
||||
{
|
||||
public class GGridlineMeshCreatorWindow : EditorWindow
|
||||
{
|
||||
public GGenericContainer Container { get; set; }
|
||||
|
||||
//[MenuItem("Window/Griffin/Tools/Gridline Mesh Creator")]
|
||||
public static void ShowWindow()
|
||||
{
|
||||
GGridlineMeshCreatorWindow window = GetWindow<GGridlineMeshCreatorWindow>();
|
||||
window.titleContent = new GUIContent("GGridlineMeshCreator");
|
||||
window.Show();
|
||||
}
|
||||
|
||||
public void OnGUI()
|
||||
{
|
||||
Container = EditorGUILayout.ObjectField("Container", Container, typeof(GGenericContainer), false) as GGenericContainer;
|
||||
|
||||
if (GUILayout.Button("Generate"))
|
||||
{
|
||||
Generate();
|
||||
}
|
||||
}
|
||||
|
||||
private void Generate()
|
||||
{
|
||||
Mesh[] wireframeMeshes = new Mesh[GEditorSettings.Instance.livePreview.triangleMeshes.Length];
|
||||
for (int i = 0; i < wireframeMeshes.Length; ++i)
|
||||
{
|
||||
Mesh wm = ConvertToLineMesh(GEditorSettings.Instance.livePreview.triangleMeshes[i]);
|
||||
wm.name = "Wireframe Grid " + i.ToString();
|
||||
AssetDatabase.AddObjectToAsset(wm, Container);
|
||||
wireframeMeshes[i] = wm;
|
||||
}
|
||||
|
||||
GEditorSettings.Instance.livePreview.wireframeMeshes = wireframeMeshes;
|
||||
EditorUtility.SetDirty(Container);
|
||||
EditorUtility.SetDirty(GEditorSettings.Instance);
|
||||
}
|
||||
|
||||
private Mesh ConvertToLineMesh(Mesh m)
|
||||
{
|
||||
Mesh wm = new Mesh();
|
||||
wm.vertices = m.vertices;
|
||||
wm.uv = m.uv;
|
||||
wm.colors = m.colors;
|
||||
|
||||
int[] tris = m.triangles;
|
||||
int trisCount = tris.Length / 3;
|
||||
|
||||
List<int> indices = new List<int>();
|
||||
|
||||
for (int i = 0; i < trisCount; ++i)
|
||||
{
|
||||
indices.Add(tris[i * 3 + 0]);
|
||||
indices.Add(tris[i * 3 + 1]);
|
||||
|
||||
indices.Add(tris[i * 3 + 1]);
|
||||
indices.Add(tris[i * 3 + 2]);
|
||||
|
||||
indices.Add(tris[i * 3 + 2]);
|
||||
indices.Add(tris[i * 3 + 0]);
|
||||
}
|
||||
|
||||
wm.SetIndices(indices.ToArray(), MeshTopology.Lines, 0);
|
||||
|
||||
return wm;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57678d95c15ebe34f86b067d29782e8f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,60 @@
|
||||
#if GRIFFIN
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Pinwheel.Griffin
|
||||
{
|
||||
[CustomEditor(typeof(GNavigationHelper))]
|
||||
public class GNavigationHelperInspector : Editor
|
||||
{
|
||||
private GNavigationHelper instance;
|
||||
|
||||
public void OnEnable()
|
||||
{
|
||||
instance = target as GNavigationHelper;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
instance.GroupId = GEditorCommon.ActiveTerrainGroupPopupWithAllOption("Group Id", instance.GroupId);
|
||||
DrawInstructionGUI();
|
||||
DrawActionGUI();
|
||||
}
|
||||
|
||||
public override bool RequiresConstantRepaint()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
private void DrawInstructionGUI()
|
||||
{
|
||||
string label = "Instruction";
|
||||
string id = "instruction" + instance.GetInstanceID().ToString();
|
||||
GEditorCommon.Foldout(label, true, id, () =>
|
||||
{
|
||||
EditorGUILayout.LabelField("Create dummy game objects for Nav Mesh baking. These game objects should be removed in production.", GEditorCommon.WordWrapItalicLabel);
|
||||
});
|
||||
}
|
||||
|
||||
private void DrawActionGUI()
|
||||
{
|
||||
string label = "Actions";
|
||||
string id = "actions" + instance.GetInstanceID().ToString();
|
||||
GEditorCommon.Foldout(label, true, id, () =>
|
||||
{
|
||||
Rect createButtonRect = EditorGUILayout.GetControlRect();
|
||||
if (GUI.Button(createButtonRect, "Create static obstacles"))
|
||||
{
|
||||
instance.CreateStaticObstacles();
|
||||
}
|
||||
|
||||
Rect deleteButtonRect = EditorGUILayout.GetControlRect();
|
||||
if (GUI.Button(deleteButtonRect, "Delete static obstacles"))
|
||||
{
|
||||
instance.DeleteStaticObstacles();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ddb7b10ce01c9b542b89ae49891130ec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,21 @@
|
||||
#if GRIFFIN
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Pinwheel.Griffin
|
||||
{
|
||||
public class GObjectComparer<T> : IEqualityComparer<T> where T : Object
|
||||
{
|
||||
public bool Equals(T x, T y)
|
||||
{
|
||||
return x.GetInstanceID() == y.GetInstanceID();
|
||||
}
|
||||
|
||||
public int GetHashCode(T obj)
|
||||
{
|
||||
return obj.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9a9556e7076a22744a76bb9ab7b75128
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,40 @@
|
||||
#if GRIFFIN
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Pinwheel.Griffin
|
||||
{
|
||||
[CustomEditor(typeof(GObjectHelper))]
|
||||
public class GObjectHelperInspector : Editor
|
||||
{
|
||||
private GObjectHelper instance;
|
||||
private void OnEnable()
|
||||
{
|
||||
instance = target as GObjectHelper;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
instance.Terrain = EditorGUILayout.ObjectField("Terrain", instance.Terrain, typeof(GStylizedTerrain), true) as GStylizedTerrain;
|
||||
instance.SnapMode = (GSnapMode)EditorGUILayout.EnumPopup("Snap Mode", instance.SnapMode);
|
||||
|
||||
SerializedObject so = new SerializedObject(instance);
|
||||
SerializedProperty sp = so.FindProperty("layerMask");
|
||||
if (sp != null)
|
||||
{
|
||||
EditorGUILayout.PropertyField(sp);
|
||||
}
|
||||
so.ApplyModifiedProperties();
|
||||
sp.Dispose();
|
||||
so.Dispose();
|
||||
|
||||
instance.AlignToSurface = EditorGUILayout.Toggle("Align To Surface", instance.AlignToSurface);
|
||||
|
||||
if (GUILayout.Button("Snap", GUILayout.Height(EditorGUIUtility.singleLineHeight)))
|
||||
{
|
||||
instance.Snap();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e03be64d1504c0741a068f946f48174c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,167 @@
|
||||
#if GRIFFIN
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Pinwheel.Griffin
|
||||
{
|
||||
public static class GShaderParser
|
||||
{
|
||||
//private static string debugFile = "Assets/debug.txt";
|
||||
|
||||
//[MenuItem("Testing/Debug Parse Shader")]
|
||||
public static void Debug()
|
||||
{
|
||||
Shader shader = Shader.Find("SyntyStudios/Trees");
|
||||
GetProperties(shader, "Color");
|
||||
}
|
||||
|
||||
public static List<string> GetProperties(Shader shader, string type)
|
||||
{
|
||||
List<string> props = new List<string>();
|
||||
List<string> lines = GetShaderContent(shader);
|
||||
CleanUpContent(lines);
|
||||
ExtractPropertiesLines(lines);
|
||||
CleanUpContent(lines);
|
||||
|
||||
for (int i = 0; i < lines.Count; ++i)
|
||||
{
|
||||
lines[i] = lines[i].Replace(" ", "").Trim();
|
||||
if (lines[i].Contains("," + type))
|
||||
{
|
||||
int openParathesisPos = lines[i].IndexOf("(");
|
||||
if (openParathesisPos > 0)
|
||||
{
|
||||
props.Add(lines[i].Substring(0, openParathesisPos));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//File.WriteAllLines(debugFile, props.ToArray());
|
||||
|
||||
return props;
|
||||
}
|
||||
|
||||
private static List<string> GetShaderContent(Shader shader)
|
||||
{
|
||||
List<string> lines = new List<string>();
|
||||
string path = AssetDatabase.GetAssetPath(shader);
|
||||
if (File.Exists(path))
|
||||
{
|
||||
lines.AddRange(File.ReadAllLines(path));
|
||||
}
|
||||
|
||||
return lines;
|
||||
}
|
||||
|
||||
private static void CleanUpContent(List<string> lines)
|
||||
{
|
||||
//remove double slashes comments
|
||||
for (int i = 0; i < lines.Count; ++i)
|
||||
{
|
||||
int doubleSlashesPosition = lines[i].IndexOf("//");
|
||||
if (doubleSlashesPosition >= 0)
|
||||
{
|
||||
lines[i] = lines[i].Remove(doubleSlashesPosition);
|
||||
}
|
||||
}
|
||||
|
||||
//remove block comments
|
||||
bool commentStarted = false;
|
||||
for (int i = 0; i < lines.Count; ++i)
|
||||
{
|
||||
if (!commentStarted)
|
||||
{
|
||||
int pos = lines[i].IndexOf("/*");
|
||||
if (pos >= 0)
|
||||
{
|
||||
lines[i] = lines[i].Remove(pos);
|
||||
commentStarted = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int pos = lines[i].IndexOf("*/");
|
||||
if (pos < 0)
|
||||
{
|
||||
lines[i] = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
lines[i] = lines[i].Remove(0, pos + 2);
|
||||
commentStarted = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//remove indentations
|
||||
for (int i = 0; i < lines.Count; ++i)
|
||||
{
|
||||
lines[i] = lines[i].Replace("\t", "").Trim();
|
||||
}
|
||||
|
||||
//remove empty lines
|
||||
lines.RemoveAll(s => string.IsNullOrEmpty(s) || s.Equals("\n"));
|
||||
}
|
||||
|
||||
private static void ExtractPropertiesLines(List<string> lines)
|
||||
{
|
||||
StringBuilder s = new StringBuilder();
|
||||
for (int i = 0; i < lines.Count; ++i)
|
||||
{
|
||||
s.AppendLine(lines[i]);
|
||||
}
|
||||
|
||||
string content = s.ToString();
|
||||
int pos = content.IndexOf("Properties");
|
||||
|
||||
if (pos < 0)
|
||||
{
|
||||
lines.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
int openBracketPos = content.IndexOf("{", pos);
|
||||
int closeBracketPos = openBracketPos;
|
||||
int blockLevel = 1;
|
||||
for (int i = openBracketPos + 1; i < content.Length; ++i)
|
||||
{
|
||||
if (content[i].Equals('{'))
|
||||
{
|
||||
blockLevel += 1;
|
||||
}
|
||||
if (content[i].Equals('}'))
|
||||
{
|
||||
blockLevel -= 1;
|
||||
if (blockLevel == 0)
|
||||
{
|
||||
closeBracketPos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string propertiesContent = content.Substring(openBracketPos + 1, closeBracketPos - openBracketPos - 1);
|
||||
|
||||
lines.Clear();
|
||||
lines.AddRange(propertiesContent.Split(new char[] { '\n' }, System.StringSplitOptions.RemoveEmptyEntries));
|
||||
|
||||
//remove attributes
|
||||
for (int i = 0; i < lines.Count; ++i)
|
||||
{
|
||||
int lastBracket = lines[i].LastIndexOf("]");
|
||||
if (lastBracket >= 0)
|
||||
{
|
||||
lines[i] = lines[i].Remove(0, lastBracket + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cbd4ee118e623914ab54a8582fb5c01e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,87 @@
|
||||
#if GRIFFIN
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Pinwheel.Griffin
|
||||
{
|
||||
[InitializeOnLoad]
|
||||
public class GTerrainDataDragAndDrop
|
||||
{
|
||||
static GTerrainDataDragAndDrop()
|
||||
{
|
||||
EditorApplication.hierarchyWindowItemOnGUI += OnHierarchyGUI;
|
||||
#pragma warning disable 0618
|
||||
SceneView.onSceneGUIDelegate += OnSceneViewGUI;
|
||||
#pragma warning restore 0618
|
||||
}
|
||||
|
||||
private static void OnHierarchyGUI(int instanceID, Rect r)
|
||||
{
|
||||
Event e = Event.current;
|
||||
if (e == null)
|
||||
return;
|
||||
int controlId = EditorGUIUtility.GetControlID(FocusType.Passive);
|
||||
if (e.type == EventType.DragUpdated)
|
||||
{
|
||||
Object[] draggedObjects = DragAndDrop.objectReferences;
|
||||
if (draggedObjects.Length == 1 &&
|
||||
draggedObjects[0] is GTerrainData)
|
||||
{
|
||||
DragAndDrop.AcceptDrag();
|
||||
DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
|
||||
DragAndDrop.activeControlID = controlId;
|
||||
e.Use();
|
||||
}
|
||||
}
|
||||
else if (e.type == EventType.DragPerform)
|
||||
{
|
||||
Object[] draggedObjects = DragAndDrop.objectReferences;
|
||||
if (draggedObjects.Length == 1 &&
|
||||
draggedObjects[0] is GTerrainData)
|
||||
{
|
||||
GTerrainData data = draggedObjects[0] as GTerrainData;
|
||||
GCommon.CreateTerrain(data);
|
||||
data.Geometry.ClearDirtyRegions();
|
||||
data.Foliage.ClearTreeDirtyRegions();
|
||||
data.Foliage.ClearGrassDirtyRegions();
|
||||
e.Use();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void OnSceneViewGUI(SceneView sv)
|
||||
{
|
||||
Event e = Event.current;
|
||||
if (e == null)
|
||||
return;
|
||||
int controlId = EditorGUIUtility.GetControlID(FocusType.Passive, sv.position);
|
||||
if (e.type == EventType.DragUpdated)
|
||||
{
|
||||
Object[] draggedObjects = DragAndDrop.objectReferences;
|
||||
if (draggedObjects.Length == 1 &&
|
||||
draggedObjects[0] is GTerrainData)
|
||||
{
|
||||
DragAndDrop.AcceptDrag();
|
||||
DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
|
||||
DragAndDrop.activeControlID = controlId;
|
||||
e.Use();
|
||||
}
|
||||
}
|
||||
else if (e.type == EventType.DragPerform)
|
||||
{
|
||||
Object[] draggedObjects = DragAndDrop.objectReferences;
|
||||
if (draggedObjects.Length == 1 &&
|
||||
draggedObjects[0] is GTerrainData)
|
||||
{
|
||||
GTerrainData data = draggedObjects[0] as GTerrainData;
|
||||
GCommon.CreateTerrain(data);
|
||||
data.Geometry.ClearDirtyRegions();
|
||||
data.Foliage.ClearTreeDirtyRegions();
|
||||
data.Foliage.ClearGrassDirtyRegions();
|
||||
e.Use();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 39b93a4d7a213b34ba2771b911fec4fb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,28 @@
|
||||
#if GRIFFIN
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Pinwheel.Griffin
|
||||
{
|
||||
[CustomEditor(typeof(GTextAsset))]
|
||||
public class GTextAssetInspector : Editor
|
||||
{
|
||||
private GTextAsset instance;
|
||||
private void OnEnable()
|
||||
{
|
||||
instance = target as GTextAsset;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
EditorGUILayout.LabelField("Text", EditorStyles.boldLabel);
|
||||
instance.Text = EditorGUILayout.TextArea(instance.Text, GUILayout.ExpandHeight(true));
|
||||
if (GUILayout.Button("Spacify"))
|
||||
{
|
||||
instance.Text = instance.Text.Replace("\t", " ");
|
||||
}
|
||||
EditorUtility.SetDirty(instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b87ce1be7501ebb4484a48414936e626
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,111 @@
|
||||
#if GRIFFIN
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Pinwheel.Griffin
|
||||
{
|
||||
public class GUvLayoutExporterWindow : EditorWindow
|
||||
{
|
||||
private Mesh targetMesh;
|
||||
private int resolution;
|
||||
|
||||
static Material lineMaterial;
|
||||
|
||||
//[MenuItem("Window/Griffin/Internal/UV Layout Exporter")]
|
||||
public static void ShowWindow()
|
||||
{
|
||||
GUvLayoutExporterWindow window = GetWindow<GUvLayoutExporterWindow>();
|
||||
window.titleContent = new GUIContent("GUvLayoutExporter");
|
||||
window.Show();
|
||||
}
|
||||
|
||||
public void OnEnable()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnDisable()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnGUI()
|
||||
{
|
||||
targetMesh = EditorGUILayout.ObjectField("Mesh", targetMesh, typeof(Mesh), false) as Mesh;
|
||||
resolution = EditorGUILayout.IntField("Resolution", resolution);
|
||||
if (GUILayout.Button("Export"))
|
||||
{
|
||||
Export();
|
||||
}
|
||||
}
|
||||
|
||||
private void Export()
|
||||
{
|
||||
RenderTexture rt = new RenderTexture(resolution, resolution, 24, RenderTextureFormat.ARGB32);
|
||||
GCommon.FillTexture(rt, Color.clear);
|
||||
|
||||
Vector2[] uv = targetMesh.uv;
|
||||
int[] tris = targetMesh.triangles;
|
||||
int trisCount = tris.Length / 3;
|
||||
|
||||
CreateLineMaterial();
|
||||
// Apply the line material
|
||||
lineMaterial.SetPass(0);
|
||||
|
||||
RenderTexture.active = rt;
|
||||
GL.PushMatrix();
|
||||
GL.LoadOrtho();
|
||||
// Draw lines
|
||||
GL.Begin(GL.LINES);
|
||||
for (int i = 0; i < trisCount; ++i)
|
||||
{
|
||||
GL.Color(Color.black);
|
||||
Vector2 p0 = uv[tris[i * 3 + 0]];
|
||||
Vector2 p1 = uv[tris[i * 3 + 1]];
|
||||
Vector2 p2 = uv[tris[i * 3 + 2]];
|
||||
|
||||
GL.Vertex3(p0.x, p0.y, 0);
|
||||
GL.Vertex3(p1.x, p1.y, 0);
|
||||
|
||||
GL.Vertex3(p1.x, p1.y, 0);
|
||||
GL.Vertex3(p2.x, p2.y, 0);
|
||||
|
||||
GL.Vertex3(p2.x, p2.y, 0);
|
||||
GL.Vertex3(p0.x, p0.y, 0);
|
||||
}
|
||||
GL.End();
|
||||
GL.PopMatrix();
|
||||
|
||||
Texture2D tex = new Texture2D(resolution, resolution, TextureFormat.ARGB32, false);
|
||||
tex.ReadPixels(new Rect(0, 0, resolution, resolution), 0, 0);
|
||||
tex.Apply();
|
||||
|
||||
byte[] data = tex.EncodeToPNG();
|
||||
File.WriteAllBytes(string.Format("Assets/{0}_UV_{1}.png", targetMesh.name, resolution), data);
|
||||
GUtilities.DestroyObject(tex);
|
||||
|
||||
RenderTexture.active = null;
|
||||
rt.Release();
|
||||
GUtilities.DestroyObject(rt);
|
||||
}
|
||||
|
||||
static void CreateLineMaterial()
|
||||
{
|
||||
if (!lineMaterial)
|
||||
{
|
||||
// Unity has a built-in shader that is useful for drawing
|
||||
// simple colored things.
|
||||
Shader shader = Shader.Find("Hidden/Internal-Colored");
|
||||
lineMaterial = new Material(shader);
|
||||
lineMaterial.hideFlags = HideFlags.HideAndDontSave;
|
||||
// Turn on alpha blending
|
||||
lineMaterial.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
|
||||
lineMaterial.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
|
||||
// Turn backface culling off
|
||||
lineMaterial.SetInt("_Cull", (int)UnityEngine.Rendering.CullMode.Off);
|
||||
// Turn off depth writes
|
||||
lineMaterial.SetInt("_ZWrite", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0140fb5603a76ae48a8ca7ff42cfa5df
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,80 @@
|
||||
#if GRIFFIN
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace Pinwheel.Griffin
|
||||
{
|
||||
[CustomEditor(typeof(GWindZone))]
|
||||
public class GWindZoneInspector : Editor
|
||||
{
|
||||
private static Vector3[] arrowShape = new Vector3[]
|
||||
{
|
||||
new Vector3(0, 0, 1),
|
||||
new Vector3(-0.5f, 0, 0.5f),
|
||||
new Vector3(-0.25f, 0, 0.5f),
|
||||
new Vector3(-0.25f, 0, -1),
|
||||
new Vector3(0.25f, 0, -1),
|
||||
new Vector3(0.25f, 0, 0.5f),
|
||||
new Vector3(0.5f, 0, 0.5f),
|
||||
new Vector3(0, 0, 1),
|
||||
new Vector3(0, 0, -1)
|
||||
};
|
||||
|
||||
private GWindZone instance;
|
||||
private void OnEnable()
|
||||
{
|
||||
instance = target as GWindZone;
|
||||
if (instance.enabled)
|
||||
{
|
||||
}
|
||||
SceneView.duringSceneGui += DuringSceneGUI;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
SceneView.duringSceneGui -= DuringSceneGUI;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
instance.DirectionX = EditorGUILayout.FloatField("Direction X", instance.DirectionX);
|
||||
instance.DirectionZ = EditorGUILayout.FloatField("Direction Z", instance.DirectionZ);
|
||||
instance.Speed = EditorGUILayout.FloatField("Speed", instance.Speed);
|
||||
instance.Spread = EditorGUILayout.FloatField("Spread", instance.Spread);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
instance.SyncTransform();
|
||||
}
|
||||
}
|
||||
|
||||
private void DuringSceneGUI(SceneView sv)
|
||||
{
|
||||
instance.SyncDirection();
|
||||
|
||||
Handles.color = instance.enabled ? Color.cyan : Color.gray;
|
||||
CompareFunction zTest = Handles.zTest;
|
||||
Handles.zTest = CompareFunction.LessEqual;
|
||||
Matrix4x4 handlesMatrix = Handles.matrix;
|
||||
|
||||
float arrowSize = 5;
|
||||
Handles.matrix = Matrix4x4.TRS(
|
||||
instance.transform.position,
|
||||
instance.transform.rotation,
|
||||
Vector3.one * arrowSize);
|
||||
Handles.DrawPolyLine(arrowShape);
|
||||
|
||||
Handles.matrix = Matrix4x4.TRS(
|
||||
instance.transform.position,
|
||||
instance.transform.rotation * Quaternion.Euler(0, 0, 90),
|
||||
Vector3.one * arrowSize);
|
||||
Handles.DrawPolyLine(arrowShape);
|
||||
|
||||
Handles.matrix = handlesMatrix;
|
||||
Handles.zTest = zTest;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2cad0ba10f6f85242bfbe13cda046f17
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user