Commit 71b97fa0 authored by 潘梓豪's avatar 潘梓豪

修改Dt

parent e8c59d86
......@@ -37,6 +37,7 @@ MonoBehaviour:
- ZeusSQLite
- HighlightingSystem
- RTVoice
- SplineMeshRenderer
showAdvancedSettings: 0
addMgrToSceneAutomatically: 0
autoUpdateReferences: 1
......
fileFormatVersion: 2
guid: d759b1e2c1fc21741baaf92df89f8079
guid: 6be031889ac72b2438330d072d6fc332
DefaultImporter:
externalObjects: {}
userData:
......
......@@ -16,12 +16,19 @@ PluginImporter:
second:
enabled: 0
settings:
Exclude Android: 0
Exclude Editor: 0
Exclude Linux64: 0
Exclude OSXUniversal: 0
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude WebGL: 0
Exclude Win: 0
Exclude Win64: 0
- first:
Android: Android
second:
enabled: 1
settings:
CPU: ARMv7
- first:
Any:
second:
......@@ -38,27 +45,27 @@ PluginImporter:
- first:
Standalone: Linux64
second:
enabled: 1
enabled: 0
settings:
CPU: AnyCPU
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 1
enabled: 0
settings:
CPU: x86_64
CPU: None
- first:
Standalone: Win
second:
enabled: 1
settings:
CPU: x86
CPU: None
- first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: x86_64
CPU: None
- first:
WebGL: WebGL
second:
......
fileFormatVersion: 2
guid: c76b7eadbb1191444941ddc8cb983867
folderAsset: yes
timeCreated: 1538144599
licenseType: Store
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: b2937462d9483194fa97a35a1667f690
timeCreated: 1538144675
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.SceneManagement;
using WSMGameStudio.Splines;
[CustomEditor(typeof(BakedSegment))]
public class BakedSegmentInspector : Editor
{
private BakedSegment _bakedSegment;
private GUIStyle _menuBoxStyle;
private GUIContent _btnConnectTarget = new GUIContent("Connect Target", "Connect target to the end of this spline");
private SerializedProperty _endPoint;
private SerializedProperty _operationTarget;
private void OnEnable()
{
_endPoint = serializedObject.FindProperty("_endPoint");
_operationTarget = serializedObject.FindProperty("_operationTarget");
}
public override void OnInspectorGUI()
{
//base.OnInspectorGUI();
_bakedSegment = (BakedSegment)target;
//Set up the box style if null
if (_menuBoxStyle == null)
{
_menuBoxStyle = new GUIStyle(GUI.skin.box);
_menuBoxStyle.normal.textColor = GUI.skin.label.normal.textColor;
_menuBoxStyle.fontStyle = FontStyle.Bold;
_menuBoxStyle.alignment = TextAnchor.UpperLeft;
}
GUILayout.BeginVertical(_menuBoxStyle);
GUILayout.Label("SEGMENT SETTINGS", EditorStyles.boldLabel);
serializedObject.Update();
EditorGUILayout.PropertyField(_endPoint, false);
EditorGUILayout.PropertyField(_operationTarget, false);
serializedObject.ApplyModifiedProperties();
GUILayout.Label("SEGMENT OPERATIONS", EditorStyles.boldLabel);
if (GUILayout.Button(_btnConnectTarget))
{
_bakedSegment.ConnectTarget();
MarkSceneAlteration(_bakedSegment);
}
GUILayout.EndVertical();
}
/// <summary>
/// Show player the scene needs to be saved
/// </summary>
private void MarkSceneAlteration(Object target)
{
if (!Application.isPlaying)
{
EditorUtility.SetDirty(target);
EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
}
}
}
fileFormatVersion: 2
guid: 6c493e2e613499840b77d41c928a3980
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEditor.SceneManagement;
using UnityEngine.SceneManagement;
using UnityEditor;
using UnityEngine;
namespace WSMGameStudio.Splines
{
[CanEditMultipleObjects]
[CustomEditor(typeof(LinkedSplineFollower))]
public class LinkedSplineFollowerInspector : Editor
{
private GUIStyle _menuBoxStyle;
SerializedProperty _followingOffset;
private void OnEnable()
{
_followingOffset = serializedObject.FindProperty("followingOffset");
}
public override void OnInspectorGUI()
{
//base.DrawDefaultInspector();
//Set up the box style if null
if (_menuBoxStyle == null)
{
_menuBoxStyle = new GUIStyle(GUI.skin.box);
_menuBoxStyle.normal.textColor = GUI.skin.label.normal.textColor;
_menuBoxStyle.fontStyle = FontStyle.Bold;
_menuBoxStyle.alignment = TextAnchor.UpperLeft;
}
GUILayout.BeginVertical(_menuBoxStyle);
GUILayout.Label("LINKED FOLLOWER SETTINGS", EditorStyles.boldLabel);
serializedObject.Update();
float offset = _followingOffset.floatValue;
EditorGUILayout.PropertyField(_followingOffset, new GUIContent("Following Offset"));
if (offset != _followingOffset.floatValue) _followingOffset.floatValue = Mathf.Abs(_followingOffset.floatValue);
serializedObject.ApplyModifiedProperties();
GUILayout.EndVertical();
}
/// <summary>
/// Show player the scene needs to be saved
/// </summary>
private void MarkSceneAlteration(Object target)
{
if (!Application.isPlaying)
{
EditorUtility.SetDirty(target);
EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
}
}
}
}
fileFormatVersion: 2
guid: b958cb71cad287449af9686d0589cd96
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using UnityEditor;
namespace WSMGameStudio.Splines
{
public class SMR_CreateObjectMenus
{
[MenuItem("WSM Game Studio/Spline Mesh Renderer/Create/Spline", false, 10)]
[MenuItem("GameObject/WSM Game Studio/Spline", false, 10)]
static void CreateNewSpline(MenuCommand menuCommand)
{
GameObject go = CreateAndSelectNewObject(menuCommand, "Spline");
Spline spline = go.AddComponent<Spline>();
ApplyDefaultTheme(spline);
}
[MenuItem("WSM Game Studio/Spline Mesh Renderer/Create/Spline Prefab Spawner", false, 10)]
[MenuItem("GameObject/WSM Game Studio/Spline Prefab Spawner", false, 10)]
static void CreateNewSplinePrefabSpawner(MenuCommand menuCommand)
{
GameObject go = CreateAndSelectNewObject(menuCommand, "SplinePrefabSpawner");
SplinePrefabSpawner spline = go.AddComponent<SplinePrefabSpawner>();
}
[MenuItem("WSM Game Studio/Spline Mesh Renderer/Create/Spline Mesh Renderer", false, 10)]
[MenuItem("GameObject/WSM Game Studio/Spline Mesh Renderer", false, 10)]
static void CreateNewSplineMeshRenderer(MenuCommand menuCommand)
{
GameObject go = CreateAndSelectNewObject(menuCommand, "SplineMeshRenderer");
GameObject aux1 = new GameObject("Aux1");
GameObject aux2 = new GameObject("Aux2");
aux1.transform.SetParent(go.transform);
aux2.transform.SetParent(go.transform);
Spline spline = go.AddComponent<Spline>();
ApplyDefaultTheme(spline);
SplineMeshRenderer splineMeshRenderer = go.AddComponent<SplineMeshRenderer>();
splineMeshRenderer.Spline = spline;
}
/// <summary>
/// Create and select new object on the Hierarchy
/// </summary>
/// <param name="menuCommand"></param>
/// <param name="name"></param>
/// <returns></returns>
private static GameObject CreateAndSelectNewObject(MenuCommand menuCommand, string name)
{
Vector3 worldPos = Vector3.zero;
if (SceneView.lastActiveSceneView.camera != null)
{
float distanceToGround;
Ray worldRay = SceneView.lastActiveSceneView.camera.ViewportPointToRay(new Vector3(0.5f, 0.5f, 1.0f));
Plane groundPlane = new Plane(Vector3.up, Vector3.zero);
groundPlane.Raycast(worldRay, out distanceToGround);
worldPos = worldRay.GetPoint(distanceToGround);
}
// Create a custom game object
GameObject newObject = new GameObject(name);
newObject.transform.position = worldPos;
// Ensure it gets reparented if this was a context click (otherwise does nothing)
GameObjectUtility.SetParentAndAlign(newObject, menuCommand.context as GameObject);
// Ensure Unique naming for this object
GameObjectUtility.EnsureUniqueNameForSibling(newObject);
// Register the creation in the undo system
Undo.RegisterCreatedObjectUndo(newObject, "Create " + newObject.name);
Selection.activeObject = newObject;
return newObject;
}
/// <summary>
/// Tries to locate and applies default UI theme
/// </summary>
/// <param name="spline"></param>
private static void ApplyDefaultTheme(Spline spline)
{
// Try to locate default theme
string path = "Assets/WSM Game Studio/Spline Mesh Renderer/Themes/SMR-Default-Theme.asset";
SMR_Theme defaultTheme = AssetDatabase.LoadAssetAtPath(path, typeof(SMR_Theme)) as SMR_Theme;
if (defaultTheme != null)
spline.Theme = defaultTheme;
}
}
}
fileFormatVersion: 2
guid: 765ea77bd22f7814c9ef3a92e34d3844
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.IO;
using UnityEditor;
using UnityEngine;
namespace WSMGameStudio.Splines
{
public class SMR_Links
{
[MenuItem("WSM Game Studio/Spline Mesh Renderer/Documentation")]
static void OpenDocumentation()
{
string documentationFolder = "WSM Game Studio/Spline Mesh Renderer/Documentation/Spline Mesh Renderer v2.1.pdf";
DirectoryInfo info = new DirectoryInfo(Application.dataPath);
string documentationPath = Path.Combine(info.Name, documentationFolder);
Application.OpenURL(documentationPath);
}
[MenuItem("WSM Game Studio/Spline Mesh Renderer/Write a Review")]
static void Review()
{
Application.OpenURL("https://assetstore.unity.com/packages/slug/129857");
}
}
}
fileFormatVersion: 2
guid: e151ad5f8fca8714295801b8c2a00146
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEditor.SceneManagement;
using UnityEngine.SceneManagement;
using UnityEngine;
using UnityEditor;
using WSMGameStudio.Splines;
[CanEditMultipleObjects]
[CustomEditor(typeof(SplineFollower))]
public class SplineFollowerInspector : Editor
{
private SplineFollower _splineFollower;
private int _selectedMenuIndex = 0;
private string[] _toolbarMenuOptions = new[] { "Follower Settings", "Linked Followers" };
private GUIStyle _menuBoxStyle;
private GUIContent _btnMoveToStart = new GUIContent("Move to Start Position", "Move object to start position along the spline");
private GUIContent _btnRestart = new GUIContent("Restart Follower", "Restarts follower to its initial position");
private SerializedProperty _splines;
private SerializedProperty _speed;
private SerializedProperty _speedUnit;
private SerializedProperty _followerBehaviour;
private SerializedProperty _customStartPosition;
private SerializedProperty _applySplineRotation;
private SerializedProperty _cycleEndStops;
private SerializedProperty _cycleStopTime;
private SerializedProperty _visualizePathOnEditor;
private SerializedProperty _followersOffset;
private SerializedProperty _linkedFollowersBehaviour;
private SerializedProperty _linkedFollowers;
private void OnEnable()
{
_splines = serializedObject.FindProperty("splines");
_speed = serializedObject.FindProperty("speed");
_speedUnit = serializedObject.FindProperty("speedUnit");
_followerBehaviour = serializedObject.FindProperty("followerBehaviour");
_customStartPosition = serializedObject.FindProperty("customStartPosition");
_applySplineRotation = serializedObject.FindProperty("applySplineRotation");
_cycleEndStops = serializedObject.FindProperty("cycleEndStops");
_cycleStopTime = serializedObject.FindProperty("cycleStopTime");
_visualizePathOnEditor = serializedObject.FindProperty("visualizePathOnEditor");
_followersOffset = serializedObject.FindProperty("followersOffset");
_linkedFollowersBehaviour = serializedObject.FindProperty("linkedFollowersBehaviour");
_linkedFollowers = serializedObject.FindProperty("linkedFollowers");
}
public override void OnInspectorGUI()
{
//base.DrawDefaultInspector();
_splineFollower = target as SplineFollower;
//Set up the box style if null
if (_menuBoxStyle == null)
{
_menuBoxStyle = new GUIStyle(GUI.skin.box);
_menuBoxStyle.normal.textColor = GUI.skin.label.normal.textColor;
_menuBoxStyle.fontStyle = FontStyle.Bold;
_menuBoxStyle.alignment = TextAnchor.UpperLeft;
}
GUILayout.BeginVertical(_menuBoxStyle);
serializedObject.Update();
_selectedMenuIndex = GUILayout.Toolbar(_selectedMenuIndex, _toolbarMenuOptions);
if (_selectedMenuIndex == (int)FollowerInspectorMenu.FollowerSettings)
{
#region FOLLOWER SETTINGS
/*
* Follower Settings
*/
GUILayout.Label("FOLLOWER SETTINGS", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(_splines, true);
GUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(_speed, false);
EditorGUILayout.PropertyField(_speedUnit, GUIContent.none, false, GUILayout.MaxWidth(50));
GUILayout.EndHorizontal();
EditorGUILayout.PropertyField(_followerBehaviour, false);
EditorGUILayout.PropertyField(_customStartPosition, false);
EditorGUILayout.PropertyField(_applySplineRotation, false);
EditorGUILayout.PropertyField(_cycleEndStops, false);
EditorGUILayout.PropertyField(_cycleStopTime, false);
EditorGUILayout.PropertyField(_visualizePathOnEditor, false);
#endregion
}
else if (_selectedMenuIndex == (int)FollowerInspectorMenu.LinkedFollowers)
{
#region LINKED FOLLOWERS
EditorGUILayout.PropertyField(_followersOffset, false);
EditorGUILayout.PropertyField(_linkedFollowersBehaviour, false);
EditorGUILayout.PropertyField(_linkedFollowers, true);
#endregion
}
serializedObject.ApplyModifiedProperties();
#region FOLLOWER OPERATIONS
/*
* Follower Operations
*/
GUILayout.Label("FOLLOWER OPERATIONS", EditorStyles.boldLabel);
GUILayout.BeginHorizontal();
if (Selection.gameObjects != null)
{
if (GUILayout.Button(_btnMoveToStart))
{
foreach (var selected in Selection.gameObjects)
{
SplineFollower follower = selected.GetComponent<SplineFollower>();
if (follower != null)
{
follower.MoveToStartPosition();
MarkSceneAlteration(selected);
}
}
}
if (GUILayout.Button(_btnRestart))
{
foreach (var selected in Selection.gameObjects)
{
SplineFollower follower = selected.GetComponent<SplineFollower>();
if (follower != null)
{
follower.RestartFollower();
MarkSceneAlteration(selected);
}
}
}
}
GUILayout.EndHorizontal();
#endregion
GUILayout.EndVertical();
}
private void OnSceneGUI()
{
_splineFollower = target as SplineFollower;
if (_splineFollower.visualizePathOnEditor)
{
Quaternion handleRotation = Tools.pivotRotation == PivotRotation.Local ? _splineFollower.transform.rotation : Quaternion.identity;
OrientedPoint[][] followerPath = _splineFollower.NormalizedOrientedPoints;
for (int splineIndex = 0; splineIndex < followerPath.Length; splineIndex++)
{
for (int pointIndex = 0; pointIndex < followerPath[splineIndex].Length; pointIndex++)
{
Vector3 pointPosition = followerPath[splineIndex][pointIndex].Position;
float size = HandleUtility.GetHandleSize(pointPosition);
size *= 3f;
Handles.color = Color.white;
if (Handles.Button(pointPosition, handleRotation, (size * 0.04f), (size * 0.06f), Handles.SphereHandleCap))
{
SceneViewZoom(pointPosition, 10f);
}
//Oriented Points Directions
Vector3 lineStart = pointPosition;
Vector3 zAxisEnd = lineStart + (followerPath[splineIndex][pointIndex].Forward) * SplineDefaultValues.DirectionScale;
Vector3 yAxisEnd = lineStart + (followerPath[splineIndex][pointIndex].Up) * SplineDefaultValues.DirectionScale;
Vector3 xAxisEnd = lineStart + (followerPath[splineIndex][pointIndex].Right) * SplineDefaultValues.DirectionScale;
DrawLine(Color.blue, lineStart, zAxisEnd);
DrawLine(Color.green, lineStart, yAxisEnd);
DrawLine(Color.red, lineStart, xAxisEnd);
}
}
}
}
/// <summary>
/// Draw a line of the selected color
/// </summary>
/// <param name="lineColor"></param>
/// <param name="lineStart"></param>
/// <param name="lineEnd"></param>
private void DrawLine(Color lineColor, Vector3 lineStart, Vector3 lineEnd)
{
Handles.color = lineColor;
Handles.DrawLine(lineStart, lineEnd);
}
/// <summary>
/// Zoom on selected point
/// </summary>
/// <param name="point"></param>
/// <param name="zoomLevel"></param>
private static void SceneViewZoom(Vector3 point, float zoomLevel)
{
if (SceneView.lastActiveSceneView != null)
SceneView.lastActiveSceneView.Frame(new Bounds(point, Vector3.one * zoomLevel), false);
}
/// <summary>
/// Show player the scene needs to be saved
/// </summary>
private void MarkSceneAlteration(Object target)
{
if (!Application.isPlaying)
{
EditorUtility.SetDirty(target);
EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
}
}
}
fileFormatVersion: 2
guid: 4c4c40444d3f65f47970a5bbd336dd3f
timeCreated: 1559842385
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 90c4c397f67884b438bf36ddd6aa07c8
timeCreated: 1538144675
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
{
"name": "SplineMeshRender-Editor",
"references": [
"SplineMeshRenderer"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
\ No newline at end of file
fileFormatVersion: 2
guid: 6da170ba123d4f245b94dc7881495c73
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.SceneManagement;
using WSMGameStudio.Splines;
[CustomEditor(typeof(SplineMeshRenderer))]
public class SplineMeshRendererInspector : Editor
{
private SplineMeshRenderer _splineMeshRenderer;
private GUIStyle _menuBoxStyle;
private GUIContent _btnPrintMeshDetails = new GUIContent("Print Mesh Details", "Prints the generated mesh details on console window when Realtime Mesh Generation is selected");
private GUIContent _btnCreateMesh = new GUIContent("Generate Mesh", "Manually generates the mesh when Manual Mesh Generation is selected");
private GUIContent _btnBakeMesh = new GUIContent("Bake Mesh", "Exports the generated mesh as a prefab (Mesh Baker Window)");
private GUIContent _btnConnectNewRenderer = new GUIContent("Connect New Renderer", string.Format("Connects a new Mesh Renderer at the end of the current one. Usefull to improve performance with occlusion culling.", System.Environment.NewLine));
private GUIContent _btnSpawnCaps = new GUIContent("Spawn Caps", "Spawn or updates start and end caps instances");
private SerializedProperty _spline;
private SerializedProperty _meshGenerationProfile;
private SerializedProperty _meshGenerationMethod;
private SerializedProperty _meshOffset;
private SerializedProperty _autoSplit;
private SerializedProperty _verticesLimit;
private SerializedProperty _startCap;
private SerializedProperty _endCap;
/// <summary>
/// Caching Serialized Properties for better performance
/// </summary>
private void OnEnable()
{
_spline = serializedObject.FindProperty("_spline");
_meshGenerationProfile = serializedObject.FindProperty("_meshGenerationProfile");
_meshGenerationMethod = serializedObject.FindProperty("_meshGenerationMethod");
_meshOffset = serializedObject.FindProperty("_meshOffset");
_autoSplit = serializedObject.FindProperty("_autoSplit");
_verticesLimit = serializedObject.FindProperty("_verticesLimit");
_startCap = serializedObject.FindProperty("_startCap");
_endCap = serializedObject.FindProperty("_endCap");
}
/// <summary>
/// Draw spline on editor
/// </summary>
private void OnSceneGUI()
{
try
{
_splineMeshRenderer = (SplineMeshRenderer)target;
if (_splineMeshRenderer.Spline != null && _splineMeshRenderer.Spline.Theme != null)
{
Handles.BeginGUI();
int posX = _splineMeshRenderer.Spline.Theme.supportsVerticalBuilding ? _splineMeshRenderer.Spline.Theme.button8PosX : _splineMeshRenderer.Spline.Theme.button6PosX;
int posY = _splineMeshRenderer.Spline.Theme.supportsVerticalBuilding ? _splineMeshRenderer.Spline.Theme.button8PosY : _splineMeshRenderer.Spline.Theme.button6PosY;
if (_splineMeshRenderer.MeshGenerationMethod == MeshGenerationMethod.Manual)
{
// Scene Window buttons
if (GUI.Button(new Rect(posX, posY, _splineMeshRenderer.Spline.Theme.buttonSize, _splineMeshRenderer.Spline.Theme.buttonSize), _splineMeshRenderer.Spline.Theme.MeshIcon))
{
_splineMeshRenderer.ExtrudeMesh();
MarkSceneAlteration();
}
// Add icons to inspector buttons
_btnCreateMesh.image = _splineMeshRenderer.Spline.Theme.SmallMeshIcon;
}
else if (_splineMeshRenderer.MeshGenerationMethod == MeshGenerationMethod.Realtime)
{
// Scene Window buttons
if (GUI.Button(new Rect(posX, posY, _splineMeshRenderer.Spline.Theme.buttonSize, _splineMeshRenderer.Spline.Theme.buttonSize), _splineMeshRenderer.Spline.Theme.LogIcon))
{
_splineMeshRenderer.PrintMeshDetails();
}
// Add icons to inspector buttons
_btnPrintMeshDetails.image = _splineMeshRenderer.Spline.Theme.SmallLogIcon;
}
Handles.EndGUI();
}
}
catch (System.Exception ex)
{
Debug.LogError(ex.Message);
}
}
/// <summary>
/// Custom inspector
/// </summary>
public override void OnInspectorGUI()
{
try
{
//base.OnInspectorGUI();
_splineMeshRenderer = (SplineMeshRenderer)target;
//Set up the box style if null
if (_menuBoxStyle == null)
{
_menuBoxStyle = new GUIStyle(GUI.skin.box);
_menuBoxStyle.normal.textColor = GUI.skin.label.normal.textColor;
_menuBoxStyle.fontStyle = FontStyle.Bold;
_menuBoxStyle.alignment = TextAnchor.UpperLeft;
}
GUILayout.BeginVertical(_menuBoxStyle);
#region Mesh Generation Settings
GUILayout.Label("MESH GENERATION SETTINGS", EditorStyles.boldLabel);
serializedObject.Update();
EditorGUILayout.PropertyField(_spline, false);
EditorGUILayout.PropertyField(_meshGenerationProfile, false);
EditorGUILayout.PropertyField(_meshGenerationMethod, false);
EditorGUILayout.PropertyField(_meshOffset, false);
EditorGUILayout.PropertyField(_autoSplit, false);
EditorGUILayout.PropertyField(_verticesLimit, false);
GUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(_startCap, false);
EditorGUILayout.PropertyField(_endCap, false);
GUILayout.EndHorizontal();
serializedObject.ApplyModifiedProperties();
GUILayout.Label("MESH OPERATIONS", EditorStyles.boldLabel);
GUILayout.BeginHorizontal();
GUILayout.BeginVertical();
if (_splineMeshRenderer.MeshGenerationMethod != MeshGenerationMethod.Manual)
{
if (GUILayout.Button(_btnPrintMeshDetails))
{
_splineMeshRenderer.PrintMeshDetails();
}
}
else
{
if (GUILayout.Button(_btnCreateMesh))
{
_splineMeshRenderer.ExtrudeMesh();
MarkSceneAlteration();
}
}
if (GUILayout.Button(_btnConnectNewRenderer))
{
Selection.activeGameObject = _splineMeshRenderer.ConnectNewRenderer();
MarkSceneAlteration();
}
GUILayout.EndVertical();
GUILayout.BeginVertical();
if (GUILayout.Button(_btnBakeMesh))
{
BakeMeshWindow.ShowWindow();
}
if (GUILayout.Button(_btnSpawnCaps))
{
_splineMeshRenderer.SpawnCaps();
MarkSceneAlteration();
}
GUILayout.EndVertical();
GUILayout.EndHorizontal();
#endregion
GUILayout.EndVertical();
}
catch (System.Exception ex)
{
if (ex.GetType() != typeof(ExitGUIException)) // ExitGUIException is used by the Unity GUI System as a flag to stop the GUI Loop
Debug.LogError(ex.Message);
}
}
/// <summary>
/// Show player the scene needs to be saved
/// </summary>
private void MarkSceneAlteration()
{
if (!Application.isPlaying)
{
EditorUtility.SetDirty(_splineMeshRenderer);
EditorUtility.SetDirty(_splineMeshRenderer.Spline); //Spline must also be saved to update serialized references
if (_splineMeshRenderer.GeneratedMeshes != null)
foreach (var meshObj in _splineMeshRenderer.GeneratedMeshes)
EditorUtility.SetDirty(meshObj.GetGameObject);
if (_splineMeshRenderer.GeneratedColliders != null)
foreach (var colliderObj in _splineMeshRenderer.GeneratedColliders)
EditorUtility.SetDirty(colliderObj.GetGameObject);
EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
}
}
}
fileFormatVersion: 2
guid: 411f24bbf65d6e94487dfe4b2cff078d
timeCreated: 1538144675
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.SceneManagement;
using WSMGameStudio.Splines;
[CustomEditor(typeof(SplinePrefabSpawner))]
public class SplinePrefabSpawnerInspector : Editor
{
private SplinePrefabSpawner _splinePrefabSpawner;
private GUIStyle _menuBoxStyle;
private GUIContent _btnSpawn = new GUIContent("Spawn", "Spawn instances of the selected prefabs");
private GUIContent _btnReset = new GUIContent("Reset", "Removes all spawned instances from scene");
private SerializedProperty _splines;
private SerializedProperty _spawningMethod;
private SerializedProperty _instances;
private SerializedProperty _prefabs;
private SerializedProperty _spawnOffset;
private void OnEnable()
{
_splines = serializedObject.FindProperty("splines");
_spawningMethod = serializedObject.FindProperty("spawningMethod");
_instances = serializedObject.FindProperty("instances");
_prefabs = serializedObject.FindProperty("prefabs");
_spawnOffset = serializedObject.FindProperty("spawnOffset");
}
public override void OnInspectorGUI()
{
//base.OnInspectorGUI();
_splinePrefabSpawner = (SplinePrefabSpawner)target;
//Set up the box style if null
if (_menuBoxStyle == null)
{
_menuBoxStyle = new GUIStyle(GUI.skin.box);
_menuBoxStyle.normal.textColor = GUI.skin.label.normal.textColor;
_menuBoxStyle.fontStyle = FontStyle.Bold;
_menuBoxStyle.alignment = TextAnchor.UpperLeft;
}
GUILayout.BeginVertical(_menuBoxStyle);
#region SPAWNER SETTINGS
/*
* Spawner Settings
*/
GUILayout.Label("SPAWNER SETTINGS", EditorStyles.boldLabel);
serializedObject.Update();
EditorGUILayout.PropertyField(_splines, true);
EditorGUILayout.PropertyField(_spawningMethod, false);
EditorGUILayout.PropertyField(_instances, false);
EditorGUILayout.PropertyField(_prefabs, true);
EditorGUILayout.PropertyField(_spawnOffset, false);
serializedObject.ApplyModifiedProperties();
#endregion
#region SPAWNER OPERATIONS
/*
* Spawner Operations
*/
GUILayout.Label("SPAWNER OPERATIONS", EditorStyles.boldLabel);
GUILayout.BeginHorizontal();
if (GUILayout.Button(_btnSpawn))
{
_splinePrefabSpawner.SpawnPrefabs();
MarkSceneAlteration();
}
if (GUILayout.Button(_btnReset))
{
_splinePrefabSpawner.ResetObjects();
MarkSceneAlteration();
}
GUILayout.EndHorizontal();
#endregion
GUILayout.EndVertical();
}
/// <summary>
/// Show player the scene needs to be saved
/// </summary>
private void MarkSceneAlteration()
{
if (!Application.isPlaying)
{
EditorUtility.SetDirty(_splinePrefabSpawner);
EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
}
}
}
fileFormatVersion: 2
guid: d2026f4067b6b41498d29b8e12047ac6
timeCreated: 1538430437
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: dbabe7c93b36105409fa0f3d31da5ade
folderAsset: yes
timeCreated: 1538144599
licenseType: Store
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using UnityEngine.Serialization;
namespace WSMGameStudio.Splines
{
public class BakedSegment : MonoBehaviour
{
[FormerlySerializedAs("endPoint")]
[SerializeField] private Transform _endPoint;
[SerializeField] private GameObject _operationTarget;
public Transform EndPoint
{
get { return _endPoint; }
set { _endPoint = value; }
}
public GameObject OperationTarget
{
get { return _operationTarget; }
set { _operationTarget = value; }
}
/// <summary>
/// Connect target at the end of this segment
/// </summary>
public void ConnectTarget()
{
ConnectTarget(_operationTarget);
}
/// <summary>
/// Connect target at the end of this segment
/// </summary>
/// <param name="target"></param>
public void ConnectTarget(GameObject target)
{
if (_endPoint == null)
{
Debug.Log(string.Format("{0}: End point not found", name));
return;
}
if (target != null)
{
target.transform.position = _endPoint.position;
target.transform.rotation = _endPoint.rotation;
}
ResetOperationTarget();
}
/// <summary>
/// Reset operation target
/// </summary>
private void ResetOperationTarget()
{
_operationTarget = null;
}
}
}
fileFormatVersion: 2
guid: 59247a4d90ac471439ba1e38bf351ceb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
namespace WSMGameStudio.Splines
{
/// <summary>
/// Bezier curve used in spline
/// </summary>
public static class Bezier
{
/// <summary>
/// Get bezier point between three control points (QUADRATIC BEZIER)
/// </summary>
/// <param name="p0"></param>
/// <param name="p1"></param>
/// <param name="p2"></param>
/// <param name="t"></param>
/// <returns></returns>
public static Vector3 GetPoint(Vector3 p0, Vector3 p1, Vector3 p2, float t)
{
t = Mathf.Clamp01(t);
float oneMinusT = 1f - t;
return
oneMinusT * oneMinusT * p0 +
2f * oneMinusT * t * p1 +
t * t * p2;
}
/// <summary>
/// Gets beziers first derivative (QUADRATIC BEZIER)
/// </summary>
/// <param name="p0"></param>
/// <param name="p1"></param>
/// <param name="p2"></param>
/// <param name="t"></param>
/// <returns></returns>
public static Vector3 GetFirstDerivative(Vector3 p0, Vector3 p1, Vector3 p2, float t)
{
return
2f * (1f - t) * (p1 - p0) +
2f * t * (p2 - p1);
}
/// <summary>
/// Get bezier point between four control points (CUBIC BEZIER)
/// </summary>
/// <param name="p0"></param>
/// <param name="p1"></param>
/// <param name="p2"></param>
/// <param name="p3"></param>
/// <param name="t"></param>
/// <returns></returns>
public static Vector3 GetPoint(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float t)
{
t = Mathf.Clamp01(t);
float oneMinusT = 1f - t;
return
oneMinusT * oneMinusT * oneMinusT * p0 +
3f * oneMinusT * oneMinusT * t * p1 +
3f * oneMinusT * t * t * p2 +
t * t * t * p3;
}
/// <summary>
/// Gets beziers first derivative (CUBIC BEZIER)
/// </summary>
/// <param name="p0"></param>
/// <param name="p1"></param>
/// <param name="p2"></param>
/// <param name="p3"></param>
/// <param name="t"></param>
/// <returns></returns>
public static Vector3 GetFirstDerivative(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float t)
{
t = Mathf.Clamp01(t);
float oneMinusT = 1f - t;
return
3f * oneMinusT * oneMinusT * (p1 - p0) +
6f * oneMinusT * t * (p2 - p1) +
3f * t * t * (p3 - p2);
}
/// <summary>
/// Get bezier point rotation (CUBIC BEZIER)
/// </summary>
/// <param name="r0"></param>
/// <param name="r1"></param>
/// <param name="r2"></param>
/// <param name="r3"></param>
/// <param name="t"></param>
/// <returns></returns>
public static Quaternion GetPointRotation(Quaternion r0, Quaternion r1, Quaternion r2, Quaternion r3, float t)
{
Vector4 p0 = Convert.QuaternionToVector4(r0);
Vector4 p1 = Convert.QuaternionToVector4(r1);
Vector4 p2 = Convert.QuaternionToVector4(r2);
Vector4 p3 = Convert.QuaternionToVector4(r3);
Vector4 rotation;
t = Mathf.Clamp01(t);
float oneMinusT = 1f - t;
rotation = oneMinusT * oneMinusT * oneMinusT * p0 +
3f * oneMinusT * oneMinusT * t * p1 +
3f * oneMinusT * t * t * p2 +
t * t * t * p3;
return Convert.Vector4ToQuaternion(rotation);
}
}
}
fileFormatVersion: 2
guid: 149527f80e8af5f4db7fa60cd76feb78
timeCreated: 1538144692
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
namespace WSMGameStudio.Splines
{
public static class Convert
{
public static Quaternion Vector3ToQuaternion(Vector3 v3)
{
return Quaternion.Euler(v3);
}
public static Vector3 QuaternionToVector3(Quaternion q)
{
return q.eulerAngles;
}
public static Quaternion Vector4ToQuaternion(Vector4 v4)
{
return new Quaternion(v4.x, v4.y, v4.z, v4.w);
}
public static Vector4 QuaternionToVector4(Quaternion q)
{
return new Vector4(q.x, q.y, q.z, q.w);
}
}
}
fileFormatVersion: 2
guid: e6218ce49f2541d4f855119d0f210b43
timeCreated: 1559654867
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
namespace WSMGameStudio.Splines
{
public interface IGeneratedMesh
{
Mesh Mesh { get; }
GameObject GetGameObject { get; }
}
}
fileFormatVersion: 2
guid: 8912f4c0253b42249903228f91b509bf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
namespace WSMGameStudio.Splines
{
public class LinkedSplineFollower : MonoBehaviour
{
public float followingOffset;
private SplineFollower _master;
private LinkedFollowerBehaviour _followerBehaviour;
private Transform _transform;
private Vector3 _startPosition;
private Vector3 _endPosition;
private Quaternion _startRotation;
private Quaternion _endRotation;
private int _currentSplineIndex;
private int _currentPointIndex;
private int _nextPointIndex;
private float _segmentProgress = 0;
public OrientedPoint[][] NormalizedOrientedPoints { get { return _master != null ? _master.NormalizedOrientedPoints : null; } }
public SplineFollower Master
{
get { return _master; }
set { _master = value; }
}
public LinkedFollowerBehaviour FollowerBehaviour
{
get { return _followerBehaviour; }
set { _followerBehaviour = value; }
}
private bool HasOverflown
{
get { return _currentSplineIndex <= -1; }
}
protected void Start()
{
_transform = GetComponent<Transform>();
}
/// <summary>
/// Follow master position. Invoked from master update method, to ensure synchronized movement
/// </summary>
/// <param name="followOffset"></param>
public void FollowMaster(float followOffset)
{
if (NormalizedOrientedPoints == null) return; //Master is null or oriented points not calculated
int nextIndexDirection = _master.GoingForward ? 1 : -1; //1 = forwards | -1 = backwards
float masterProgress = _master.GoingForward ? Mathf.Clamp01(Master.SegmentProgress) : 1f - Mathf.Clamp01(Master.SegmentProgress);
float targetPosition = _master.CurrentPointIndex + masterProgress - followOffset;
_currentSplineIndex = _master.CurrentSplineIndex;
_currentPointIndex = _master.GoingForward || _currentPointIndex > 0? Mathf.FloorToInt(targetPosition) : Mathf.CeilToInt(targetPosition);
_nextPointIndex = _currentPointIndex + nextIndexDirection;
_segmentProgress = Mathf.Abs(targetPosition - _currentPointIndex);
_segmentProgress = _master.GoingForward ? _segmentProgress : 1f - _segmentProgress;
// Calculate current spline and point index based on the follow offset
while (_currentPointIndex < 0)
{
ChangeSpline(-1);
if (_followerBehaviour == LinkedFollowerBehaviour.Overflow && HasOverflown)
break;
_currentPointIndex = (NormalizedOrientedPoints[_currentSplineIndex].Length - 1) + _currentPointIndex;
_nextPointIndex = _currentPointIndex + nextIndexDirection;
}
_transform = _transform == null ? GetComponent<Transform>() : _transform;
if (_followerBehaviour == LinkedFollowerBehaviour.Overflow && HasOverflown)
{
CalculateOverflownPosition(followOffset);
}
else
{
//Validate next point on next spline
if (_nextPointIndex > NormalizedOrientedPoints[_currentSplineIndex].Length - 1)
{
ChangeSpline(1);
_currentPointIndex = 0;
_nextPointIndex = 1;
}
else if (_nextPointIndex < 0) //Validate next point on previous spline
{
ChangeSpline(-1);
if (HasOverflown) //Next point has overflown
{
CalculateOverflownPosition(followOffset);
return;
}
_currentPointIndex = (NormalizedOrientedPoints[_currentSplineIndex].Length - 1);
_nextPointIndex = _currentPointIndex - 1;
}
_startPosition = NormalizedOrientedPoints[_currentSplineIndex][_currentPointIndex].Position;
_endPosition = NormalizedOrientedPoints[_currentSplineIndex][_nextPointIndex].Position;
_startRotation = NormalizedOrientedPoints[_currentSplineIndex][_currentPointIndex].Rotation;
_endRotation = NormalizedOrientedPoints[_currentSplineIndex][_nextPointIndex].Rotation;
_transform.position = Vector3.Lerp(_startPosition, _endPosition, _segmentProgress);
_transform.rotation = Quaternion.Slerp(_startRotation, _endRotation, _segmentProgress);
}
}
/// <summary>
/// Calculate Overflown Position
/// </summary>
/// <param name="followOffset"></param>
private void CalculateOverflownPosition(float followOffset)
{
_transform.position = _master.transform.position - (_master.transform.forward * followOffset);
_transform.rotation = _master.transform.rotation;
}
/// <summary>
/// Cicly through splines
/// </summary>
/// <param name="splineDirection"></param>
private void ChangeSpline(int splineDirection)
{
_currentSplineIndex = _currentSplineIndex + splineDirection;
if (_followerBehaviour == LinkedFollowerBehaviour.Wrap)
{
_currentSplineIndex = _currentSplineIndex < 0 ? (NormalizedOrientedPoints.Length - 1) : _currentSplineIndex; // Return to top
_currentSplineIndex = _currentSplineIndex > (NormalizedOrientedPoints.Length - 1) ? 0 : _currentSplineIndex; // Return to bottom
}
else if (_followerBehaviour == LinkedFollowerBehaviour.Overflow)
{
_currentSplineIndex = _currentSplineIndex < 0 ? -1 : _currentSplineIndex; // Overflow first spline. -1 used as reference value
_currentSplineIndex = _currentSplineIndex > (NormalizedOrientedPoints.Length - 1) ? (NormalizedOrientedPoints.Length - 1) : _currentSplineIndex;
}
}
/// <summary>
/// Move linked follower to its initial position on the editor
/// </summary>
public void MoveToStartPosition(float followOffset)
{
FollowMaster(followOffset);
}
}
}
fileFormatVersion: 2
guid: 3bf4690968fca0d4a9e40cb09b1973f3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 2c5d30e4e4051a34f81393ecc3bde498
timeCreated: 1538144692
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: ee4f7c7e003909944a20e0e683dbf771
timeCreated: 1559653267
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 79162e2746bcfb34db517257d9c12542
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 0977aa2d5194f1e4081e775d23c237c3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
namespace WSMGameStudio.Splines
{
public class SMR_IgnoredObject : MonoBehaviour
{
}
}
fileFormatVersion: 2
guid: 564f48a58c7ffb14d8fd93ac4f570aca
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment