Пример #1
0
    private IEnumerator LoadWorld()
    {
        // Debug.Log("Hello CLOiSim World!!!!!");
        // Debug.Log("World: " + worldFileName);

        var sdf = new SDF.Root();

        sdf.SetTargetLogOutput(simulationDisplay);
        sdf.SetWorldFileName(worldFileName);
        sdf.fileDefaultPaths.AddRange(fileRootDirectories);
        sdf.modelDefaultPaths.AddRange(modelRootDirectories);
        sdf.worldDefaultPaths.AddRange(worldRootDirectories);

        if (sdf.DoParse())
        {
            yield return(new WaitForSeconds(0.001f));

            var loader = new SDF.Import.Loader(modelsRoot);
            loader.SetMainCamera(mainCamera);
            loader.DoImport(sdf.World());

            // for GUI
            simulationDisplay?.ClearEventMessage();
            followingList?.UpdateList();
        }
        else
        {
            var errorMessage = "Parsing failed!!!, failed to load world file: " + worldFileName;
            Debug.LogError(errorMessage);
            simulationDisplay?.SetEventMessage(errorMessage);
        }

        yield return(null);
    }
    private IEnumerator LoadSdfModels()
    {
        // Debug.Log("Hello CLOiSim World!!!!!");
        Debug.Log("World: " + worldFileName);

        // Main models loader
        if (!doNotLoad && !string.IsNullOrEmpty(worldFileName))
        {
            var sdf = new SDF.Root();
            sdf.SetWorldFileName(worldFileName);
            sdf.fileDefaultPath = filesRootDirectory;
            sdf.modelDefaultPaths.AddRange(modelRootDirectories);
            sdf.worldDefaultPath.AddRange(worldRootDirectories);

            if (sdf.DoParse())
            {
                yield return(new WaitForSeconds(0.005f));

                var importer = new SDFImporter();
                importer.SetRootObject(modelsRoot);
                importer.SetMainCamera(defaultCameraName);
                importer.Start(sdf.World());
            }
            else
            {
                Debug.LogError("Parsing failed!!");
            }
        }

#if UNITY_EDITOR
        if (pauseOnStart)
        {
            EditorApplication.isPaused = true;
        }
#endif

        // for GUI
        var followingListObject = GameObject.Find(followingListName);
        var followingTargetList = followingListObject.GetComponent <FollowingTargetList>();
        followingTargetList.UpdateList();
    }