我是react-native和android的初学者,我尝试将unity视图集成到react-native中,然后我按照RN Docs做某事。 The Docs
一切看起来都不错,UnityView会显示出来。但问题是,Unity没有更新,看起来像是暂停了。
也许我忽略了什么?
一些代码:
public UnityView(Context context, AttributeSet attrs, int defStyle) {
...
// AddUnityView
mUnityPlayer = UnityManager.instance().getUnityPlayer();
LinearLayout mParent=(LinearLayout)findViewById(R.id.realView);
View mView=mUnityPlayer.getView();
mParent.addView(mView);
mUnityPlayer.requestFocus();
...}
'use strict'
import React, { Component } from 'react';
import { View } from 'react-native';
import { requireNativeComponent } from 'react-native';
class UnityView extends Component {
setNativeProps(props){
this.root.setNativeProps(props);
}
render() {
return (
<UnityViewNative
{...this.props}
style={[
{backgroundColor: 'transparent'},
this.props.style,
]}
ref={(r)=>{this.root = r}}
/>
);
}
}
UnityView.propTypes = {
};
const UnityViewNative = requireNativeComponent('RCTUnityView', UnityView);
export default UnityView;
答案 0 :(得分:0)
团结球员实际上可能会被暂停。
你可以试试这个......
int main( void )
{
int counter = 0;
...
char *output = getInitials( input, &counter );
for(int i = 0; i < counter ; i++)
{
printf("%c",toupper(output[i]));
}
...
}
/**
* The "string" typedef is an abomination that *will* lead you astray,
* and I want to have words with whoever created the CS50 header.
*
* They're trying to abstract away the concept of a "string" in C, but
* they've done it in such a way that the abstraction is "leaky" -
* in order to use and access the input object correctly, you *need to know*
* the representation behind the typedef, which in this case is `char *`.
*
* Secondly, not every `char *` object points to the beginning of a
* *string*.
*
* Hiding pointer types behind typedefs is almost always bad juju.
*/
char *getInitials( const char *input, int *counter )
{
...
(*counter)++; // parens are necessary here
output = appendArray(output,input[i],*counter); // need leading * here
...
}