내 코드가 불완전하지만 ... 또한 매우 간단합니다. 응답 할 수 있으면 Visual Studio Intellisense 및 auto를 사용할 수있을만큼 충분히 인식하고 있습니다. 몇 가지를 채우십시오 ... 미안, 긴 밤이었습니다.업데이트 및 IEnumerator가있는 Unity의 데이터 손실
나는 세 개의 기본 스크립트를 가지고 있습니다 ... 이것은 체인의 주요 링크이며,받은 데이터를 전달합니다. 그러나 이후 AddToStack() 메서드를 필터링 할 때; 출력은 그러나 ... ... 1 (X91) 잡 ... (1) (X9)가
지금내가 쥐게하고는 10-90 흐르는하지만 여전히 ... 나는 돈있어 보내기
입니다 왜 내 데이터의 90 %가 떨어지는 지 알지 못합니다. Unity Engine이나 다른 무엇인가의 흐름이 엉망이 되었습니까? XD 나는 단결감이있는 것 같아. dataStrength 그것이 임계 값 이상이면 임계 값과 지연없이 작은 경우에 지연 데이터를 송신 -
1) 차를 다음과 같이
스크립트이다. 2.)는 update 메소드를 사용하여 public 입력이 0보다 큰지 확인하고, 그렇다면 목록에 입력을 저장하는 메소드를 시작한 후 다음 입력을 위해 입력을 0으로 재설정합니다. 그런 다음 "A"를 누르면 목록을 반복하여 합계를냅니다.
SCRIPT ONE은
private float totalStrength = 0;
public float activationThreshold;
public float signalStrength;
public bool showPackets = true;
public bool showFullDebug = true;
public Stack<float> signals = new Stack<float>();
void Start()
{
nodeGrowthThreshold = 60; //Just temporary arbitrary numeric values...
activationThreshold = 20; //The default values if not set.
path = GetComponent<Path>();
}
private void Update()
{
if (signalStrength > 0)
{
if (numRequests.Equals(nodeGrowthThreshold)) { StartCoroutine(NodeGrow()); StopCoroutine(NodeGrow()); }
if (totalStrength >= activationThreshold)
{
StartCoroutine(AddToStack());
StopCoroutine(AddToStack());
signalStrength = 0;
if (showPackets || showFullDebug) { StartCoroutine(ReadStack()); StopCoroutine(ReadStack()); }
StartCoroutine(WriteStack());
StopCoroutine(WriteStack());
totalStrength -= activationThreshold;
signalStrength = 0;
signals.Clear();
}
else if (totalStrength < activationThreshold)
{
StartCoroutine(AddToStack());
StopCoroutine(AddToStack());
signalStrength = 0;
}
}
if (showFullDebug) { print("Node receieved: " + numRequests + " requests."); }
}
private IEnumerator AddToStack()
{
if (!showFullDebug) { print("Node added signal: " + signalStrength + " to storage stack"); }
signals.Push(signalStrength);
numRequests++;
totalStrength += signalStrength;
yield return null;
}
private IEnumerator WriteStack()
{
if (showFullDebug) { print("Node is passing stack of stack size..." + signals.Count); }
if (signals.Count > 0)
{
foreach (float signal in signals.ToArray()) { path.input = signal; if (showFullDebug) { print(signal); } print("Sending... " + signal); /**NOT CAPTURING DATA FAST ENOUGH. DATA IS SENDING FAST ENOUGH THOUGH.**/} }
yield return null;
}
SCRIPT 두 (리시버)
public class Out : MonoBehaviour
{
public float input = 0;
private float savedOutput = 0;
public bool showFullDebug = true;
public List<float> savedInput = new List<float>();
public Queue<float> output = new Queue<float>();
private void Update()
{
if (input > 0) {
//StartCoroutine(Save());
//StopCoroutine(Save());\
Save();
input = 0;
}
if (Input.GetKeyDown(KeyCode.A)) { print(savedOutput); }
}
private void Save()
{
savedInput.Add(input);
output.Enqueue(input);
foreach (float num in savedInput.ToArray()) { savedOutput += num; }
//yield return null;
}
}
도울 수있는 사람에게 감사합니다 (DATA 조건을 샌드).
Notes :- 내가 사용한 데이터는 시뮬레이션을 위해 100 회 통과 한 플로트의 경우 분명히 1이었습니다. - 볼 수 있듯이 IEnumerators 및 방금 메서드를 정상적으로 시도했지만 ... 데이터가 떨어지는 이유를 모르겠다.
부딪 혔기 때문에 늦게 게시하고 더미에서 길을 잃었을 수 있습니다. – DDeathlonger