我只有一个分支.几个月来我一直在用
git push origin master
Run Code Online (Sandbox Code Playgroud)
提交到我的本地存储库.昨晚我对我的本地存储库进行了一些小的更改,并试图使用相同的命令,我得到了这个错误:
error: RPC failed; result=22, HTTP code = 411
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly
Everything up-to-date
Run Code Online (Sandbox Code Playgroud)
我用谷歌搜索并发现了这个问题和这个问题,但这些问题的答案都没有解决我的问题.
大多数答案都表明头部脱落的问题.但我不认为我的头是分离的.我也不认为我在错误的分支上(因为我只有一个分支......)
我做了一些实验来弄清楚什么是错的,这是我得到的结果:
(1)首先是我的git status
输出
Run Code Online (Sandbox Code Playgroud)# On branch master # Untracked files: # (use "git add <file>..." to include in what will be committed) # # egal.aux # egal.blg # egal.out # egal.pdf # egalcar.aux # egalcar.blg # egalcar.pdf nothing added to …
关于协同程序(在Unity3D和其他地方)如何工作,我感到困惑和好奇.coroutine是新线程吗?他们说Unity的文档:
协程是一个可以暂停执行(yield)直到给定的YieldInstruction完成的函数.
他们在这里有C#示例:
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
void Start() {
print("Starting " + Time.time);
StartCoroutine(WaitAndPrint(2.0F));
print("Before WaitAndPrint Finishes " + Time.time);
}
IEnumerator WaitAndPrint(float waitTime) {
yield return new WaitForSeconds(waitTime);
print("WaitAndPrint " + Time.time);
}
}
Run Code Online (Sandbox Code Playgroud)
我对这个例子有很多疑问:
在上面的例子中,哪一行是协程?是WaitAndPrint()
一个协程?是WaitForSeconds()
一个协程?
在这一行:yield return new WaitForSeconds(waitTime);
为什么都yield
和return
存在?我在Unity文档中读到"yield语句是一种特殊的返回,它确保函数将在下次调用yield语句后继续执行." 如果yield
是特别的return
,return
这里做了什么?
为什么我们要退货IEnumerator
?
是否StartCoroutine
开始新线程?
WaitAndPrint() …
我正在使用Microsoft TypeScript-React-Starter并在以下期间遇到此编译错误npm start
:
./src/index.tsx
(16,5): error TS2605: JSX element type 'App' is not a constructor function for JSX elements.
Types of property 'setState' are incompatible.
Type '{ <K extends never>(f: (prevState: null, props: {}) => Pick<null, K>, callback?: (() => any) | un...' is not assignable to type '{ <K extends never>(f: (prevState: {}, props: any) => Pick<{}, K>, callback?: (() => any) | undef...'.
Types of parameters 'f' and 'f' are incompatible.
Type '(prevState: {}, …
Run Code Online (Sandbox Code Playgroud) Unity3D Profiler为我提供了主要关于垃圾收集的峰值.在下面的截图中,三个红色尖峰代表我在游戏中的三个档位.这些摊位中的每一个都是100 + ms,大部分时间都花在了上面TrackDependencies
.
根据Unity指令,我尝试将其添加到我的代码中:
if (Time.frameCount % 30 == 0)
{
System.GC.Collect();
}
Run Code Online (Sandbox Code Playgroud)
这没有用.我仍然有尖峰,他们仍然需要100 + ms.到底发生了什么,我该怎么做才能优化我的游戏?
PS:
我GameObject
在游戏中动态创建并摧毁了很多s.这可能是个问题吗?
我在循环或数组中没有字符串连接作为返回值,如帖子中所述.
optimization garbage-collection memory-management unity-game-engine
我有一个html5范围输入和一个文本框输入.当范围更改时,文本框将更新.但是我该怎么办呢,当我在文本框中输入数字时,范围输入会更新?
这是我目前的代码:
<div>
<input id="slider" type="range" min="0" max="200" />
<input id="box" type="text" value="0"/>
</div>
<script>
var slider = document.getElementById('slider');
$('#box').change(function(){slider.value=parseInt(this.value)});
</script>
Run Code Online (Sandbox Code Playgroud)
当我编辑文本框时,我的滑块(范围输入)不会改变.我究竟做错了什么?是不是我不应该使用slider.value来更新滑块?如果这就是原因,那么这样做的正确方法是什么?
我有一个React v15网络应用程序在localhost运行正常.然而,当我将它部署到GitHub页面时,我有一个CSS module is undefined
错误:
我为这个问题设置了一个测试回购:https://github.com/ZeningQu/test-repo/tree/master
如果您克隆了repo并运行yarn start
,您应该能够看到该load-data-pane
组件:
但是当你这样做时yarn run deploy
,GitHub页面基本上是空的:
更多信息:
是否可以将C/C++函数回调到Unity脚本中,前提是您可以从脚本创建新线程?我试过但是一旦脚本执行完毕,Unity就会崩溃.
我GOOGLE了一下,发现这个线程它说
Unity不是回调也不是线程安全,任何对扩展UnityEngine.Object的类的访问只允许在Unity脚本运行的同一个线程内,而不是来自其他线程的同步,也不允许来自COM/OS异步操作的异步回调
如果是这种情况,有两种可能的方法:
(1)编写一个包装器,获取这些回调并对这些东西进行排队,然后公开一个函数,允许统一请求下一个事件/数据对象或任何阻塞,无线程形式(2)使回调调用到某个东西上的静态函数从System.Object扩展并编写与上面相同的逻辑,以请求有关扩展UnityEngine.Object的类的信息
但我想如果我创建一个线程并回调到该线程,它会没问题吧?我想是这样,因为我读过像线程这一块,介绍如何让C函数调用回C#的功能.所以我推断如果我创建一个新线程,它不再是Unity,它只是单声道和C#.
这是我的代码崩溃Unity:
C++代码:
#include <iostream>
// #include "stdafx.h"
typedef int (__stdcall * Callback)(const char* text);
Callback Handler = 0;
extern "C" __declspec(dllexport)
void __stdcall SetCallback(Callback handler) {
Handler = handler;
}
extern "C" __declspec(dllexport)
void __stdcall TestCallback() {
int retval = Handler("hello world");
}
Run Code Online (Sandbox Code Playgroud)
C#代码:
using UnityEngine;
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
class UnManagedInterop : MonoBehaviour {
private delegate int Callback(string text);
private Callback mInstance; // …
Run Code Online (Sandbox Code Playgroud) 我正在尝试Vega-Lite
从名为的项目中导入一个React类Voyager
。
这是我的代码:
import * as React from 'react';
import {VegaLite} from 'datavoyager/build/components/vega-lite';
export interface Props {
spec: any;
logger: any;
}
export const View = ({spec, logger}: Props) => {
return(
<VegaLite spec={spec} logger={logger}/>
);
};
Run Code Online (Sandbox Code Playgroud)
这是我的错误:
[ts] JSX元素类型'VegaLite'不是JSX元素的构造函数。属性'componentDidMount'在类型'VegaLite'中受保护,但在类型'ElementClass'中是公共的。
我知道在课堂上Vega-Lite
,函数componentDidMount()
确实是protected
。但是,如何解决此错误?
PS:我试过设置allowSyntheticDefaultImports
到true
我的tsconfig.json
,但同样的错误仍然存在。
我有一个C#脚本,通过System.Runtime.Interop调用C函数.我设法调用了C函数,但是在管理C和C#之间的缓冲区时遇到了问题.
在我的情况下,C是(数据)生产者,C#是消费者.
我的问题是当我在C#中读取数据时,有时我得到正确的值但有时我得到NULL.
这个问题已经解决了.我正在粘贴错误的方法,并在此与我分享正确的方法.
C#代码是一个统一脚本(Mono开发的一部分),C代码在Xcode中,这意味着我不能在我的C代码中使用.Net框架函数.
这是我的C代码(写入缓冲区并从缓冲区读取):
static char InteropBF[INTEROP_BUFFER_SIZE];
static int mutex = 0;
// for the c code to put its message in buffer
void PutToBuffer(char* name, char* content)
{
while (mutex>0);
mutex++;
strcat(InteropBF, name);
strcat(InteropBF, ",");
strcat(InteropBF, content);
strcat(InteropBF, ",");
printf("Interop Buffer: %s\n", InteropBF);
mutex--;
}
// for the C# code to poll and read from C
void* ReadFromBuffer(void* temp)
{
while (mutex>0);
mutex++;
strcpy(temp, InteropBF);
// memcpy(temp, InteropBF, INTEROP_BUFFER_SIZE);
strcpy(InteropBF, "");
mutex--;
return temp; …
Run Code Online (Sandbox Code Playgroud) 我正在尝试向div
. 我的CSS是这样的:
border: solid;
border-width: 1px;
Run Code Online (Sandbox Code Playgroud)
然而,结果边框在我的浏览器中看起来并不那么细。如下图所示,左侧和底部的边框看起来比右侧和顶部的边框更粗。
我想让边框同样细。我尝试添加
shape-rendering: crispEdges;
Run Code Online (Sandbox Code Playgroud)
但它并没有改变外观。JS Fiddle 示例在这里。
我在 Chrome 版本 41.0.2272.101 m 中尝试了这一点 - 它看起来很糟糕。我也在 IE 中尝试过这个 - 看起来不错。所以我知道这不是我的显示器...
c# ×3
reactjs ×3
interop ×2
c ×1
callback ×1
coroutine ×1
css ×1
deployment ×1
git ×1
github ×1
github-pages ×1
html5 ×1
javascript ×1
jquery ×1
optimization ×1
typescript ×1
webpack ×1
xcode ×1