浏览代码

BackCompat fix for 2017.1 (EditorApplication.playmodeStateChanged deprecated in 2018)

/develop-generalizationTraining-TrainerController
Brian Sterling 6 年前
当前提交
f229e9ff
共有 2 个文件被更改,包括 38 次插入2 次删除
  1. 18
      unity-environment/Assets/ML-Agents/Scripts/RpcCommunicator.cs
  2. 22
      unity-environment/Assets/ML-Agents/Scripts/SocketCommunicator.cs

18
unity-environment/Assets/ML-Agents/Scripts/RpcCommunicator.cs


var result = m_client.Exchange(WrapMessage(unityOutput, 200));
unityInput = m_client.Exchange(WrapMessage(null, 200)).UnityInput;
#if UNITY_EDITOR
#if UNITY_2017_2_OR_NEWER
#else
EditorApplication.playmodeStateChanged += HandleOnPlayModeChanged;
#endif
#endif
return result.UnityInput;
}

}
#if UNITY_EDITOR
#if UNITY_2017_2_OR_NEWER
/// <summary>
/// When the editor exits, the communicator must be closed
/// </summary>

Close();
}
}
#else
/// <summary>
/// When the editor exits, the communicator must be closed
/// </summary>
private void HandleOnPlayModeChanged()
{
// This method is run whenever the playmode state is changed.
if (!EditorApplication.isPlayingOrWillChangePlaymode)
{
Close();
}
}
#endif
#endif
}

22
unity-environment/Assets/ML-Agents/Scripts/SocketCommunicator.cs


unityInput = UnityMessage.Parser.ParseFrom(Receive()).UnityInput;
#if UNITY_EDITOR
#if UNITY_2017_2_OR_NEWER
#else
EditorApplication.playmodeStateChanged += HandleOnPlayModeChanged;
#endif
#endif
return initializationInput.UnityInput;

}
#if UNITY_EDITOR
#if UNITY_2017_2_OR_NEWER
void HandleOnPlayModeChanged(PlayModeStateChange state)
private void HandleOnPlayModeChanged(PlayModeStateChange state)
if (state == PlayModeStateChange.ExitingPlayMode)
if (state==PlayModeStateChange.ExitingPlayMode)
#else
/// <summary>
/// When the editor exits, the communicator must be closed
/// </summary>
private void HandleOnPlayModeChanged()
{
// This method is run whenever the playmode state is changed.
if (!EditorApplication.isPlayingOrWillChangePlaymode)
{
Close();
}
}
#endif
#endif
}
正在加载...
取消
保存