Example #1
1
 public bool AttachView(EditorWindow parent, ScriptableObject webView, bool initialize = false)
 {
     this.parentWin = parent;
     this.internalWebView = webView;
     if (this.internalWebView != null)
     {
         this.hostView = Tools.GetReflectionField<object>(parent, "m_Parent");
         this.dockedGetterMethod = this.parentWin.GetType().GetProperty("docked", Tools.FullBinding).GetGetMethod(true);
         if (this.hostView != null && dockedGetterMethod != null)
         {
             if (initialize)
             {
                 Rect initViewRect = new Rect(0, 20, this.parentWin.position.width, this.parentWin.position.height - ((this.IsDocked()) ? 20 : 40));
                 this.InitWebView(this.hostView, (int)initViewRect.x, (int)initViewRect.y, (int)initViewRect.width, (int)initViewRect.height, false);
                 this.SetHideFlags(HideFlags.HideAndDontSave);
                 this.AllowRightClickMenu(true);
             }
         }
         else
         {
             throw new Exception("Failed to get parent window or docked property");
         }
     }
     return (this.internalWebView != null);
 }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, property);
            {
                if (EditorGUI.PropertyField(position, property))
                {
                    EditorGUILayout.PropertyField(property.FindPropertyRelative("type"));

                    switch (property.FindPropertyRelative("type").enumValueIndex)
                    {
                        case 0: // None
                            break;
                        case 1: // Sphere
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("center"));
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("radius"));
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("physicsMaterial"));
                            break;
                        case 2: // Box
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("center"));
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("size"));
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("physicsMaterial"));
                            break;
                        case 3: // Capsule
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("center"));
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("direction"));
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("radius"));
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("height"));
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("physicsMaterial"));
                            break;
                    }
                }
            }
            EditorGUI.EndProperty();
        }
 private void OnGUI()
 {
     if (this.vessel == FlightGlobals.ActiveVessel && _render_window)
     {
         _window_position = GUILayout.Window(_window_ID, _window_position, Window, "ISRU Refinery Interface");
     }
 }
        // RimWorld.AreaAllowedGUI
        public static void DoStockpileSelectors( Rect rect, ref Zone_Stockpile stockpile, Map map )
        {
            // get all stockpiles
            List<Zone_Stockpile> allStockpiles = map.zoneManager.AllZones.OfType<Zone_Stockpile>().ToList();

            // count + 1 for all stockpiles
            int areaCount = allStockpiles.Count + 1;

            // create colour swatch
            if ( textures == null || textures.Count != areaCount - 1 )
                CreateTextures( allStockpiles );

            float widthPerCell = rect.width / areaCount;
            Text.WordWrap = false;
            Text.Font = GameFont.Tiny;
            Rect nullAreaRect = new Rect( rect.x, rect.y, widthPerCell, rect.height );
            DoZoneSelector( nullAreaRect, ref stockpile, null, BaseContent.GreyTex );
            int areaIndex = 1;
            for( int j = 0; j < allStockpiles.Count; j++ )
            {
                float xOffset = areaIndex * widthPerCell;
                Rect stockpileRect = new Rect( rect.x + xOffset, rect.y, widthPerCell, rect.height );
                DoZoneSelector( stockpileRect, ref stockpile, allStockpiles[j], textures[j] );
                areaIndex++;
            }
            Text.WordWrap = true;
            Text.Font = GameFont.Small;
        }
Example #5
0
        private static void DrawPanel(Rect rect, Color color, PanelStyleOption option)
        {
            GUI.color = color;
            GUI.Box(rect, "", PanelStyle(option));

            Colors.ResetUIColor();
        }
        private void HandleWindowEvents(Rect resizeRect)
        {
            var theEvent = Event.current;
            if (theEvent != null)
            {
                if (!mouseDown)
                {
                    if (theEvent.type == EventType.MouseDown && theEvent.button == 0 && resizeRect.Contains(theEvent.mousePosition))
                    {
                        mouseDown = true;
                        theEvent.Use();
                    }
                }
                else if (theEvent.type != EventType.Layout)
                {
                    if (Input.GetMouseButton(0))
                    {
                        // Flip the mouse Y so that 0 is at the top
                        float mouseY = Screen.height - Input.mousePosition.y;

                        WindowRect.width = Mathf.Clamp(Input.mousePosition.x - WindowRect.x + (resizeRect.width / 2), 50, Screen.width - WindowRect.x);
                        WindowRect.height = Mathf.Clamp(mouseY - WindowRect.y + (resizeRect.height / 2), 50, Screen.height - WindowRect.y);
                    }
                    else
                    {
                        mouseDown = false;
                    }
                }
            }
        }
 public static Rect BeginCurveFrame(Rect r)
 {
   AudioCurveRendering.DrawCurveBackground(r);
   r = AudioCurveRendering.DrawCurveFrame(r);
   GUI.BeginGroup(r);
   return new Rect(0.0f, 0.0f, r.width, r.height);
 }
Example #8
0
        void CalculateOffset()
        {
            // Remove the delta movement
            _transform.Translate(-ProCamera2D.DeltaMovement, Space.World);

            // Calculate the window rect
            _cameraWindowRectInWorldCoords = GetRectAroundTransf(CameraWindowRect, ProCamera2D.ScreenSizeInWorldCoordinates, _transform);

            // If camera final horizontal position outside camera window rect
            var horizontalDeltaMovement = 0f;
            if (ProCamera2D.CameraTargetPositionSmoothed.x >= _cameraWindowRectInWorldCoords.x + _cameraWindowRectInWorldCoords.width)
            {
                horizontalDeltaMovement = ProCamera2D.CameraTargetPositionSmoothed.x - (Vector3H(_transform.localPosition) + _cameraWindowRectInWorldCoords.width / 2 + CameraWindowRect.x);
            }
            else if (ProCamera2D.CameraTargetPositionSmoothed.x <= _cameraWindowRectInWorldCoords.x)
            {
                horizontalDeltaMovement = ProCamera2D.CameraTargetPositionSmoothed.x - (Vector3H(_transform.localPosition) - _cameraWindowRectInWorldCoords.width / 2 + CameraWindowRect.x);
            }

            // If camera final vertical position outside camera window rect
            var verticalDeltaMovement = 0f;
            if (ProCamera2D.CameraTargetPositionSmoothed.y >= _cameraWindowRectInWorldCoords.y + _cameraWindowRectInWorldCoords.height)
            {
                verticalDeltaMovement = ProCamera2D.CameraTargetPositionSmoothed.y - (Vector3V(_transform.localPosition) + _cameraWindowRectInWorldCoords.height / 2 + CameraWindowRect.y);
            }
            else if (ProCamera2D.CameraTargetPositionSmoothed.y <= _cameraWindowRectInWorldCoords.y)
            {
                verticalDeltaMovement = ProCamera2D.CameraTargetPositionSmoothed.y - (Vector3V(_transform.localPosition) - _cameraWindowRectInWorldCoords.height / 2 + CameraWindowRect.y);
            }

            var deltaMovement = VectorHV(horizontalDeltaMovement, verticalDeltaMovement);
            _transform.Translate(deltaMovement, Space.World);
        }
