我在 Windows 10 64 位上使用 unity 5.4.1f1 Personal
我将解释我所做的所有步骤以及迄今为止我尝试过的所有事情。
我第一次使用原始代码创建了一个新的 c# 文件: 现在,当我按 Escape 键时,它将返回编辑器,但不会退出游戏!使用[InitializeOnLoad]时,您无法停止编辑器播放按钮并退出游戏。要退出游戏,您只能在独立模式下使用“构建并运行”来完成,然后您可以使用 Application.Quit();
using UnityEditor;
using UnityEngine;
using System.Collections;
[InitializeOnLoad]
public class FullscreenPlayMode : MonoBehaviour {
//The size of the toolbar above the game view, excluding the OS border.
private static int tabHeight = 22;
static FullscreenPlayMode()
{
EditorApplication.playmodeStateChanged -= CheckPlayModeState;
EditorApplication.playmodeStateChanged += CheckPlayModeState;
EditorApplication.update += Update;
}
static void CheckPlayModeState()
{
if (EditorApplication.isPlaying)
{
FullScreenGameWindow();
}
else
{
CloseGameWindow();
}
}
static EditorWindow GetMainGameView(){
EditorApplication.ExecuteMenuItem("Window/Game");
System.Type …
Run Code Online (Sandbox Code Playgroud) 我有两个脚本附加到同一个emptygameobject.第一个脚本是:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
public class SpawnObjects : MonoBehaviour
{
public int numberOfObjects;
public GameObject objectToPlace;
public Vector3 newObjectsSize = new Vector3(5, 5, 5);
public float spawnSpeed = 0.1f;
private int wallsLengthX;
private int wallsLengthZ;
private int wallsPosX;
private int wallsPosZ;
private int currentObjects;
private List<GameObject> objects = new List<GameObject>();
void Start()
{
var wi = GetComponent<Walls>();
wallsLengthX = (int)wi.lengthX;
wallsLengthZ = (int)wi.lengthZ;
wallsPosX = (int)wi.wallsStartPosition.x;
wallsPosZ = (int)wi.wallsStartPosition.z;
StartCoroutine(Spawn());
}
IEnumerator Spawn() …
Run Code Online (Sandbox Code Playgroud) 问题是我有两个着色器。如果我在游戏运行时更改着色器,它将不会生效。仅当我使用当前着色器启动游戏时,它才会使用该着色器,但不会使用我切换到的着色器。
我看到了这段代码,但它正在切换材质,我想切换着色器。我的意思是在同一个游戏对象上的着色器之间切换。我不确定这段代码中应该包含哪些材料?
var materials : Material[];
var count = 0;
function OnMouseDown() {
if (count == materials.Length - 1)
count = 0;
else
count++;
renderer.material = materials[count];
}
Run Code Online (Sandbox Code Playgroud) private void button13_Click(object sender, EventArgs e)
{
button13.ForeColor = Color.Red;
debugMode = true;
}
Run Code Online (Sandbox Code Playgroud)
我点击按钮后想要跟随设置:
button13.ForeColor = Color.Red;
debugMode = true;
Run Code Online (Sandbox Code Playgroud)
而下一次我会点击按钮,该按钮会回到Color.Black
和debugMode
会false
.
如果它在另一个开关上,如果按钮Color.Black
并且debugMode
是false
,我点击按钮,值会改变Color.Red
并且debugMode
是true
.
我已经有一个bool变量用于使用
debugButtonSwitch
我有这个代码:
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Android.Speech.Tts;
using System.Collections.Generic;
namespace SayItAndroid{ [Activity (Label = "SayItAndroid", MainLauncher = true)]
public class Activity1 : Activity, TextToSpeech.IOnInitListener
{
int count = 1;
TextToSpeech mTts;
public void OnInit (int status)
{
Console.WriteLine ("Listening to text to speech");
}
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
Intent checkIntent = new Intent();
checkIntent.SetAction(TextToSpeech.Engine.ActionCheckTtsData);
StartActivityForResult(checkIntent, …
Run Code Online (Sandbox Code Playgroud) 我这样做:
long[] HistogramValues = Form1.GetHistogram(bitmap);
Form1.Histograms.AddRange(HistogramValues);
Run Code Online (Sandbox Code Playgroud)
但是,直方图还包含256个值,如HistogramValues.我希望在索引[0]的直方图中,将有来自HistogramValues的256个值,然后在[1]中还有256个值,然后是[2],依此类推.
直方图是一个列表
我有这个按钮点击事件:
private void button6_Click(object sender, EventArgs e)
{
if (File.Exists(@"d:\Keywords.txt"))
{
Dictionary<string,string> test = new Dictionary<string,string>();
string value_of_each_key;
string key_of_each_line;
string line;
int index;
sr = new StreamReader(@"d:\Keywords.txt");
while (null != (line = sr.ReadLine()))
{
index = line.IndexOf(",");
key_of_each_line = line.Substring(0, index);
value_of_each_key = line.Substring(index + 1);
test.Add(key_of_each_line, value_of_each_key);
}
sr.Close();
}
using (var w = new StreamWriter(@"D:\Keywords.txt"))
{
crawlLocaly1 = new CrawlLocaly();
crawlLocaly1.StartPosition = FormStartPosition.CenterParent;
DialogResult dr = crawlLocaly1.ShowDialog(this);
if (dr == DialogResult.OK)
{
if (LocalyKeyWords.ContainsKey(mainUrl))
{
LocalyKeyWords[mainUrl].Clear();
//probably …
Run Code Online (Sandbox Code Playgroud) public static long[] GetHistogramRGB(Bitmap b)
{
long[] myHistogramBlue = new long[256];
long[] myHistogramGreen = new long[256];
long[] myHistogramRed = new long[256];
BitmapData bmData = null;
try
{
//Lock it fixed with 32bpp
bmData = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
int scanline = bmData.Stride;
System.IntPtr Scan0 = bmData.Scan0;
unsafe
{
byte* p = (byte*)(void*)Scan0;
int nWidth = b.Width;
int nHeight = b.Height;
for (int y = 0; y < nHeight; y++)
{
for (int x = 0; x < …
Run Code Online (Sandbox Code Playgroud) using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class OnMouseOverEvent : MonoBehaviour
{
public GameObject[] objects;
private Vector3[] originalpos;
private void Start()
{
originalpos = new Vector3[objects.Length];
for (int i = 0; i < objects.Length; i++)
{
originalpos[i] = objects[i].transform.position;
}
}
private void Update()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, 100))
{
if (hit.transform.tag == "Test")
{
// if (transform.position.z != originalpos.z - 3)
// StartCoroutine(moveToX(transform, new Vector3(transform.position.x, transform.position.y, transform.position.z - 3), 0.1f));
}
else …
Run Code Online (Sandbox Code Playgroud) private void List<string> removeDuplicates(
List<string> currentsites,
List<string> listintheformlevelsitesvisited)
{
}
Run Code Online (Sandbox Code Playgroud)
我想获得两个列表,但我得到错误.很多错误:
; 期望标识符预期无效令牌)无效令牌> Sysntax错误(
错误10找不到类型或命名空间名称"listintheformlevelsitesvisited"(您是否缺少using指令或程序集引用?)
错误9找不到类型或命名空间名称"removeDuplicates"(您是否缺少using指令或程序集引用?)
我想要的只是一个简单的功能,获得两个列表.怎么了 ?
for (int xx = 0; xx < piCount; xx++)
{
comboBox1.Items.Add(xx);
}
Run Code Online (Sandbox Code Playgroud)
piCount是int.它的值是8.如果我从0开始我将在comboBox 01234567中看到但我想看到12345678
c# ×10
.net ×1
arrays ×1
file-io ×1
gameobject ×1
list ×1
raycasting ×1
unity5 ×1
unityscript ×1
winforms ×1