Equals() public method

public Equals ( object obj ) : bool
obj object
return bool
    static int Equals(IntPtr L)
    {
        try
        {
            ToLua.CheckArgsCount(L, 2);
            UnityEngine.Event obj  = (UnityEngine.Event)ToLua.CheckObject(L, 1, typeof(UnityEngine.Event));
            object            arg0 = ToLua.ToVarObject(L, 2);
            bool o = obj != null?obj.Equals(arg0) : arg0 == null;

            LuaDLL.lua_pushboolean(L, o);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Beispiel #2
0
    /// <summary>
    /// Determines which key command is pressed and responds accordingly.
    /// </summary>
    /// <param name="keyDownEvent">The keyboard event.</param>
    /// <returns>True if the keyboard shortcut exists, false otherwise.</returns>
    public void HandleKeyboardShortcuts(Event keyDownEvent)
    {
        KeyCode key = keyDownEvent.keyCode;

        // Tools:

        // Move/resize
        if (key == CutsceneHotkeys.MoveResizeTool.key) {
            currentTool = Tool.MoveResize;
            EDebug.Log("Cutscene Editor: switching to Move/Resize tool");
        // Scissors
        } else if (key == CutsceneHotkeys.ScissorsTool.key) {
            currentTool = Tool.Scissors;
            EDebug.Log("Cutscene Editor: switching to Scissors tool");
        // Zoom
        } else if (key == CutsceneHotkeys.ZoomTool.key) {
            currentTool = Tool.Zoom;
            EDebug.Log("Cutscene Editor: switching to Zoom tool");
        }

        // Timeline navigation:

        // Set in point
        else if (key == CutsceneHotkeys.SetInPont.key) {
            scene.inPoint = scene.playhead;
            EDebug.Log("Cutscene Editor: setting in point");
        // Set out point
        } else if (key == CutsceneHotkeys.SetOutPoint.key) {
            scene.outPoint = scene.playhead;
            EDebug.Log("Cutscene Editor: setting out point");
        // Scrub left
        } else if (keyDownEvent.Equals(Event.KeyboardEvent("left"))) {
            scene.playhead -= CutsceneTimeline.scrubSmallJump;
            EDebug.Log("Cutscene Editor: moving playhead left");
        // Scrub left large
        } else if (keyDownEvent.Equals(Event.KeyboardEvent("#left"))) {
            scene.playhead -= CutsceneTimeline.scrubLargeJump;
            EDebug.Log("Cutscene Editor: moving playhead left");
        // Scrub right
        } else if (keyDownEvent.Equals(Event.KeyboardEvent("right"))) {
            scene.playhead += CutsceneTimeline.scrubSmallJump;
            EDebug.Log("Cutscene Editor: moving playhead right");
        // Scrub right large
        } else if (keyDownEvent.Equals(Event.KeyboardEvent("#right"))) {
            scene.playhead += CutsceneTimeline.scrubLargeJump;
            EDebug.Log("Cutscene Editor: moving playhead right");
        // Go to previous split point
        } else if (keyDownEvent.Equals(Event.KeyboardEvent("up"))) {
            scene.playhead = selectedTrack.GetTimeOfNextSplit(scene.playhead);
            EDebug.Log("Cutscene Editor: moving playhead to previous split point");
        // Go to next split point
        } else if (keyDownEvent.Equals(Event.KeyboardEvent("down"))) {
            scene.playhead = selectedTrack.GetTimeOfPreviousSplit(scene.playhead);
            EDebug.Log("Cutscene Editor: moving playhead to next split point");
        // Go to in point
        } else if (keyDownEvent.Equals(Event.KeyboardEvent("#up"))) {
            scene.playhead = scene.inPoint;
            EDebug.Log("Cutscene Editor: moving playhead to next split point");
        // Go to out point
        } else if (keyDownEvent.Equals(Event.KeyboardEvent("#down"))) {
            scene.playhead = scene.outPoint;
            EDebug.Log("Cutscene Editor: moving playhead to next split point");
        }

        // Track selection:

        // Select track 1
          else if (key == CutsceneHotkeys.SelectTrack1.key) {
            SelectTrackAtIndex(1);
        // Select track 2
        } else if (key == CutsceneHotkeys.SelectTrack2.key) {
            SelectTrackAtIndex(2);
        // Select track 3
        } else if (key == CutsceneHotkeys.SelectTrack3.key) {
            SelectTrackAtIndex(3);
        // Select track 4
        } else if (key == CutsceneHotkeys.SelectTrack4.key) {
            SelectTrackAtIndex(4);
        // Select track 5
        } else if (key == CutsceneHotkeys.SelectTrack5.key) {
            SelectTrackAtIndex(5);
        // Select track 6
        } else if (key == CutsceneHotkeys.SelectTrack6.key) {
            SelectTrackAtIndex(6);
        // Select track 7
        } else if (key == CutsceneHotkeys.SelectTrack7.key) {
            SelectTrackAtIndex(7);
        // Select track 8
        } else if (key == CutsceneHotkeys.SelectTrack8.key) {
            SelectTrackAtIndex(8);
        // Select track 9
        } else if (key == CutsceneHotkeys.SelectTrack9.key) {
            SelectTrackAtIndex(9);
        }

        // Other:

        else {
            EDebug.Log("Cutscene Editor: unknown keyboard shortcut " + keyDownEvent);
            return;
        }

        // If we get to this point, a shortcut matching the user's keystroke has been found
        Event.current.Use();
    }
Beispiel #3
0
 private bool key_down(Event e, string key)
 {
     return e.Equals(Event.KeyboardEvent(key));
 }
Beispiel #4
0
	Event currentEvent;// = (Event)0;

	void OnSceneGUI(SceneView scnView)
	{			
		currentEvent = Event.current;
		
		if(editLevel == EditLevel.Geometry && currentEvent.Equals(Event.KeyboardEvent("v")))
		{
			currentEvent.Use();
			snapToVertex = true;
		}

		/**
		 * Snap stuff
		 */
		if(currentEvent.type == EventType.KeyUp)
			snapToVertex = false;

		if(currentEvent.type == EventType.MouseDown && currentEvent.button == 1)
			rightMouseDown = true;

		if(currentEvent.type == EventType.MouseUp && currentEvent.button == 1 || currentEvent.type == EventType.Ignore)
			rightMouseDown = false;

		#if !PROTOTYPE
			// e.type == EventType.DragUpdated || 
			if(currentEvent.type == EventType.DragPerform)
			{
				GameObject go = HandleUtility.PickGameObject(currentEvent.mousePosition, false);

				if(go != null && System.Array.Exists(DragAndDrop.objectReferences, x => x is Texture2D || x is Material))
				{
					pb_Object pb = go.GetComponent<pb_Object>();

					if( pb )
					{
						Material mat = null;
						foreach(Object t in DragAndDrop.objectReferences)
						{
							if(t is Material)
							{
								mat = (Material)t;
								break;
							}
							/* This works, but throws some bullshit errors. Not creating a material leaks, so disable this functionality. */
							else
							if(t is Texture2D)
							{
								mat = new Material(Shader.Find("Diffuse"));
								mat.mainTexture = (Texture2D)t;

								string texPath = AssetDatabase.GetAssetPath(mat.mainTexture);
								int lastDot = texPath.LastIndexOf(".");
								texPath = texPath.Substring(0, texPath.Length - (texPath.Length-lastDot));
								texPath = AssetDatabase.GenerateUniqueAssetPath(texPath + ".mat");

								AssetDatabase.CreateAsset(mat, texPath);
								AssetDatabase.Refresh();

								break;
							}
						}

						if(mat != null)
						{
							if(editLevel == EditLevel.Geometry)
							{
								pbUndo.RecordObjects(selection, "Set Face Materials");

								foreach(pb_Object pbs in selection)
									pbs.SetFaceMaterial(pbs.SelectedFaces.Length < 1 ? pbs.faces : pbs.SelectedFaces, mat);

							}
							else
							{
								pbUndo.RecordObject(pb, "Set Object Material");
								pb.SetFaceMaterial(pb.faces, mat);
							}

							pb.ToMesh();
							pb.Refresh();
							pb.Optimize();

							currentEvent.Use();
						}
					}
				}
			}
		#endif

		DrawHandleGUI(scnView);

		if(editLevelToolbarRect.Contains(currentEvent.mousePosition))
			scnView.Repaint();

		if(!rightMouseDown && getKeyUp != KeyCode.None)
		{
			if(ShortcutCheck(currentEvent))
			{
				currentEvent.Use();
				return;
			}
		}
		
		// Finished moving vertices, scaling, or adjusting uvs
		#if PROTOTYPE
		if( (movingVertices || scaling) && GUIUtility.hotControl < 1)
		{
			OnFinishVertexModification();
		}
		#else
		if( (movingVertices || movingPictures || scaling) && GUIUtility.hotControl < 1)
		{
			OnFinishVertexModification();
			UpdateHandleRotation();
			UpdateTextureHandles();
		}
		#endif

		// Check mouse position in scene and determine if we should highlight something
		if(currentEvent.type == EventType.MouseMove)
			UpdateMouse(currentEvent.mousePosition);

		// Draw GUI Handles
		if(editLevel != EditLevel.Top && editLevel != EditLevel.Plugin)
			DrawHandles();
		
		if(Tools.current != Tool.None && Tools.current != currentHandle)
			SetTool_Internal(Tools.current);

		if( (editLevel == EditLevel.Geometry || editLevel == EditLevel.Texture) && Tools.current != Tool.View)
		{
			if( selectedVertexCount > 0 ) 
			{
				if(editLevel == EditLevel.Geometry)
				{
					switch(currentHandle)
					{
						case Tool.Move:
							VertexMoveTool();
							break;
						case Tool.Scale:
							VertexScaleTool();
							break;
						case Tool.Rotate:
							VertexRotateTool();
							break;
					}
				}
				#if !PROTOTYPE	// TEXTURE HANDLES
				else if(editLevel == EditLevel.Texture && selectedVertexCount > 0)
				{
					switch(currentHandle)
					{
						case Tool.Move:
							TextureMoveTool();
							break;
						case Tool.Rotate:
							TextureRotateTool();
							break;
						case Tool.Scale:
							TextureScaleTool();
							break;
					}
		 		}
		 		#endif
		 	}
		}
		else
		{
			return;
		}

		// altClick || Tools.current == Tool.View || GUIUtility.hotControl > 0 || middleClick
		// Tools.viewTool == ViewTool.FPS || Tools.viewTool == ViewTool.Orbit
		if( pb_Handle_Utility.SceneViewInUse(currentEvent) || currentEvent.isKey || selection == null || selection.Length < 1)
		{
			dragging = false;

			return;
		}

		/* * * * * * * * * * * * * * * * * * * * *
		 *	 Vertex & Quad Wranglin' Ahead! 	 *
		 * 	 Everything from this point below	 *
		 *	 overrides something Unity related.  *
		 * * * * * * * * * * * * * * * * * * * * */

		// This prevents us from selecting other objects in the scene,
		// and allows for the selection of faces / vertices.
		int controlID = GUIUtility.GetControlID(FocusType.Passive);
		HandleUtility.AddDefaultControl(controlID);

		// If selection is made, don't use default handle -- set it to Tools.None
		if(selectedVertexCount > 0)
			Tools.current = Tool.None;

		if(leftClick) {
			// double clicking object
			if(currentEvent.clickCount > 1)
			{
				DoubleClick(currentEvent);
			}

			mousePosition_initial = mousePosition;
		}

		if(mouseDrag)
			dragging = true;

		if(ignore)
		{
			if(dragging)
			{
				dragging = false;
				DragCheck();
			}
			
			if(doubleClicked)
				doubleClicked = false;
		}

		if(leftClickUp)
		{
			if(doubleClicked)
			{
				doubleClicked = false;
			}
			else
			{
				if(!dragging)
				{
					#if !PROTOTYPE
					if(pb_UV_Editor.instance)
						pb_UV_Editor.instance.ResetUserPivot();
					#endif

					RaycastCheck(currentEvent.mousePosition);
				}
				else
				{
					dragging = false;

					#if !PROTOTYPE
					if(pb_UV_Editor.instance)
						pb_UV_Editor.instance.ResetUserPivot();
					#endif

					DragCheck();
				}
			}
		}
	}