我有一张桌子EmpDetails:
DeptID EmpName Salary
Engg Sam 1000
Engg Smith 2000
HR Denis 1500
HR Danny 3000
IT David 2000
IT John 3000
Run Code Online (Sandbox Code Playgroud)
我需要进行查询,找出每个部门的最高薪水.
我是C#/ Unity的新手(温柔) - 我正在尝试创建自己的脚本,向Inspector添加一个公共变量,这样我就可以让一个脚本适用于多个GameObjects(或者我认为).
脚本非常简单.
它适用于PC,但它不适用于Android.
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.EventSystems;
public class BtnLoadScene : MonoBehaviour {
public Object SceneObj;
private string SceneName;
public void LoadLevel()
{
SceneName = SceneObj.name;
Debug.Log (SceneName);
SceneManager.LoadScene(SceneName);
}
}
Run Code Online (Sandbox Code Playgroud)
我将此脚本作为组件附加到驱动场景加载的所有按钮(在整个应用程序中).同样,这里的值是我可以将我的"场景"从assets文件夹拖到检查器/组件中(因此我不必显式管理"整数"或"字符串" - 它将全部通过对象引用).
再次,这适用于PC UPDATE:根据评论中的建议,我在独立播放器中尝试了这个并且它失败了.这仅适用于Unity编辑器.当我为Android构建时(是的它编译并且我可以安装APK)它不起作用 - 第一个场景加载,按钮响应我的触摸,我看到它"压下",但亚行抛出:
12-23 15:37:27.028 14816 14847 I Unity : NullReferenceException: Object reference not set to an instance of an object
12-23 15:37:27.028 14816 14847 I Unity : at BtnLoadScene.LoadLevel () [0x00000] in <filename unknown>:0
12-23 15:37:27.028 14816 …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用System.DateTime.Now.ToString()和Convert.ToDateTime,并遇到了一些奇怪的行为.我已将问题缩小到Convert.ToDateTime.由于某种原因,使用System.DateTime.Now设置的DateTime类型与从字符串转换的DateTime类型不同.但是,当您输出其中任何一个时,它们看起来是相同的.
(我尝试使用Trim(),TrimStart()和TrimEnd()无济于事.)
在统一运行之后,这是控制台中的输出:http: //imgur.com/1ZIdPH4
using UnityEngine;
using System;
public class DateTimeTest : MonoBehaviour {
void Start () {
//Save current time as a DateTime type
DateTime saveTime = System.DateTime.Now;
//Save above DateTime as a string
string store = saveTime.ToString();
//Convert it back to a DateTime type
DateTime convertedTime = Convert.ToDateTime(store);
//Output both DateTimes
Debug.Log(saveTime + "\n" + convertedTime);
//Output whether or not they match.
if (saveTime == convertedTime)
Debug.Log("Match: Yes");
else
Debug.Log("Match: No");
//Output both DateTimes converted to …Run Code Online (Sandbox Code Playgroud) 你什么时候使用其中一个?
public interface IFriendly
{
string GetFriendly();
}
public abstract class Person: IFriendly
{
public abstract string GetFriendly();
}
Run Code Online (Sandbox Code Playgroud)
VS.
public interface IFriendly
{
string GetFriendly();
}
public abstract class Person
{
// some other stuff i would like subclasses to have
}
public abstract class Employee : Person, IFriendly
{
public string GetFriendly()
{
return "friendly";
}
}
Run Code Online (Sandbox Code Playgroud):我是从分析数据集MNIST在C#http://yann.lecun.com/exdb/mnist/
我正在尝试Int32从二进制文件中读取第一个:
FileStream fileS = new FileStream(fileName, FileMode.Open, FileAccess.Read);
BinaryReader reader = new BinaryReader(fileS);
int magicNumber = reader.ReadInt32();
Run Code Online (Sandbox Code Playgroud)
但是,它给了我一个无意义的数字:50855936.
如果我使用 File.ReadAllBytes()
buffer = File.ReadAllBytes(fileName);
Run Code Online (Sandbox Code Playgroud)
然后查看字节,它工作正常(前四个字节现在代表2049),我做了什么错误的BinaryReader?
文件格式如下(我正在尝试读取第一个幻数):
All the integers in the files are stored in the MSB first (high endian) format used by most non-Intel processors. Users of Intel processors and other low-endian machines must flip the bytes of the header.
Run Code Online (Sandbox Code Playgroud)
TRAINING SET LABEL FILE(train-labels-idx1-ubyte):
[offset] [type] [value] [description]
0000 32 bit integer 0x00000801(2049) magic number (MSB …Run Code Online (Sandbox Code Playgroud) 我不知道如何处理这个问题或者是否有任何内置的Unity函数可以帮助解决这个问题所以任何建议都值得赞赏.
我想在设定半径范围内围绕给定点生成游戏对象.但是,它们在此半径中的位置应随机选择.该位置应与原点(在地面上)具有相同的Y轴.下一个主要问题是每个对象不应该与另一个游戏对象发生冲突和重叠,也不应该进入他们的个人空间(橙色圆圈).
到目前为止我的代码不是很好:
public class Spawner : MonoBehaviour {
public int spawnRadius = 30; // not sure how large this is yet..
public int agentRadius = 5; // agent's personal space
public GameObject agent; // added in Unity GUI
Vector3 originPoint;
void CreateGroup() {
GameObject spawner = GetRandomSpawnPoint ();
originPoint = spawner.gameObject.transform.position;
for (int i = 0; i < groupSize; i++) {
CreateAgent ();
}
}
public void CreateAgent() {
float directionFacing = Random.Range (0f, 360f);
// need to …Run Code Online (Sandbox Code Playgroud) 我正在尝试在Unity 4中进行3D观看模拟,用户可以选择一个对象并移动鼠标使其绕其旋转(360度)。帮助将不胜感激,如果它是用C#编写的,那就太好了!(但这不是必须的)在此先感谢!
c# ×6
.net ×1
binary ×1
camera ×1
datetime ×1
endianness ×1
gameobject ×1
mnist ×1
mouse ×1
object ×1
oop ×1
sql ×1
sql-server ×1
t-sql ×1
unity5 ×1