Ejemplo n.º 1
0
    /// <summary>
    /// When we change playmode, we make sure to reset all iml models
    /// </summary>
    /// <param name="playModeStatus"></param>
    private static void PlayModeStateChangedLogic(PlayModeStateChange playModeStatus)
    {
        // We load models if we are entering a playmode or editormode
        if (playModeStatus == PlayModeStateChange.EnteredEditMode || playModeStatus == PlayModeStateChange.EnteredPlayMode)
        {
            // Reload all models (if we can) when we enter playmode or when we come back to the editor
            foreach (var MLComponent in m_IMLComponents)
            {
                // Reload models
                MLComponent.LoadAllModelsFromDisk();
                // Run them (if marked with RunOnAwake)
                MLComponent.RunAllModels();
            }
            //Debug.Log("**Models reconfigured in editor status: " + playModeStatus + "**");
        }

        // We save models if we are leaving a playmode or editormode
        if (playModeStatus == PlayModeStateChange.ExitingEditMode || playModeStatus == PlayModeStateChange.ExitingPlayMode)
        {
            foreach (var MLComponent in m_IMLComponents)
            {
                MLComponent.StopAllModels();
                MLComponent.SaveAllModels();
            }
        }
    }
    /// <summary>
    /// When we change playmode, we make sure to reset all iml models
    /// </summary>
    /// <param name="playModeStatus"></param>
    private static void PlayModeStateChangedLogic(PlayModeStateChange playModeStatus)
    {
        #region Enter Events

        // We load models if we are entering a playmode (not required when leaving playmode)
        if (playModeStatus == PlayModeStateChange.EnteredPlayMode)
        {
            // Reload all models (if we can) when we enter playmode or when we come back to the editor
            foreach (var MLComponent in m_IMLComponents)
            {
                MLComponent.LoadDataAndRunOnAwakeModels();

                //// Reload models
                //MLComponent.LoadAllModelsFromDisk(reCreateModels: true);
                //// Run them (if marked with RunOnAwake)
                //MLComponent.RunAllModels();
            }
            //Debug.Log("**Models reconfigured in editor status: " + playModeStatus + "**");
        }

        if (playModeStatus == PlayModeStateChange.EnteredEditMode)
        {
            foreach (var MLComponent in m_IMLComponents)
            {
                MLComponent.updateGameObjectImage();
                MLComponent.GetAllNodes();
                MLComponent.UpdateGameObjectNodes(changingPlayMode: true);
                MLComponent.UpdateScriptNodes(changingPlayMode: true);
            }
        }

        #endregion

        #region Exit Events

        // Remove any scriptNodes added during playtime when leaving playMode
        if (playModeStatus == PlayModeStateChange.ExitingPlayMode)
        {
            foreach (var MLComponent in m_IMLComponents)
            {
                MLComponent.UpdateGameObjectNodes(changingPlayMode: true);
                MLComponent.UpdateScriptNodes(changingPlayMode: true);
            }
        }

        // We stop models if we are leaving a playmode or editormode
        if (playModeStatus == PlayModeStateChange.ExitingEditMode || playModeStatus == PlayModeStateChange.ExitingPlayMode)
        {
            foreach (var MLComponent in m_IMLComponents)
            {
                MLComponent.StopAllModels();
            }
        }

        #endregion
    }
Ejemplo n.º 3
0
 /// <summary>
 /// When the scene opens we will clear and find all the imlComponents
 /// </summary>
 /// <param name="scene"></param>
 /// <param name="mode"></param>
 private static void SceneOpenedLogic(UnityEngine.SceneManagement.Scene scene, UnityEditor.SceneManagement.OpenSceneMode mode)
 {
     //Debug.Log("SceneOpened");
     ClearIMLComponents();
     FindIMLComponents();
     // Reload all models (if we can) when we enter playmode or when we come back to the editor
     foreach (var MLComponent in m_IMLComponents)
     {
         // Get all nodes
         MLComponent.GetAllNodes();
         // Reload models
         MLComponent.LoadAllModelsFromDisk(reCreateModels: true);
         // Run them (if marked with RunOnAwake)
     }
 }