Example #9
0
        public override void OnGUI (Rect position, SerializedProperty property, GUIContent label) 
        {
            float value = 0f;
            if (property.propertyType == SerializedPropertyType.Float)
            {
                value = property.floatValue;
                isNumericValue = true;
            }
            else
            if (property.propertyType == SerializedPropertyType.Integer)
            {
                value = (float)property.intValue;
                isNumericValue = true;
            }
            else
            {
                isNumericValue = false;
            }

            if (isNumericValue)
            {
                ProgressBarAttribute barAttribute = (ProgressBarAttribute)attribute;
                EditorGUI.BeginProperty(position, label, property);
                EditorGUI.ProgressBar(position, (value / barAttribute.max), label.text);
                EditorGUI.EndProperty();
            }
            else
            {
                EditorGUI.BeginProperty(position, label, property);
                EditorGUI.PropertyField(position, property);
                EditorGUI.EndProperty();
            }
        }
        internal static void Display(int windowId)
        {
            // Reset Tooltip active flag...
              ToolTipActive = false;

              Rect rect = new Rect(Position.width - 20, 4, 16, 16);
              if (GUI.Button(rect, new GUIContent("", "Close Window")))
              {
            ShowWindow = false;
            ToolTip = "";
              }
              if (Event.current.type == EventType.Repaint && ShowToolTips)
            ToolTip = SMToolTips.SetActiveToolTip(rect, GUI.tooltip, ref ToolTipActive, 10);

              // This is a scroll panel (we are using it to make button lists...)
              GUILayout.BeginVertical();
              DisplayWindowTabs();
              // This is a scroll panel (we are using it to make button lists...)
              _displayViewerPosition = GUILayout.BeginScrollView(_displayViewerPosition, SMStyle.ScrollStyle,
            GUILayout.Height(200), GUILayout.Width(370));
              DisplaySelectedTab(_displayViewerPosition);
              GUILayout.EndScrollView();

              DisplayTabActions();
              GUILayout.EndVertical();
              GUI.DragWindow(new Rect(0, 0, Screen.width, 30));
              SMAddon.RepositionWindow(ref Position);
        }
Example #11
0
		override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor) {
			if (!checkVisible (editor)) return;

			Color col = GUI.contentColor;
			Color bcol = GUI.backgroundColor;
			GUI.contentColor = new Color(1f, 1f, 0.8f, 1f);
			GUI.backgroundColor = backgroundColor;
			//position.y -= 15;
			Rect pos=new Rect(position);
			pos.y += 3;
			pos.height -= 3;
			//if (visibilityProp1==null || visibilityProp1=="indent") {
	//			pos.height -= 10;
	//			pos.y += 10;
			//}

			if (visibilityProp1!=null) {
				pos.x+=12;
				pos.width-=12;
			}
	//		pos.height = 17;
			EditorGUI.HelpBox(pos, (foldoutFlag ? "     ":"")+label, MessageType.None);

			if (foldoutFlag) {
				Rect fpos = new Rect(pos);
				fpos.x += 15;
				fpos.y += 1;
				bool state = EditorGUI.Foldout(fpos, prop.floatValue==1, "", true);
				prop.floatValue = state ? 1 : 0;
			}

			GUI.contentColor = col;
			GUI.backgroundColor = bcol;
		}
        public static Rect ClampToScreen(Rect window)
        {
            window.x = Mathf.Clamp(window.x, -window.width + 20, Screen.width - 20);
            window.y = Mathf.Clamp(window.y, -window.height + 20, Screen.height - 20);

            return window;
        }
Example #13
0
 public void draw()
 {
     if (visible) {
         GUI.skin = HighLogic.Skin;
         windowPos = GUILayout.Window(2, windowPos, windowGUI, "Monitor", GUILayout.MinWidth(100));
     }
 }
        //called anywhere from 60 times a sec to 1000 times a second. Only display GUI in this function.
        //No model data should built/manipulated.
        public void OnGUI()
        {
            if (guiMgr.inGame && !guiMgr.gameOver) {
                if (SettingsManager.BoolSettings[(int)Preferences.ToggleTradeSettingsMenu]) {
                    windowRect = GUI.Window(TradeMenuSettingsWindowId, windowRect, BuildTradeMenuSettingsMenu, string.Empty, guiMgr.windowBoxStyle);
                }

                if (!SettingsManager.BoolSettings[(int)Preferences.ToggleNewTradeMenu]) return;

                if (GUIManager.getInstance().merchantTrade != null) {
                    TimeManager.getInstance().play();
                    GUIManager.getInstance().merchantTrade = null;
                }
                if (tradeOnGoing) {
                    openTradeWindowRect = GUI.Window(OpenTradeWindowId, openTradeWindowRect, BuildOpenTradeWindow, string.Empty, guiMgr.windowBoxStyle);
                }
                if (showTradeWindow) {
                    tradeWindowRect = GUI.Window(TradeWindowId, tradeWindowRect, BuildTradeWindow, string.Empty, guiMgr.windowBoxStyle);
                }
            }

            tradeWindowRect.x = Mathf.Clamp(tradeWindowRect.x, 2f, Screen.width - tradeWindowRect.width - 2f);
            tradeWindowRect.y = Mathf.Clamp(tradeWindowRect.y, 40f, Screen.height - tradeWindowRect.height - 2f);
            windowRect.x = Mathf.Clamp(windowRect.x, 2f, Screen.width - windowRect.width - 2f);
            windowRect.y = Mathf.Clamp(windowRect.y, 40f, Screen.height - windowRect.height - 2f);
        }
        private void DisplayMapping(Rect screenRect, int index)
        {
            Rect configPos = GUILayoutUtility.GetRect(new GUIContent(name), EditorStyles.label, GUILayout.Height(15.0f));
            if(Event.current.type == EventType.MouseDown && Event.current.button == 0)
            {
                if(configPos.Contains(Event.current.mousePosition))
                {
                    _selection = index;
                    Repaint();
                }
            }

            if(_selection == index)
            {
                if(_highlightTexture == null) {
                    CreateHighlightTexture();
                }
                GUI.DrawTexture(configPos, _highlightTexture, ScaleMode.StretchToFill);
                EditorGUI.LabelField(configPos, _mappings[index].Name, _whiteLabel);
            }
            else
            {
                EditorGUI.LabelField(configPos, _mappings[index].Name);
            }
        }
Example #16
0
        public static GameObject CreateDecal(Material mat, Rect uvCoords, float scale)
        {
            GameObject decal = new GameObject();
            decal.name = "Decal" + decal.GetInstanceID();

            decal.AddComponent<MeshFilter>().sharedMesh = DecalMesh("DecalMesh" + decal.GetInstanceID(), mat, uvCoords, scale);
            decal.AddComponent<MeshRenderer>().sharedMaterial = mat;

            #if UNITY_5
            decal.GetComponent<MeshRenderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
            #else
            decal.GetComponent<MeshRenderer>().castShadows = false;
            #endif

            qd_Decal decalComponent = decal.AddComponent<qd_Decal>();

            decalComponent.SetScale(scale);
            decalComponent.SetTexture( (Texture2D)mat.mainTexture );
            decalComponent.SetUVRect(uvCoords);

            #if DEBUG
            decal.AddComponent<qd_DecalDebug>();
            #endif

            return decal;
        }
		public override void OnGUI (Rect pos, SerializedProperty prop, GUIContent label) {


			SerializedProperty selection = prop.FindPropertyRelative("selection");
			SerializedProperty gameObject = prop.FindPropertyRelative("gameObject");

			CacheOwnerGameObject(prop.serializedObject);


			// draw the enum popup Field
			int oldEnumIndex = selection.enumValueIndex;

			EditorGUI.PropertyField(
				GetRectforRow(pos,0),
				selection,new GUIContent("Target"),true);

			if (oldEnumIndex !=selection.enumValueIndex)
			{
				if (selection.enumValueIndex==1)
				{
					gameObject.objectReferenceValue = ownerGameObject;
				}
			}

			if (selection.enumValueIndex==1)
			{
				EditorGUI.indentLevel++;

				EditorGUI.PropertyField(
					GetRectforRow(pos,1),
					gameObject,new GUIContent("Game Object"),true);
			}
	
		}
Example #18
0
 public static void Line(float yOrigin, Color color)
 {
     var rect = new Rect(0, yOrigin, Screen.width, 1);
     GUI.color = color;
     GUI.DrawTexture(rect, Drawing.Pixel);
     Colors.ResetUIColor();
 }
 private static ListViewShared.ListViewElementsEnumerator DoListView(ListViewState state, int[] colWidths, string dragTitle)
 {
   Rect rect = ListViewGUILayout.dummyRect;
   int yFrom = 0;
   int yTo = 0;
   ListViewShared.InternalLayoutedListViewState ilvState = state.ilvState;
   int controlId = GUIUtility.GetControlID(ListViewGUILayout.listViewHash, FocusType.Native);
   state.ID = controlId;
   state.selectionChanged = false;
   ilvState.state = state;
   if (Event.current.type != EventType.Layout)
   {
     rect = new Rect(0.0f, state.scrollPos.y, GUIClip.visibleRect.width, GUIClip.visibleRect.height);
     if ((double) rect.width <= 0.0)
       rect.width = 1f;
     if ((double) rect.height <= 0.0)
       rect.height = 1f;
     state.ilvState.rect = rect;
     yFrom = (int) rect.yMin / state.rowHeight;
     yTo = yFrom + (int) Math.Ceiling(((double) rect.yMin % (double) state.rowHeight + (double) rect.height) / (double) state.rowHeight) - 1;
     ilvState.invisibleRows = yFrom;
     ilvState.endRow = yTo;
     ilvState.rectHeight = (int) rect.height;
     if (yFrom < 0)
       yFrom = 0;
     if (yTo >= state.totalRows)
       yTo = state.totalRows - 1;
   }
   if (colWidths == null)
   {
     ListViewGUILayout.dummyWidths[0] = (int) rect.width;
     colWidths = ListViewGUILayout.dummyWidths;
   }
   return new ListViewShared.ListViewElementsEnumerator((ListViewShared.InternalListViewState) ilvState, colWidths, yFrom, yTo, dragTitle, new Rect(0.0f, (float) (yFrom * state.rowHeight), rect.width, (float) state.rowHeight));
 }
		public void OnGUI(Rect rect)
		{
			int controlID = GUIUtility.GetControlID(FocusType.Keyboard);
			if (AudioMixersTreeView.s_Styles == null)
			{
				AudioMixersTreeView.s_Styles = new AudioMixersTreeView.Styles();
			}
			this.m_TreeView.OnEvent();
			Rect r;
			Rect rect2;
			AudioMixerDrawUtils.DrawRegionBg(rect, out r, out rect2);
			AudioMixerDrawUtils.HeaderLabel(r, AudioMixersTreeView.s_Styles.header, AudioMixersTreeView.s_Styles.audioMixerIcon);
			if (GUI.Button(new Rect(r.xMax - 15f, r.y + 3f, 15f, 15f), AudioMixersTreeView.s_Styles.addText, EditorStyles.label))
			{
				AudioMixersTreeViewGUI audioMixersTreeViewGUI = this.m_TreeView.gui as AudioMixersTreeViewGUI;
				audioMixersTreeViewGUI.BeginCreateNewMixer();
			}
			this.m_TreeView.OnGUI(rect2, controlID);
			if (this.m_TreeView.data.GetVisibleRows().Count == 0)
			{
				EditorGUI.BeginDisabledGroup(true);
				GUI.Label(new RectOffset(-20, 0, -2, 0).Add(rect2), "No mixers found");
				EditorGUI.EndDisabledGroup();
			}
			AudioMixerDrawUtils.DrawScrollDropShadow(rect2, this.m_TreeView.state.scrollPos.y, this.m_TreeView.gui.GetTotalSize(this.m_TreeView.data.GetVisibleRows()).y);
			this.HandleCommandEvents(controlID);
			this.HandleObjectSelectorResult();
		}
 // RimWorld.AreaAllowedGUI
 private static void DoZoneSelector( Rect rect, ref Zone_Stockpile zoneAllowed, Zone_Stockpile zone, Texture2D tex)
 {
     rect = rect.ContractedBy( 1f );
     GUI.DrawTexture( rect, tex );
     Text.Anchor = TextAnchor.MiddleLeft;
     string label = zone?.label ?? "Any stockpile";
     Rect innerRect = rect;
     innerRect.xMin += 3f;
     innerRect.yMin += 2f;
     Widgets.Label( innerRect, label );
     if( zoneAllowed == zone )
     {
         Widgets.DrawBox( rect, 2 );
     }
     if( Mouse.IsOver( rect ) )
     {
         if( zone != null )
         {
             if ( zone.AllSlotCellsList() != null && zone.AllSlotCellsList().Count > 0 )
                 Find.CameraDriver.JumpTo( zone.AllSlotCellsList().FirstOrDefault() );
         }
         if( Input.GetMouseButton( 0 ) &&
              zoneAllowed != zone )
         {
             zoneAllowed = zone;
             SoundDefOf.DesignateDragStandardChanged.PlayOneShotOnCamera();
         }
     }
     TooltipHandler.TipRegion( rect, label );
     Text.Anchor = TextAnchor.UpperLeft;
 }
Example #22
0
		public virtual void OnWindowGUI(Rect viewRect)
		{
			if(!isShown && CanShow())
			{
				isShown = true;
				DoShow();
			}
			
			if(isShown && !CanShow())
			{
				isShown = false;
				DoHide();
			}

			if(CanShow())
			{
				windowRect = GUILayout.Window(windowID, windowRect, DoWindow, header);

				DoGUI();

				if(isHovered)
				{
					int controlID = GUIUtility.GetControlID("WindowHovered".GetHashCode(), FocusType.Passive);
					
					if(Event.current.GetTypeForControl(controlID) == EventType.Layout)
					{
						HandleUtility.AddControl(controlID,0f);
					}
				}
			}
		}
Example #23
0
		public RectEx(Rect rc)
		{
			this.Left = rc.xMin;
			this.Top = rc.yMin;
			this.Right = rc.xMax;
			this.Bottom = rc.yMax;
		}
Example #24
0
        private void Awake()
        {
            instance = this;

            GameEvents.onShowUI.Add(OnShowUI);
            GameEvents.onHideUI.Add(OnHideUI);

            mainGuid = Guid.NewGuid().GetHashCode();
            bodyGuid = Guid.NewGuid().GetHashCode();
            configGuid = Guid.NewGuid().GetHashCode();

            MainWindowRect = new Rect(Screen.width / 4, 0, 200, 10); //Overwritten by LoadGUI
            BodyWindowRect = new Rect((Screen.width / 2) - 75, Screen.height / 4, 150, 10);
            ConfigWindowRect = new Rect((Screen.width / 2) - 100, Screen.height / 4, 200, 10);

            LoadGUI();

            if (visibility_mode == 2)
            {
                CreateStockToolbar();
            }
            else if (visibility_mode == 3)
            {
                CreateBlizzyToolbar();
            }
        }
Example #25
0
        public Monitor(Int32[] arr, UInt16 ptr, UInt16 chars, UInt16 colPtr, UInt16 modePointer)
        {
            mem = arr;
            pointer = ptr;
            charSetPtr = chars;
            colors = new Color[16];
            modePtr = modePointer;
            for (int i = 0; i < 16; ++i) {
                colors[i] = new Color();
                colors[i].a = 1.0f;
            }
            colorPointer = colPtr;

            image = new Texture2D(256, 256, TextureFormat.ARGB32, false);
            windowPos = new Rect();
            if ((windowPos.x == 0) && (windowPos.y == 0))//windowPos is used to position the GUI window, lets set it in the center of the screen
            {
                windowPos = new Rect(Screen.width / 2, Screen.height / 2, 100, 100);
            }
            //Set all the pixels to black. If you don't do this the image contains random junk.
            for (int y = 0; y < image.height; y++) {
                for (int x = 0; x < image.width; x++) {
                    image.SetPixel(x, y, Color.black);
                }
            }
            image.Apply();
        }
 public static void DrawFilledCurve(Rect r, AudioCurveRendering.AudioCurveAndColorEvaluator eval)
 {
   if (Event.current.type != EventType.Repaint)
     return;
   HandleUtility.ApplyWireMaterial();
   GL.Begin(1);
   float pixelsPerPoint = EditorGUIUtility.pixelsPerPoint;
   float num1 = 1f / pixelsPerPoint;
   float num2 = 0.5f * num1;
   float num3 = Mathf.Ceil(r.width) * pixelsPerPoint;
   float num4 = Mathf.Floor(r.x) + AudioCurveRendering.pixelEpsilon;
   float num5 = 1f / (num3 - 1f);
   float max = r.height * 0.5f;
   float num6 = r.y + 0.5f * r.height;
   float y = r.y + r.height;
   Color col;
   float b = Mathf.Clamp(max * eval(0.0f, out col), -max, max);
   for (int index = 0; (double) index < (double) num3; ++index)
   {
     float x = num4 + (float) index * num1;
     float a = Mathf.Clamp(max * eval((float) index * num5, out col), -max, max);
     float num7 = Mathf.Min(a, b) - num2;
     float num8 = Mathf.Max(a, b) + num2;
     GL.Color(new Color(col.r, col.g, col.b, 0.0f));
     AudioMixerDrawUtils.Vertex(x, num6 - num8);
     GL.Color(col);
     AudioMixerDrawUtils.Vertex(x, num6 - num7);
     AudioMixerDrawUtils.Vertex(x, num6 - num7);
     AudioMixerDrawUtils.Vertex(x, y);
     b = a;
   }
   GL.End();
 }
        public void drawKKSettingsGUI()
        {
            KKWindow = new GUIStyle(GUI.skin.window);
            KKWindow.padding = new RectOffset(3, 3, 5, 5);

            KKSettingsRect = GUI.Window(0xC10B3A8, KKSettingsRect, drawKKSettingsWindow, "", KKWindow);
        }
        static void HierarchyItemCB(int instanceID, Rect selectionRect)
        {
            GameObject go = EditorUtility.InstanceIDToObject(instanceID) as GameObject;

            if (go == null)
            {
                return;
            }   

            if (_icon != null && go.GetComponent<ProCamera2D>() != null)
            {
                Rect r = new Rect(selectionRect);
                r.x = r.width - 5;

                GUI.Label(r, _icon);
                return;
            }

            if (_icon_plugin != null && go.GetComponent<BasePC2D>() != null)
            {
                Rect r = new Rect(selectionRect);
                r.x = r.width - 5;

                GUI.Label(r, _icon_plugin);
            }
        }
        public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label)
        {
            Rect position = rect;
            position.height = EditorGUIUtility.singleLineHeight;
            SerializedProperty property = prop.FindPropertyRelative("m_NormalTrigger");
            SerializedProperty property2 = prop.FindPropertyRelative("m_HighlightedTrigger");
            SerializedProperty property3 = prop.FindPropertyRelative("m_PressedTrigger");
            SerializedProperty property4 = prop.FindPropertyRelative("m_ActiveTrigger");
            SerializedProperty property5 = prop.FindPropertyRelative("m_ActiveHighlightedTrigger");
            SerializedProperty property6 = prop.FindPropertyRelative("m_ActivePressedTrigger");
            SerializedProperty property7 = prop.FindPropertyRelative("m_DisabledTrigger");

            EditorGUI.PropertyField(position, property);
            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            EditorGUI.PropertyField(position, property2);
            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            EditorGUI.PropertyField(position, property3);
            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            EditorGUI.PropertyField(position, property4);
            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            EditorGUI.PropertyField(position, property5);
            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            EditorGUI.PropertyField(position, property6);
            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            EditorGUI.PropertyField(position, property7);
        }
		public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
			
			EditorGUI.PropertyField(position, property, label, includeChildren: true);

			var attribute = PropertyExtensions.GetAttribute<BeginGroupAttribute>(this);
			var otherProp = PropertyExtensions.GetRelativeProperty(property, property.propertyPath, attribute.otherFieldName);

			var isNull = false;
			if (property.propertyType == SerializedPropertyType.ObjectReference) {

				isNull = (property.objectReferenceValue == null);

			}

			if (isNull == true && otherProp != null) {

				if (otherProp.propertyType == SerializedPropertyType.ObjectReference) {

					isNull = (otherProp.objectReferenceValue == null);

				}

			}

			++EditorGUI.indentLevel;
			EditorGUI.BeginDisabledGroup(isNull);

			CustomGUI.Splitter();

		}
Example #31
0
 static void Camera_pixelRect(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.Camera _this = (UnityEngine.Camera)vc.csObj;
         var result = _this.pixelRect;
         JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
     }
     else
     {
         UnityEngine.Rect   arg0  = (UnityEngine.Rect)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
         UnityEngine.Camera _this = (UnityEngine.Camera)vc.csObj;
         _this.pixelRect = arg0;
     }
 }
        public override List <UnityEngine.Rect> GetViewerRects(UnityEngine.Rect area)
        {
            List <Rect> viewerSpaces = new List <Rect>();

            float tempHeight = AspectRatio / 2f;
            Rect  area1      = new Rect(0, 0, area.width, (area.height * tempHeight) - GAP);
            Rect  area2      = new Rect(0, (area.height * tempHeight) + GAP, (area.width / 2) - GAP, (area.height * (1 - tempHeight)) - GAP);
            Rect  area3      = new Rect((area.width / 2) + GAP, (area.height * tempHeight) + GAP, (area.width / 2) - GAP, (area.height * (1 - tempHeight)) - GAP);

            viewerSpaces.Add(area1);
            viewerSpaces.Add(area2);
            viewerSpaces.Add(area3);

            return(viewerSpaces);
        }
 static public int Remove(IntPtr l)
 {
     try{
         UnityEngine.RectOffset self = (UnityEngine.RectOffset)checkSelf(l);
         UnityEngine.Rect       a1;
         checkType(l, 2, out a1);
         UnityEngine.Rect ret = self.Remove(a1);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Example #34
0
 public virtual void UpdateHeaderBackground(UnityEngine.Rect position, int ordinal)
 {
     if (Selection.Contains(this.TargetTrack.Behaviour.gameObject) && !this.isRenaming)
     {
         GUI.Box(position, string.Empty, styles.backgroundSelected);
     }
     else if ((ordinal % 2) == 0)
     {
         GUI.Box(position, string.Empty, styles.TrackSidebarBG2);
     }
     else
     {
         GUI.Box(position, string.Empty, styles.TrackSidebarBG1);
     }
 }
Example #35
0
    public override void OnPreviewGUI(UnityEngine.Rect r, GUIStyle background)
    {
        if (CanRender())
        {
            if (_viewPreviewGUI == null)
            {
                CreatePreviewGUIView();
            }

            if (_viewPreviewGUI != null)
            {
                UnityEngine.GUI.DrawTexture(r, RenderPreview(_viewPreviewGUI, (int)r.width * 2, (int)r.height * 2));
            }
        }
    }
    static bool GUIStyle_DrawCursor__Rect__GUIContent__Int32__Int32(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 4)
        {
            UnityEngine.Rect       arg0 = (UnityEngine.Rect)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            UnityEngine.GUIContent arg1 = (UnityEngine.GUIContent)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            System.Int32           arg2 = (System.Int32)JSApi.getInt32((int)JSApi.GetType.Arg);
            System.Int32           arg3 = (System.Int32)JSApi.getInt32((int)JSApi.GetType.Arg);
            ((UnityEngine.GUIStyle)vc.csObj).DrawCursor(arg0, arg1, arg2, arg3);
        }

        return(true);
    }
    void OnGUI()
    {
#if UNITY_EDITOR
        UnityEngine.Rect _clickButton      = new UnityEngine.Rect(Screen.width * 0.1f, Screen.height * 0.1f, Screen.width * 0.2f, Screen.height * 0.1f);
        UnityEngine.Rect _grabButton       = new UnityEngine.Rect(Screen.width * 0.1f, Screen.height * 0.3f, Screen.width * 0.2f, Screen.height * 0.1f);
        UnityEngine.Rect _releaseButton    = new UnityEngine.Rect(Screen.width * 0.1f, Screen.height * 0.5f, Screen.width * 0.2f, Screen.height * 0.1f);
        UnityEngine.Rect _tapButton        = new UnityEngine.Rect(Screen.width * 0.1f, Screen.height * 0.7f, Screen.width * 0.2f, Screen.height * 0.1f);
        UnityEngine.Rect _SwipeLeftButton  = new UnityEngine.Rect(Screen.width * 0.1f, Screen.height * 0.9f, Screen.width * 0.2f, Screen.height * 0.1f);
        UnityEngine.Rect _SwipeRightButton = new UnityEngine.Rect(Screen.width * 0.7f, Screen.height * 0.9f, Screen.width * 0.2f, Screen.height * 0.1f);

        if (GUI.Button(_clickButton, "click"))
        {
            _simulateClick = true;
        }
        if (GUI.Button(_grabButton, "grab"))
        {
            _simulateGrab = true;
        }
        if (GUI.Button(_releaseButton, "release"))
        {
            _simulateRelease = true;
        }
        if (GUI.Button(_tapButton, "tap"))
        {
            _simulateTap = true;
        }
        if (GUI.Button(_SwipeRightButton, "SwipeRight"))
        {
            _simulateSwipeRight = true;
        }
        if (GUI.Button(_SwipeLeftButton, "SwipeLeft"))
        {
            _simulateSwipeLeft = true;
        }

        if (toastTime > 0)
        {
            toastTime -= Time.deltaTime / 5;
            float xPos   = Camera.main.pixelWidth * 0.3f;
            float yPos   = Camera.main.pixelHeight * Math.Max((0.5f + ((Math.Abs(toastTime - .5f)))), 0.7f);
            float width  = Camera.main.pixelWidth * 0.4f;
            float height = Camera.main.pixelHeight * 0.1f;

            UnityEngine.Rect toast = new UnityEngine.Rect(xPos, yPos, width, height);
            GUI.Box(toast, toastMessage, style);
        }
#endif
    }
Example #38
0
    private void predict(Mat prob)
    {
        const int prefix = 5;   //skip 0~4
        int       w      = 1147;
        int       h      = 557;

        for (int i = 0; i < prob.Rows; i++)
        {
            var confidence = prob.At <float>(i, 4);
            if (confidence > threshold)
            {
                //get classes probability
                Cv2.MinMaxLoc(prob.Row[i].ColRange(prefix, prob.Cols), out _, out Point max);
                var classes     = max.X;
                var probability = prob.At <float>(i, classes + prefix);

                if (probability > threshold) //more accuracy
                {
                    var color = Scalar.RandomColor();
                    //get center and width/height
                    var centerX = prob.At <float>(i, 0) * w;
                    var centerY = prob.At <float>(i, 1) * h;
                    var width   = prob.At <float>(i, 2) * w;
                    var height  = prob.At <float>(i, 3) * h;
                    //label formating
                    var label = $"{Labels[classes]} {probability * 100:0.00}%";
                    print($"confidence {confidence * 100:0.00}% {label}, detected position x:{centerX}, y:{centerY}, width:{width} height:{height}");

                    mText.text   = string.Format("Stairs Detected, Confidence {0}", confidence);
                    stair_width  = (int)width;
                    stair_height = (int)height;
                    stair_x      = (centerX - width / 2) < 0 ? 0 : (int)(centerX - width / 2);
                    stair_y      = (int)(centerY - height / 2);

                    UnityEngine.Rect rect = ScreenRect(stair_x, stair_y, stair_width, stair_height);
                    GUI.Label(rect, "TEST");
                }
                else
                {
                    mText.text   = "No stairs detected.";
                    stair_width  = 0;
                    stair_height = 0;
                    stair_x      = 0;
                    stair_y      = 0;
                }
            }
        }
    }
        public void FillRectangle(Color color, float x, float y, float width, float height, object material = null)
        {
            var rect = new UE.Rect(x, y, width, height);

            if (material == null || material is UE.Material == false)
            {
                UE.GUI.color = color.ToUnityColor();
                UE.GUI.DrawTexture(rect, defaultTexture);
                return;
            }

            var umat = (UE.Material)material;

            umat.color = color.ToUnityColor();
            UE.Graphics.DrawTexture(rect, defaultTexture, umat);
        }
Example #40
0
    static bool GUIStyle_Draw__Rect__Boolean__Boolean__Boolean__Boolean(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 5)
        {
            UnityEngine.Rect arg0 = (UnityEngine.Rect)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            System.Boolean   arg1 = (System.Boolean)JSApi.getBooleanS((int)JSApi.GetType.Arg);
            System.Boolean   arg2 = (System.Boolean)JSApi.getBooleanS((int)JSApi.GetType.Arg);
            System.Boolean   arg3 = (System.Boolean)JSApi.getBooleanS((int)JSApi.GetType.Arg);
            System.Boolean   arg4 = (System.Boolean)JSApi.getBooleanS((int)JSApi.GetType.Arg);
            ((UnityEngine.GUIStyle)vc.csObj).Draw(arg0, arg1, arg2, arg3, arg4);
        }

        return(true);
    }
Example #41
0
        /// <summary>
        /// Opens the navigation field drawer.
        /// </summary>
        public static void BeginNavigationField(ref NavigationFieldData navField, U.Vector2?restriction = null)
        {
            lastDrawnNavField = navField;

            U.Rect _fieldRect = FindLayoutAreaRect(ref navField.backupRect, navField.border);

            BeginColorPocket(navField.backgroundColor);
            Gl.BeginArea(_fieldRect, "", "Box");
            EndColorPocket();

            navField.DrawBackground();
            navField.DragUpdate();

            U.Vector2 _restriction = restriction ?? (new U.Vector2(_fieldRect.width, _fieldRect.height) - navField.scrollView);
            Gl.BeginArea(new U.Rect(navField.scrollView.x, navField.scrollView.y, _restriction.x, _restriction.y));
        }
    public override void OnGUI(UnityEngine.Rect position, SerializedProperty property, GUIContent label)
    {
        X = property.FindPropertyRelative("X");
        Y = property.FindPropertyRelative("Y");

        EditorGUI.BeginProperty(position, label, property);
        EditorGUI.BeginChangeCheck();
        var v2 = EditorGUI.Vector2Field(position, label, new Vector2(X.floatValue, Y.floatValue));

        if (EditorGUI.EndChangeCheck())
        {
            X.floatValue = v2.x;
            Y.floatValue = v2.y;
        }
        EditorGUI.EndProperty();
    }
Example #43
0
 static void CharacterInfo_vert(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.CharacterInfo _this = (UnityEngine.CharacterInfo)vc.csObj;
         var result = _this.vert;
         JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
     }
     else
     {
         UnityEngine.Rect          arg0  = (UnityEngine.Rect)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
         UnityEngine.CharacterInfo _this = (UnityEngine.CharacterInfo)vc.csObj;
         _this.vert = arg0;
         JSMgr.changeJSObj(vc.jsObjID, _this);
     }
 }
Example #44
0
 public override void OnPreviewGUI(UnityEngine.Rect r, GUIStyle background)
 {
     if (Event.current.type == EventType.Repaint)
     {
         if (CanRender())
         {
             if (r.width > 4 && r.height > 4)
             {
                 if (_viewPreview != null && _viewPreview.Content != null)
                 {
                     UnityEngine.GUI.DrawTexture(r, RenderPreview(_viewPreview, (int)r.width, (int)r.height));
                 }
             }
         }
     }
 }
Example #45
0
        /// <summary>
        ///   Copy texture data from <paramref name="src" />.
        /// </summary>
        /// <remarks>
        ///   This operation is slow.
        ///   If CPU won't access the pixel data, use <see cref="ReadTextureFromOnGPU" /> instead.
        /// </remarks>
        public void ReadTextureFromOnCPU(Texture src)
        {
            var currentRenderTexture = RenderTexture.active;
            var tmpRenderTexture     = new RenderTexture(src.width, src.height, 32);

            Graphics.Blit(src, tmpRenderTexture);
            RenderTexture.active = tmpRenderTexture;

            var rect = new UnityEngine.Rect(0, 0, Mathf.Min(tmpRenderTexture.width, textureBuffer.width), Mathf.Min(tmpRenderTexture.height, textureBuffer.height));

            textureBuffer.ReadPixels(rect, 0, 0);
            textureBuffer.Apply();
            RenderTexture.active = currentRenderTexture;

            SetPixels32(textureBuffer.GetPixels32());
        }
Example #46
0
    //I did not write this I obtained it from https://forum.unity.com/threads/simple-node-editor.189230/
    //This forum page helped me get a better grasp on writing a window
    void DrawNodeCurve(UnityEngine.Rect start, UnityEngine.Rect end)
    {
        Vector3 startPos  = new Vector3(start.x + start.width, start.y + start.height / 2, 0);
        Vector3 endPos    = new Vector3(end.x, end.y + end.height / 2, 0);
        Vector3 startTan  = startPos + Vector3.right * 50;
        Vector3 endTan    = endPos + Vector3.left * 50;
        Color   shadowCol = new Color(0, 0, 0, 0.6f);

        for (int i = 0; i < 3; i++)
        {
            // Draw a shadow
            Handles.DrawBezier(startPos, endPos, startTan, endTan, shadowCol, null, (i + 1) * 5);
        }

        Handles.DrawBezier(startPos, endPos, startTan, endTan, Color.black, null, 1);
    }
Example #47
0
 static void Rect_size(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.Rect _this = (UnityEngine.Rect)vc.csObj;
         var result             = _this.size;
         JSApi.setVector2S((int)JSApi.SetType.Rval, result);
     }
     else
     {
         UnityEngine.Vector2 arg0  = (UnityEngine.Vector2)JSApi.getVector2S((int)JSApi.GetType.Arg);
         UnityEngine.Rect    _this = (UnityEngine.Rect)vc.csObj;
         _this.size = arg0;
         JSMgr.changeJSObj(vc.jsObjID, _this);
     }
 }
Example #48
0
    static bool Sprite_Create__Texture2D__Rect__Vector2__Single__UInt32(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 5)
        {
            UnityEngine.Texture2D arg0 = (UnityEngine.Texture2D)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            UnityEngine.Rect      arg1 = (UnityEngine.Rect)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            UnityEngine.Vector2   arg2 = (UnityEngine.Vector2)JSApi.getVector2S((int)JSApi.GetType.Arg);
            System.Single         arg3 = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
            System.UInt32         arg4 = (System.UInt32)JSApi.getUInt32((int)JSApi.GetType.Arg);
            JSMgr.datax.setObject((int)JSApi.SetType.Rval, UnityEngine.Sprite.Create(arg0, arg1, arg2, arg3, arg4));
        }

        return(true);
    }
Example #49
0
    static bool Rect_Set__Single__Single__Single__Single(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 4)
        {
            System.Single    arg0    = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
            System.Single    arg1    = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
            System.Single    arg2    = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
            System.Single    arg3    = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
            UnityEngine.Rect argThis = (UnityEngine.Rect)vc.csObj;        argThis.Set(arg0, arg1, arg2, arg3);
            JSMgr.changeJSObj(vc.jsObjID, argThis);
        }

        return(true);
    }
 static public int PixelAdjustRect_s(IntPtr l)
 {
     try{
         UnityEngine.RectTransform a1;
         checkType(l, 1, out a1);
         UnityEngine.Canvas a2;
         checkType(l, 2, out a2);
         UnityEngine.Rect ret = UnityEngine.RectTransformUtility.PixelAdjustRect(a1, a2);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Example #51
0
 static void Rect_y(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.Rect _this = (UnityEngine.Rect)vc.csObj;
         var result             = _this.y;
         JSApi.setSingle((int)JSApi.SetType.Rval, (System.Single)(result));
     }
     else
     {
         System.Single    arg0  = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
         UnityEngine.Rect _this = (UnityEngine.Rect)vc.csObj;
         _this.y = arg0;
         JSMgr.changeJSObj(vc.jsObjID, _this);
     }
 }
        public override List <UnityEngine.Rect> GetViewerRects(UnityEngine.Rect area)
        {
            List <Rect> viewerSpaces = new List <Rect>();

            Rect area1 = new Rect(0, 0, (area.width / 2) - GAP, (area.height / 2) - GAP);
            Rect area2 = new Rect((area.width / 2) + GAP, 0, (area.width / 2) - GAP, (area.height / 2) - GAP);
            Rect area3 = new Rect(0, (area.height / 2) + GAP, (area.width / 2) - GAP, (area.height / 2) - GAP);
            Rect area4 = new Rect((area.width / 2) + GAP, (area.height / 2) + GAP, (area.width / 2) - GAP, (area.height / 2) - GAP);

            viewerSpaces.Add(area1);
            viewerSpaces.Add(area2);
            viewerSpaces.Add(area3);
            viewerSpaces.Add(area4);

            return(viewerSpaces);
        }
Example #53
0
    public RasterVO(UnityEngine.Rect nsRect, float[,] nVO)
    {
        VO    = new float[nVO.GetLength(0) * nVO.GetLength(1)];
        sRect = nsRect;
        int idx = 0;

        for (int y = 0; y < nVO.GetLength(1); y++)
        {
            for (int x = 0; x < nVO.GetLength(0); x++)
            {
                VO[idx] = nVO[x, y];
                idx++;
            }
        }
        myTex2d = new Texture2D((int)sRect.width, (int)sRect.height);
    }
    public override void OnGUI(UnityEngine.Rect position, SerializedProperty property, GUIContent label)
    {
        label    = EditorGUI.BeginProperty(position, label, property);
        position = EditorGUI.PrefixLabel(position, label);

        SerializedProperty minProp = property.FindPropertyRelative("minValue");
        SerializedProperty maxProp = property.FindPropertyRelative("maxValue");

        float minValue = minProp.floatValue;
        float maxValue = maxProp.floatValue;

        float rangeMin = 0;
        float rangeMax = 1;

        var ranges = (RangeFloatMinMaxAttribute[])fieldInfo.GetCustomAttributes(typeof(RangeFloatMinMaxAttribute), true);

        if (ranges.Length > 0)
        {
            rangeMin = ranges[0].Min;
            rangeMax = ranges[0].Max;
        }

        const float rangeBoundsLabelWidth = 40f;

        var rangeBoundsLabel1Rect = new UnityEngine.Rect(position);

        rangeBoundsLabel1Rect.width = rangeBoundsLabelWidth;
        GUI.Label(rangeBoundsLabel1Rect, new GUIContent(minValue.ToString("F2")));
        position.xMin += rangeBoundsLabelWidth;

        var rangeBoundsLabel2Rect = new UnityEngine.Rect(position);

        rangeBoundsLabel2Rect.xMin = rangeBoundsLabel2Rect.xMax - rangeBoundsLabelWidth;
        GUI.Label(rangeBoundsLabel2Rect, new GUIContent(maxValue.ToString("F2")));
        position.xMax -= rangeBoundsLabelWidth;

        EditorGUI.BeginChangeCheck();
        EditorGUI.MinMaxSlider(position, ref minValue, ref maxValue, rangeMin, rangeMax);

        if (EditorGUI.EndChangeCheck())
        {
            minProp.floatValue = minValue;
            maxProp.floatValue = maxValue;
        }

        EditorGUI.EndProperty();
    }
Example #55
0
 /// <summary>
 /// Write the specified value using the writer.
 /// </summary>
 /// <param name="value">Value.</param>
 /// <param name="writer">Writer.</param>
 public override void Write(object value, ISaveGameWriter writer)
 {
     UnityEngine.Rect rect = (UnityEngine.Rect)value;
     writer.WriteProperty("x", rect.x);
     writer.WriteProperty("y", rect.y);
     writer.WriteProperty("position", rect.position);
     writer.WriteProperty("center", rect.center);
     writer.WriteProperty("min", rect.min);
     writer.WriteProperty("max", rect.max);
     writer.WriteProperty("width", rect.width);
     writer.WriteProperty("height", rect.height);
     writer.WriteProperty("size", rect.size);
     writer.WriteProperty("xMin", rect.xMin);
     writer.WriteProperty("yMin", rect.yMin);
     writer.WriteProperty("xMax", rect.xMax);
     writer.WriteProperty("yMax", rect.yMax);
 }
Example #56
0
    static bool Rect_Rect3(JSVCall vc, int argc)
    {
        int _this = JSApi.getObject((int)JSApi.GetType.Arg);

        JSApi.attachFinalizerObject(_this);
        --argc;

        int len = argc;

        if (len == 1)
        {
            UnityEngine.Rect arg0 = (UnityEngine.Rect)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            JSMgr.addJSCSRel(_this, new UnityEngine.Rect(arg0));
        }

        return(true);
    }
Example #57
0
    public static UnityEngine.Rect[] ToRectArray(SerialRect[] vects)
    {
        if (null == vects)
        {
            return(null);
        }

        UnityEngine.Rect[] temp =
            new UnityEngine.Rect[vects.Length];

        for (int index = vects.Length - 1; index >= 0; --index)
        {
            temp[index] = vects[index];
        }

        return(temp);
    }
Example #58
0
    public override void OnGUI(UnityEngine.Rect position, SerializedProperty property, UnityEngine.GUIContent label)
    {
        var nameRect  = new Rect(position.x, position.y, position.width, position.height / 3);
        var hpRect    = new Rect(position.x, position.y + position.height / 3, position.width / 2, position.height / 3);
        var deathRect = new Rect(position.x + position.width / 2, position.y + position.height / 3, position.width / 2, position.height / 3);
        var typeRect  = new Rect(position.x, position.y + position.height / 3 * 2, position.width, position.height / 3);

        hp.text      = "HP";
        Name.text    = "Name";
        Death.text   = "Death";
        ATKTYPE.text = "ATKTYPE";

        EditorGUI.PropertyField(nameRect, property.FindPropertyRelative("name"), Name);
        EditorGUI.PropertyField(hpRect, property.FindPropertyRelative("hp"), hp);
        EditorGUI.PropertyField(deathRect, property.FindPropertyRelative("isDeath"), Death);
        EditorGUI.PropertyField(typeRect, property.FindPropertyRelative("AtkType"), ATKTYPE);
    }
 static public int constructor(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         UnityEngine.Rect o;
         if (argc == 5)
         {
             System.Single a1;
             checkType(l, 2, out a1);
             System.Single a2;
             checkType(l, 3, out a2);
             System.Single a3;
             checkType(l, 4, out a3);
             System.Single a4;
             checkType(l, 5, out a4);
             o = new UnityEngine.Rect(a1, a2, a3, a4);
             pushValue(l, true);
             pushValue(l, o);
             return(2);
         }
         else if (argc == 3)
         {
             UnityEngine.Vector2 a1;
             checkType(l, 2, out a1);
             UnityEngine.Vector2 a2;
             checkType(l, 3, out a2);
             o = new UnityEngine.Rect(a1, a2);
             pushValue(l, true);
             pushValue(l, o);
             return(2);
         }
         else if (argc == 2)
         {
             UnityEngine.Rect a1;
             checkValueType(l, 2, out a1);
             o = new UnityEngine.Rect(a1);
             pushValue(l, true);
             pushValue(l, o);
             return(2);
         }
         return(error(l, "New object failed."));
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Example #60
0
    public override void OnGUI(UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label)
    {
        bool             shouldDrawProp = false;
        SerializedObject objectProp     = null;

        if (property.objectReferenceValue != null)
        {
            objectProp     = new SerializedObject(property.objectReferenceValue);
            shouldDrawProp = ShouldDrawProperty(objectProp);
        }

        position = DrawPrefixLabel(position, property, label);

        int numControls = 1;

        if (property.objectReferenceValue != null && shouldDrawProp)
        {
            numControls = 2;
        }

        float singleControlWidth = position.width / numControls;

        position.width = singleControlWidth;

        if (property.objectReferenceValue != null && shouldDrawProp)
        {
            position.width -= controlsSpace;

            EditorGUI.BeginChangeCheck();
            DrawValuePropertyIfRequired(objectProp, property, position);

            if (EditorGUI.EndChangeCheck())
            {
                objectProp.ApplyModifiedProperties();
            }

            position.x += singleControlWidth + controlsSpace;
        }

        EditorGUI.BeginChangeCheck();
        DrawVariableProperty(position, property, label);
        if (EditorGUI.EndChangeCheck())
        {
            property.serializedObject.ApplyModifiedProperties();
        }
    }