Example #1
0
        void LoadDisplaySettings()
        {
            // Global display settings:
            var guids = AssetDatabase.FindAssets("t:GlobalDisplaySettings");

            if (guids.Length == 0)
            {
                Debug.LogWarning("Could not find DisplaySettings asset. Will use default settings instead.");
                _globalDisplaySettings = ScriptableObject.CreateInstance <GlobalDisplaySettings>();
            }
            else
            {
                var path = AssetDatabase.GUIDToAssetPath(guids[0]);
                _globalDisplaySettings = AssetDatabase.LoadAssetAtPath <GlobalDisplaySettings>(path);
            }

            _capFunctions = new Dictionary <GlobalDisplaySettings.HandleType, Handles.CapFunction>();
            _capFunctions.Add(GlobalDisplaySettings.HandleType.Circle, Handles.CylinderHandleCap);
            _capFunctions.Add(GlobalDisplaySettings.HandleType.Sphere, Handles.SphereHandleCap);
            _capFunctions.Add(GlobalDisplaySettings.HandleType.Square, Handles.CubeHandleCap);
        }
Example #2
0
        // Draw the path when path objected is not selected (if enabled in settings)
        private void OnDrawGizmos()
        {
            // Only draw path gizmo if the path object is not selected
            // (editor script is resposible for drawing when selected)
            GameObject selectedObj = UnityEditor.Selection.activeGameObject;

            if (selectedObj != gameObject)
            {
                if (path != null)
                {
                    path.UpdateTransform(transform);
                    if (globalEditorDisplaySettings == null)
                    {
                        globalEditorDisplaySettings = GlobalDisplaySettings.Load();
                    }

                    if (globalEditorDisplaySettings.visibleWhenNotSelected)
                    {
                        Gizmos.color = globalEditorDisplaySettings.bezierPath;
                        for (int i = 0; i < path.NumPoints; i++)
                        {
                            int nextI = i + 1;
                            if (nextI >= path.NumPoints)
                            {
                                if (path.isClosedLoop)
                                {
                                    nextI %= path.NumPoints;
                                }
                                else
                                {
                                    break;
                                }
                            }

                            Gizmos.DrawLine(path.GetPoint(i), path.GetPoint(nextI));
                        }
                    }
                }
            }
        }