コード例 #1
0
ファイル: PathCreator.cs プロジェクト: idemax/SCar3D
        // Draw the path when path objected is not selected (if enabled in settings)
        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));
                        }
                    }
                }
            }
        }
コード例 #2
0
        // Draw the path when path objected is not selected (if enabled in settings)
        void OnDrawGizmos()
        {
            if (path != null)
            {
                if (globalEditorDisplaySettings == null)
                {
                    globalEditorDisplaySettings = GlobalDisplaySettings.Load();
                }

                if (globalEditorDisplaySettings.alwaysDrawPath)
                {
                    // 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)
                    {
                        Gizmos.color = globalEditorDisplaySettings.bezierPath;

                        for (int i = 0; i < path.NumVertices; i++)
                        {
                            int nextI = i + 1;
                            if (nextI >= path.NumVertices)
                            {
                                if (path.isClosedLoop)
                                {
                                    nextI %= path.NumVertices;
                                }
                                else
                                {
                                    break;
                                }
                            }
                            Gizmos.DrawLine(path.vertices[i], path.vertices[nextI]);
                        }
                    }
                }
            }
        }
コード例 #3
0
    //IntializeScene. Check for excistence of key gameobjects and set reference variables.
    private void InitializeScene()
    {
        // Create settings folders.
        if (!AssetDatabase.IsValidFolder("Assets/Logs"))
        {
            AssetDatabase.CreateFolder("Assets", "Logs");
        }
        if (!AssetDatabase.IsValidFolder("Assets/VRSettings"))
        {
            AssetDatabase.CreateFolder("Assets", "VRSettings");
        }
        if (!AssetDatabase.IsValidFolder("Assets/VRSettings/PathCreator"))
        {
            AssetDatabase.CreateFolder("Assets/VRSettings", "PathCreator");
        }
        if (!AssetDatabase.IsValidFolder("Assets/VRSettings/Controllers"))
        {
            AssetDatabase.CreateFolder("Assets/VRSettings", "Controllers");
        }
        if (!AssetDatabase.IsValidFolder("Assets/VRSettings/Displays"))
        {
            AssetDatabase.CreateFolder("Assets/VRSettings", "Displays");
        }
        if (!AssetDatabase.IsValidFolder("Assets/VRSettings/Actors"))
        {
            AssetDatabase.CreateFolder("Assets/VRSettings", "Actors");
        }

        // Check for main default objects.
        GameObject obj;

        string[] DefaultObjects = { "Actors", "Controllers", "MQTT Client", "Paths", "Logger" };
        foreach (string objName in DefaultObjects)
        {
            if (!GameObject.Find(objName))
            {
                Debug.Log(string.Format("Creating Object: {0}..", objName));
                obj = new GameObject(objName);
                // Special circumstances.
                switch (objName)
                {
                case "MQTT Client":
                    obj.AddComponent <Gimbl.MQTTClient>();
                    break;

                case "Logger":
                    _logger = obj.AddComponent <Gimbl.LoggerObject>();
                    Gimbl.LoggerSettings asset = CreateInstance <Gimbl.LoggerSettings>();
                    AssetDatabase.CreateAsset(asset, "Assets/VRSettings/LoggerSettings.asset");
                    _logger.settings = asset;
                    break;
                }
                // Things have changed. Mark scene for save.
                UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
            }
            else
            {
                obj = GameObject.Find(objName);
            }
            switch (objName)
            {
            // Assign for controls.
            case "MQTT Client":
                _client       = obj.GetComponent <Gimbl.MQTTClient>();
                obj.hideFlags = HideFlags.HideInHierarchy;
                break;

            case "Paths":
                break;

            case "Controllers":
                obj.hideFlags = HideFlags.None;
                break;

            case "Logger":
                _logger          = obj.GetComponent <Gimbl.LoggerObject>();
                _logger.settings = (LoggerSettings)AssetDatabase.LoadAssetAtPath("Assets/VRSettings/LoggerSettings.asset", typeof(LoggerSettings));
                obj.hideFlags    = HideFlags.HideInHierarchy;
                break;

            case "Actors":
                break;
            }
        }
        // Set client IP settings from stored.
        _client.ip = EditorPrefs.GetString("JaneliaVR_MQTT_IP");
        if (_client.ip == "")
        {
            _client.ip = "127.0.0.1";
        }
        _client.port = EditorPrefs.GetInt("JaneliaVR_MQTT_Port");
        if (_client.port == 0)
        {
            _client.port = 1883;
        }
        // Set default properties.
        msgSettings.sendFrameMsg      = EditorPrefs.GetBool("Gimbl_sendFrameMsg", false);
        sessionSettings.externalStart = EditorPrefs.GetBool("Gimbl_externalStart", false);
        sessionSettings.externalLog   = EditorPrefs.GetBool("Gimbl_externalLog", false);
        // Check for global display settings path creator.
        if (UnityEditor.AssetDatabase.FindAssets("t:GlobalDisplaySettings").Length == 0)
        {
            PathCreation.GlobalDisplaySettings asset = CreateInstance <PathCreation.GlobalDisplaySettings>();
            AssetDatabase.CreateAsset(asset, "Assets/VRSettings/PathCreator/GlobalDisplaySettings.asset");
        }
    }