rect

Go 接口使用

流过昼夜 提交于 2019-12-03 16:45:28
本文来自: CSDN博客 感谢作者:fengfengdiandia 查看原文: go 接口 Go 语言不是一种 “传统” 的面向对象编程语言:它里面没有 类 和 继承 的概念。 但是 Go 语言里有非常灵活的 接口 概念,通过它可以实现很多 面向对象 的特性。 接口 定义了一个 方法的集合 ,但是这些方法 不包含实现代码 ,它们是 抽象的 ,接口里也 不能包含变量 。 定义格式 定义接口的一般格式: type Namer interface { Method1(param_list) return_type Method2(param_list) return_type ... } 上面的 Namer 就是一个接口类型。 在 Go 语言中 接口 可以有值, 一个 接口类型 的变量或一个 接口值 : var ai Namer , ai 是一个 multiword 数据结构,它的值是 nil 。 它本质上是一个 指针 ,虽然不完全是一回事。指向接口值的指针是 非法的 ,会导致代码错误。 类型 (比如结构体)实现接口方法集中的方法,实现了 Namer 接口类型的变量可以赋值给 ai ,此时方法表中的指针会指向被实现的接口方法。 实现某个接口的类型,除了实现接口的方法外,还可以有自己的方法。 package main import "fmt" type Shaper interface {

Unity编辑器拓展之三:拓展Unity的Hierarchy面板

大城市里の小女人 提交于 2019-12-03 16:00:57
效果图: 上图中在Hierarchy右侧绘制了Toggle,Label,以及自定义的texture和Unity原声的Texture,知道了原理,其实这些都很简单。。 这里主要是使用了EditorApplication类下的HierarchyWindowItemCallback类型的hierarchyWindowItemOnGUI // // 摘要: // /// // Delegate to be called for every visible list item in the HierarchyWindow on every // OnGUI event. // /// // // 参数: // instanceID: // // selectionRect: public delegate void HierarchyWindowItemCallback ( int instanceID, Rect selectionRect); 该委托有两个参数,一个是int类型的instanceID,通过该ID利用EditorUtility.InstanceIDToObject(instanceID)可以获取该GameObject,然后第二个参数Rect,也就是该物体在Hierarchy面板的位置信息了,通过这两个数据,在Hierarchy面板上拓展就很简单了。 using System

demo多场景运行切换工具

家住魔仙堡 提交于 2019-12-03 15:47:03
curvy插件中的,很好用 using UnityEngine; using System.Collections; using UnityEngine.UI; using FluffyUnderware.DevTools.Extensions; using System.Collections.Generic; # if UNITY_EDITOR using UnityEditor; # endif public class SceneSwitcher : MonoBehaviour { bool mChkAdditive; Vector2 sv = Vector2.zero; Rect mDropdownRect; string [] mItems; bool mShow; # if UNITY_EDITOR void Start () { } # endif int CurrentLevel { get { # if UNITY_5_0 || UNITY_5_1 || UNITY_5_2 return Application.loadedLevel; # else return UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex; # endif } set { if

unity_Editor自定义窗口顶部添加小图标

时光毁灭记忆、已成空白 提交于 2019-12-03 15:43:42
在自定义窗口添加图标 可以是系统图标,也可以是自定义图标。下面举了两个例子、 系统图标的名字大家可以去我之前的文章里查 http://www.xuanyusong.com/archives/3777 代码 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 using UnityEngine ; using System . Collections ; using UnityEditor ; public class MyWindows : EditorWindow { [ MenuItem ( "Window/My Window" ) ] static void Init ( ) { MyWindows window = ( MyWindows ) EditorWindow . GetWindow ( typeof ( MyWindows ) ) ; window . Show ( ) ; } bool locked = false ; private GUIStyle m_IconStyle = new GUIStyle ( ) ; private void OnEnable ( ) { Texture2D icon = Resources .

Determine the bounding rect of a WPF element relative to some parent

依然范特西╮ 提交于 2019-12-03 15:41:49
问题 I consider this a pretty simple request, but I can't seem to find a conclusive answer in my searches. How can I determine the bounds of a particular visual element in my window, relative to some other parent element? I've tried using LayoutInformation.GetLayoutSlot but this just seems to return a Rect at 0,0 and doesn't reflect the actual location of the element. What I'm trying to do is take a "screenshot" of a window using RenderTargetBitmap and then crop it to a particular element, but I

Unity编辑器 - 自动排版

落爺英雄遲暮 提交于 2019-12-03 15:27:51
Unity编辑器 - 自动排版 使用花括号提高可读性 //一组横向排列的控件 GUILayout .BeginHorizontal () ; { GUILayout .BeginVertical () ; { //横向排列中的第一组竖向控件 } GUILayout .EndVertical () ; GUILayout .BeginVertical () ; { //横向排列中的第二组竖向控件 } GUILayout .EndVertical () ; } GUILayout .EndHorizontal () ; 1 一定要这样写的,不然改的痛不欲生。。 2 把冗长的代码按排版区域拆分成模块 坑爹的GUILayoutUtility.GetRect()和GUILayout.BeginArea() 在组织排版和需要实现交互操作时,需要获取控件的Rect,这时候使用GUILayoutUtility.GetRect()比较方便。 然而这里有两点要特别注意: - 在Event.current.type == EventType.Layout时: GUILayoutUtility.GetRect() = Rect(0, 0, 1, 1); - GUILayoutUtility.GetRect()不能给BeginArea使用,因为GUILayout

在Unity中创建编辑器Windows

非 Y 不嫁゛ 提交于 2019-12-03 15:24:44
在过去十年中,Unity一直是开发游戏的绝佳平台,为开发人员提供大量工具:渲染引擎​​,物理引擎,动画系统,音频混合器等。但是,在创建关卡或生成游戏内数据时,Unity不足,因为每个游戏都是独一无二的,需要不同种类的工具。值得庆幸的是,Unity为我们的开发人员提供了一个API,可以创建我们自己的编辑器窗口,自定义抽屉和检查器面板。在这一系列的博客文章中,我将向您展示我们如何在Gram Games中为设计师和艺术家在Unity中开发自定义编辑器。我们将首先创建一个编辑器窗口,在其中放置两个面板,然后使其可调整大小。在下一篇文章中,我们将该窗口转换为Unity自己的控制台窗口的克隆。 那么,让我们开始吧!首先,我们将创建一个空的Unity项目,并在Assets下添加一个名为Editor的文件夹。如果您在Unity中为文件夹指定某些名称,它将以特殊方式处理其内容。编辑器就是其中一个名称,此文件夹中的脚本将成为Unity自己编辑器的一部分。那么,让我们构建一个编辑器窗口脚本:进入刚刚创建的Editor文件夹,右键单击,然后选择Create - > C#Script。您也可以选择Editor Test C#Script,但我们会改变所有内容,所以它实际上并不重要。将脚本命名为ResizablePanels,然后在您喜欢的文本编辑器中打开它(在Gram Games中我们更喜欢Xamarin)

SVG基本知识

感情迁移 提交于 2019-12-03 15:10:48
(由于即将面试的公司是做AI的,涉及到 数据可视化 ,所以先对SVG做一个大概了解) (感觉前端知识还挺多的,加油!) 一、SVG是什么   SVG是 scalable vector graphics 的缩写,意为 可扩展矢量图形 或者 可缩放矢量图形 ,它使用 XML 格式定义图像。 二、SVG怎么插入到HTML界面中   1、<embed>标签 <embed src="rect.svg" width="300" height="100" type="image/svg+xml" pluginspage="http://www.adobe.com/svg/viewer/install/" />   【注:XHTML中不能使用 <embed>】   2、<object> 标签 <object data="rect.svg" width="300" height="100" type="image/svg+xml" codebase="http://www.adobe.com/svg/viewer/install/" />   【注:不允许使用脚本】   3、<iframe>标签 <iframe src="rect.svg" width="300" height="100"> </iframe> 三、形状 SVG 有一些预定义的形状元素,可被开发者使用和操作: 矩形 <rect>

Unity Editor 编辑器扩展 十一 Inspector可排序列表

你离开我真会死。 提交于 2019-12-03 15:03:31
目录 可排序列表简单使用 可排序列表复杂使用 可排序列表简单使用 创建如下脚本并挂载到物体上: using UnityEngine; using System.Collections; public class Example1 : MonoBehaviour { [SerializeField] string [] texts; } 在Editor中创建如下脚本: using UnityEngine; using UnityEditor; using UnityEditorInternal; [CustomEditor ( typeof (Example1))] public class ExampleInspector : Editor { ReorderableList reorderableList; void OnEnable () { reorderableList = new ReorderableList (serializedObject, serializedObject.FindProperty ( "texts" )); // 绘制元素 var prop = serializedObject.FindProperty ( "texts" ); reorderableList = new ReorderableList (serializedObject,

Unity--EditorGUI.ObjectField实现

五迷三道 提交于 2019-12-03 14:54:17
记录下,以后可以有个参考 绘制UI使用的是 style.Draw(position, gUIContent, id, DragAndDrop.activeControlID == id); 这个style其实就是 EditorStyles.objectField 有 ObjectSelector.get.Show(obj, objType, property, allowSceneObjects); 的 码块是后面那个圈圈的点击事件,点击后弹出对象选择面板 拖拽处理在 EventType.DragUpdated,EventType.DragPerform 的case块代码中 public static Object ObjectField(Rect position, GUIContent label, Object obj, Type objType, bool allowSceneObjects) { int controlID = GUIUtility.GetControlID(EditorGUI.s_ObjectFieldHash, FocusType.Keyboard, position); position = EditorGUI.PrefixLabel(position, controlID, label); if (EditorGUIUtility