GitHub
4 年前
当前提交
c1c7360b
共有 12 个文件被更改,包括 219 次插入 和 48 次删除
-
14Project/Assets/ML-Agents/Examples/3DBall/Prefabs/3DBall.prefab
-
44Project/Assets/ML-Agents/Examples/3DBall/Scenes/3DBall.unity
-
1Project/Assets/ML-Agents/Examples/3DBall/Scripts/Ball3DAgent.cs
-
44Project/Assets/ML-Agents/Examples/Basic/Scenes/Basic.unity
-
4Project/Assets/ML-Agents/Examples/Basic/Scripts/BasicActuatorComponent.cs
-
2Project/Assets/ML-Agents/Examples/Basic/Scripts/BasicController.cs
-
8com.unity.ml-agents/Runtime/Training/ReplayBuffer.cs
-
21com.unity.ml-agents/Runtime/Training/Trainer.cs
-
24com.unity.ml-agents/Runtime/Training/TrainingForwardTensorApplier.cs
-
13com.unity.ml-agents/Runtime/Training/TrainingModelRunner.cs
-
81com.unity.ml-agents/Runtime/Training/MyTimeScaleSetting.cs
-
11com.unity.ml-agents/Runtime/Training/MyTimeScaleSetting.cs.meta
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
public class MyTimeScaleSetting : MonoBehaviour |
|||
{ |
|||
// s_Instance is used to cache the instance found in the scene so we don't have to look it up every time.
|
|||
private static MyTimeScaleSetting s_Instance = null; |
|||
|
|||
|
|||
// A static property that finds or creates an instance of the manager object and returns it.
|
|||
public static MyTimeScaleSetting instance |
|||
{ |
|||
get |
|||
{ |
|||
if (s_Instance == null) |
|||
{ |
|||
// FindObjectOfType() returns the first AManager object in the scene.
|
|||
s_Instance = FindObjectOfType(typeof(MyTimeScaleSetting)) as MyTimeScaleSetting; |
|||
} |
|||
|
|||
// If it is still null, create a new instance
|
|||
if (s_Instance == null) |
|||
{ |
|||
var obj = new GameObject("MyTimeScaleSetting"); |
|||
s_Instance = obj.AddComponent<MyTimeScaleSetting>(); |
|||
} |
|||
|
|||
return s_Instance; |
|||
} |
|||
} |
|||
|
|||
|
|||
// Ensure that the instance is destroyed when the game is stopped in the editor.
|
|||
void OnApplicationQuit() |
|||
{ |
|||
s_Instance = null; |
|||
} |
|||
|
|||
|
|||
[SerializeField] |
|||
float m_TimeScale = 1f; |
|||
|
|||
public float MyTimeScale |
|||
{ |
|||
get { return m_TimeScale; } |
|||
set |
|||
{ |
|||
m_TimeScale = value; |
|||
Time.timeScale = value; |
|||
} |
|||
} |
|||
|
|||
[SerializeField] |
|||
float m_Greedy = 0f; |
|||
public float GreedyEpislon |
|||
{ |
|||
get { return m_Greedy; } |
|||
set { m_Greedy = value; } |
|||
} |
|||
|
|||
[SerializeField] |
|||
bool m_Train = true; |
|||
public bool IsTraining |
|||
{ |
|||
get { return m_Train; } |
|||
set { m_Train = value; } |
|||
} |
|||
|
|||
// Start is called before the first frame update
|
|||
void Start() |
|||
{ |
|||
DontDestroyOnLoad(this.gameObject); |
|||
} |
|||
|
|||
// Update is called once per frame
|
|||
void Update() |
|||
{ |
|||
Time.timeScale = m_TimeScale; |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: b1f466227168940b7ac84e337e9fcc8a |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue