这就是我声明列表的方式:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEngine;
using UnityEditorInternal;
public class ConversationTrigger : MonoBehaviour
{
public List<Conversation> conversations = new List<Conversation>();
Run Code Online (Sandbox Code Playgroud)
这是使用此 List 的编辑器脚本:
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
[CustomEditor(typeof(ConversationTrigger))]
public class ConversationTriggerEditor : Editor
{
private ReorderableList ConversationsList;
private void OnEnable()
{
ConversationTrigger conversationtrigger = (ConversationTrigger)target;
ConversationsList = new ReorderableList(serializedObject, serializedObject.FindProperty("conversations"), true, true, true, true);
}
public override void OnInspectorGUI()
{
serializedObject.Update();
ConversationsList.DoLayoutList();
serializedObject.ApplyModifiedProperties();
EditorUtility.SetDirty(target);
} …Run Code Online (Sandbox Code Playgroud) Transform[] drawns = GetComponentsInChildren<Transform>()
Run Code Online (Sandbox Code Playgroud)
这还包括父级,但我只想获取脚本所连接的转换的子级。
问题是它在循环中也破坏了父级。绘制数组中的第一项是父项:
case DrawStates.DrawOnGizmosRuntime:
drawOnce = true;
if (line != null && drawOnGizmos == false)
{
Transform[] drawns = GetComponentsInChildren<Transform>();
if (drawns.Length > 0)
{
foreach (Transform drawn in drawns)
{
Destroy(drawn.gameObject);
}
}
}
if (boxCollider == null)
{
boxCollider = boxColliderToDrawOn.GetComponent<BoxCollider>();
}
drawOnGizmos = true;
break;
Run Code Online (Sandbox Code Playgroud) using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Test
{
public partial class Form1 : Form
{
int x1, x2, wid = 100;
public Form1()
{
InitializeComponent();
x1 = this.Width / 2 ;
x2 = this.Height / 2 ;
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawEllipse(Pens.Red, x1,x2, wid, wid);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我想在表单中间绘制一个简单的圆,然后再绘制从圆心出来的线。我该怎么做 ?
private void OnGUI()
{
GUIStyle myStyle = new GUIStyle();
myStyle.fontSize = 20;
GUILayout.BeginVertical(GUI.skin.box);
GUILayout.Label("Replacing");
GUI.Label(new Rect(650, 650, 300, 50), "HELLO WORLD", myStyle);
}
Run Code Online (Sandbox Code Playgroud)
我看到“替换”标签,但字体很小。所以我想测试使用 new Rect 更改大小,但我在任何地方都看不到 HELLO WORLD。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExecuteAlways]
public class SkyBox : MonoBehaviour
{
public Material[] skyboxes;
public Camera skyboxCamera;
public float skyboxMoveSpeed = 2f;
private int index = 0;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
SwitchSkybox();
}
if (RenderSettings.skybox == skyboxes[1])
{
RenderSettings.skybox.SetFloat("_Rotation", Time.time * skyboxMoveSpeed);
}
}
public void SwitchSkybox()
{
index++;
if (index == skyboxes.Length)
{
index = …Run Code Online (Sandbox Code Playgroud) 目标是控制 BackGroundWorkerDoWork事件中的帧提取速度。
我尝试过Thread.Sleep(),但它抛出异常。
这就是我想做的。上面和底部都有描述。
using Accord.Video;
using Accord.Video.FFMPEG;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
using (var vFReader = new VideoFileReader())
{
vFReader.Open(@"C:\Users\Chocolade 1972\Downloads\MyVid.mp4");
trackBar1.Maximum = (int)vFReader.FrameCount;
}
}
private void button1_Click(object sender, EventArgs e)
{
backgroundWorker1.RunWorkerAsync();
}
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
using (var vFReader = new VideoFileReader())
{
vFReader.Open(@"C:\Users\Chocolade 1972\Downloads\MyVid.mp4");
for (var i = 0; i < vFReader.FrameCount; i++)
{ …Run Code Online (Sandbox Code Playgroud) 我创建了一个名为的新类SiteDownload,并添加了一些下载图像的链接:
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
public class SiteDownload
{
public static List<string> Sites()
{
List<string> list = new List<string>();
list.Add("mysite.com/sites/default/files/1231105.gif");
list.Add("mysite.com/sites/default/files/1231040.gif");
return list;
}
public static async Task<List<Website>> ParallelDownload(IProgress<ProgressReport> progress, CancellationTokenSource cancellationTokenSource)
{
List<string> sites = Sites();
List<Website> list = new List<Website>();
ProgressReport progressReport = new ProgressReport();
ParallelOptions parallelOptions = new ParallelOptions();
parallelOptions.MaxDegreeOfParallelism = 8;
parallelOptions.CancellationToken = cancellationTokenSource.Token;
await Task.Run(() =>
{
try
{
Parallel.ForEach<string>(sites, parallelOptions, (site) =>
{
Website results = Download(site);
list.Add(results); …Run Code Online (Sandbox Code Playgroud) 我正在使用的命令:
ffmpeg -f gdigrab -framerate 24 -i desktop -preset ultrafast -pix_fmt yuv420p camera1.mp4
Run Code Online (Sandbox Code Playgroud)
Stream #0:没有足够的帧来估计速率;考虑增加探针尺寸
并且 :
不推荐使用 AVStream.codec 将编解码器参数传递给多路复用器,请改用 AVStream.codecpar。
然后一直:
过去的持续时间 0.810524 太大
一些信息:
ffmpeg -f gdigrab -framerate 24 -i desktop -preset ultrafast -pix_fmt yuv420p camera1.mp4 ffmpeg 版本 N-81045-g450cf40 版权所有 (c) 2000-2016 FFmpeg 开发人员使用 gcc 5.4.0 (GCC) 配置构建--enable-gpl --enable-version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-libebur128 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger - -enable-libsnappy …
我的 gif 动画大小为 2.5MB,是从 mp4 视频转换而来的。
c# ×7
winforms ×3
.net ×1
.net-6.0 ×1
animated-gif ×1
ffmpeg ×1
github ×1
graphics ×1
httpclient ×1
repository ×1