# URL ## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/' url:http://yoursite.com root:/ permalink::title/# :year/:month/:day/:title/ permalink_defaults: pretty_urls: trailing_index:true# Set to false to remove trailing 'index.html' from permalinks trailing_html:true# Set to false to remove trailing '.html' from permalinks
在 fake null object 中存储信息,Unity 能够在检视窗口 (Inspector) 中高亮该 GameObject,并给出更多指引。如:”looks like you are accessing a non initialized field in this MonoBehaviour over here, use the inspector to make the field point to something” (看来您试图访问此 MonoBehaviour 的未实例化字段,请在检视窗口使其指向实例)。
privatestaticboolIsNativeObjectAlive(Object o) { if (o.GetCachedPtr() != IntPtr.Zero) returntrue; return !(o is MonoBehaviour) && !(o is ScriptableObject) && Object.DoesObjectWithInstanceIDExist(o.GetInstanceID()); }
///<summary> ///<para>Returns the instance id of the object.</para> ///</summary> [SecuritySafeCritical] publicintGetInstanceID() { this.EnsureRunningOnMainThread(); returnthis.m_InstanceID; }
privatevoidEnsureRunningOnMainThread() { if (!Object.CurrentThreadIsMainThread()) thrownew InvalidOperationException("EnsureRunningOnMainThread can only be called from the main thread"); }
在 fake null object 中存储信息,Unity 能够在检视窗口 (Inspector) 中高亮该 GameObject,并给出更多指引:”looks like you are accessing a non initialized field in this MonoBehaviour over here, use the inspector to make the field point to something” (看来你在 MonoBehaviour 中试图访问未实例化字段,请在检视窗口使其指向实例)。
// Find the first employees: var earlyFolks = from e in allEmployees where e.Classification == EmployeeType.Salary where e.YearsOfService > 20 where e.MonthlySalary < 4000 select e;
// Find the newest people: var newest = from e in allEmployees where e.Classification == EmployeeType.Salary where e.YearsOfService < 20 where e.MonthlySalary < 4000 select e;
你可以将这些 where 合并为一条子句,然而这并不会带来太大区别。查询操作之间本就可以拼接 (见31条),而简单的 where 谓词还会有可能内联 (inline),因此,这两种写法在性能上是一样的。
// else where var allEmployees = FindAllEmployees();
var earlyFolks = from e in allEmployees whereLowPaidSalaried(e) && e.YearsOfService > 20 select e; // Find the newest people: var newest = from e in allEmployees where e.Classification == EmployeeType.Salary where e.YearsOfService < 20 where e.MonthlySalary < 4000 select e;
privatestatic IQueryable<Employee> LowPaidSalariedFilter(this IQueryable<Employee> sequence) => from s in sequence where s.Classification == EmployeeType.Salary && s.MonthlySalary < 4000 select s;
// else where var allEmployees = FindAllEmployees();
// Find the first employees: var salaried = allEmployees.LowPaidSalariedFilter();
var earlyFolks = salaried.Where(e => e.YearsOfService > 20);
// Find the newest people: var newest = salaried.Where(e => e.YearsOfService < 2);
///<summary> /// 0123456789 ///</summary> privatestaticvoidLazyEvaluation3() { var answers = from number inAllNumbers() select number; var smallNumbers = answers.Take(10);
foreach (int num in smallNumbers) Console.Write(num); }
privatestatic IEnumerable<int> AllNumbers() { var number = 0;
while (number < int.MaxValue) yieldreturn number++; }
此示例不必生成整个序列,而是仅生成十个数 (虽然 AllNumbers() 可以生成至 int.MaxValue)。Take() 方法只需要其中的前 N 个对象。
反之,如果把查询语句改成这样,程序将一直运行,直到 int.MaxValue才停下:
1 2 3 4
var answers = from number inAllNumbers() where number < 10 select number;