我在base64中编码了wav文件(参考资料/声音中的audioClipName.txt).
然后我尝试解码它,从它做一个AudioClip并像这样播放:
public static void CreateAudioClip()
{
string s = Resources.Load<TextAsset> ("Sounds/audioClipName").text;
byte[] bytes = System.Convert.FromBase64String (s);
float[] f = ConvertByteToFloat(bytes);
AudioClip audioClip = AudioClip.Create("testSound", f.Length, 2, 44100, false, false);
audioClip.SetData(f, 0);
AudioSource as = GameObject.FindObjectOfType<AudioSource> ();
as.PlayOneShot (audioClip);
}
private static float[] ConvertByteToFloat(byte[] array)
{
float[] floatArr = new float[array.Length / 4];
for (int i = 0; i < floatArr.Length; i++)
{
if (BitConverter.IsLittleEndian)
Array.Reverse(array, i * 4, 4);
floatArr[i] = BitConverter.ToSingle(array, i * 4);
}
return floatArr; …Run Code Online (Sandbox Code Playgroud) 我定义了这个方法:
public static List<T2> ConvertList<T1, T2>(List<T1> param) where T1:class where T2:class
{
List<T2> result = new List<T2>();
foreach (T1 p in param)
result.Add((T2)p);
return result;
}
Run Code Online (Sandbox Code Playgroud)
用于将类型1的列表转换为类型2的列表.
不幸的是我忘记了,C#编译器在这个阶段不能说可以T1转换为T2,所以它抛出错误:
错误CS0030:无法将T1类型转换为T2
有人可以指导我如何正确地做到这一点?我现在需要这个方法只将自定义类的列表转换为列表object,因此在.NET中所有内容都object应该起作用.
基本上我所期望的是一些语法告诉编译器T2(object)是T1(MyClass)的基础,所以类似于:
public static List<T2> ConvertList<T1, T2>(List<T1> param) where T2: base of T1
Run Code Online (Sandbox Code Playgroud)
(... 其中T2:T1的基数)
所以我有直接使用Azure门户购买的SSL证书。
现在,我从Azure迁移,并希望从Azure中删除除我的SQL Server和数据库之外的所有资源。
当我尝试删除应用服务证书时,出现此错误:
操作名称删除App Service证书时间戳记Tue May 30 2017 11:47:36 GMT + 0200(欧洲标准时间)发起者-说明无法删除App Service证书。:删除“ JerrySwitalski”应用服务证书失败,因为源订阅中仍存在从应用服务证书派生的导入证书。导入的证书:/subscriptions/77cf2897-8c03-413c-8e16-38ea0e025d72/resourceGroups/01/providers/Microsoft.Web/certificates/JerrySwitalski-01-SouthCentralUSwebspace,/subscriptions/77cf2897-8c03-413c-8e16-38ea0e025d72/resourceGroups/01 /providers/Microsoft.Web/certificates/JerrySwitalski-01-WestEuropewebspace
如您在下面看到的,我只有SQL Server和数据库以及此证书:

如何永久删除此证书?
我刚刚在代码中发现了一些非常奇怪的东西.我错误地把索引作为这样的索引:
int a = 1;
int b = 1;
Dictionary<int, SomeClass> dic = new Dictionary<int, SomeClass> ();
dic[a -+ b].Field = 0;
Run Code Online (Sandbox Code Playgroud)
正如你所看到的那样," - +"opperator真的像" - "一样工作.无论如何,代码很开心,编译直到找到它.
它是Unity3d中用于游戏的代码的一部分,我现在正在处理它.
问题是:这是正常的吗?或者这是单声道2中的已知错误并且已修复.我找不到任何关于它的信息.
这个问题是针对Unity3D的实用程序脚本的,但问题只在于C#;
我提供的脚本字符串(onClickCallbackPath)看起来像" GameObjectName.ComponentTypeName.CallbackDelegateName ".
查找GameObject和Component不是问题,但请看一下这段代码:
string[] ss = onClickCallbackPath.Split ("." [0]);
Transform onClickTarget = Tools.FindDeepChild (transform.root, ss [0]);
MonoBehaviour[] allComponentsOnTarget = onClickTarget.GetComponents<MonoBehaviour> ();
foreach (MonoBehaviour mb in allComponentsOnTarget)
{
if (mb.GetType ().Name == ss [1])
{
MethodInfo[] methods = mb.GetType ().GetMethods (BindingFlags.Public);
foreach (MethodInfo mi in methods)
{
if (mi.Name == ss [2])
{
// And here is how I imagine it to work, and look for something similar...
// but of course there is no GetInstance method …Run Code Online (Sandbox Code Playgroud) 我刚刚开始在团结中学习c#.我按照教程,但我想添加一些东西.
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class PlayerController : MonoBehaviour {
public float speed;
public Text countText;
public Text winText;
private Rigidbody rb;
private int count;
void Start ()
{
rb = GetComponent<Rigidbody>();
count = 0;
SetCountText ();
winText.text = "";
}
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rb.AddForce (movement * speed);
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag ( "Pick Up")) …Run Code Online (Sandbox Code Playgroud) 这可能是非常非常基本的问题,也是noob的错误,但是我才刚开始为Amiga平台做游戏,并尝试编译仅包含以下内容的测试程序集源文件:
move.b $#FF,D0
Run Code Online (Sandbox Code Playgroud)
使用vasmm68k_mot(我在OSX上使用制作的vasm汇编器make CPU=m68k SYNTAX=mot)
但我有编译器错误:
“ ./test.asm”的第1行中的错误2:未知助记符<.b>
就像我说的那样,可能是我使用了错误的语法,或者是更明显的用法,但是我是菜鸟,无法在网络中找到任何帮助(可能是因为我问的是错误的问题)。
任何帮助赞赏。