Ejemplo n.º 1
0
	public static void ExecuteTool(int toolSlot)
	{
	    if (_currentSelectedShelf < 0 && _currentSelectedShelf >= _shelves.Count)
	    {
		Debug.LogWarning("Invalid shelf selected. Unable to apply tool.");
		return;
	    }

	    if (toolSlot < 0 || toolSlot >= _shelves[_currentSelectedShelf]._tools.Count)
	    {
		Debug.LogWarning("Invalid tool selected. Unable to apply tool.");
		return;
	    }

	    HEU_ShelfToolData toolData = _shelves[_currentSelectedShelf]._tools[toolSlot];

	    GameObject[] selectedObjects = HEU_EditorUtility.GetSelectedObjects();

	    string assetPath = toolData._assetPath;

	    if (toolData._toolType == HEU_ShelfToolData.ToolType.GENERATOR)
	    {
		Matrix4x4 targetMatrix = HEU_EditorUtility.GetSelectedObjectsMeanTransform();
		Vector3 position = HEU_HAPIUtility.GetPosition(ref targetMatrix);
		Quaternion rotation = HEU_HAPIUtility.GetQuaternion(ref targetMatrix);
		Vector3 scale = HEU_HAPIUtility.GetScale(ref targetMatrix);
		scale = Vector3.one;

		ExecuteToolGenerator(toolData._name, assetPath, position, rotation, scale);
	    }
	    else if (selectedObjects.Length == 0)
	    {
		ExecuteToolNoInput(toolData._name, assetPath);
	    }
	    else if (toolData._toolType == HEU_ShelfToolData.ToolType.OPERATOR_SINGLE)
	    {
		ExecuteToolOperatorSingle(toolData._name, assetPath, selectedObjects);
	    }
	    else if (toolData._toolType == HEU_ShelfToolData.ToolType.OPERATOR_MULTI)
	    {
		ExecuteToolOperatorMultiple(toolData._name, assetPath, selectedObjects);
	    }
	    else if (toolData._toolType == HEU_ShelfToolData.ToolType.BATCH)
	    {
		ExecuteToolBatch(toolData._name, assetPath, selectedObjects);
	    }
	}
Ejemplo n.º 2
0
		public static void ExecuteTool(int toolSlot)
		{
			if(toolSlot < 0 || toolSlot >= _tools.Count)
			{
				Debug.LogWarning("Invalid tool selection!");
				return;
			}

			HEU_ShelfToolData toolData = _tools[toolSlot];
			if(toolData.toolType == HEU_ShelfToolData.ToolType.GENARATOR)
			{
				Matrix4x4 targetMatrix = HEU_EditorUtility.GetSelectedObjectsMeanTransform();
				Vector3 position = HEU_HAPIUtility.GetPosition(ref targetMatrix);
				Quaternion rotation = HEU_HAPIUtility.GetQuaternion(ref targetMatrix);
				Vector3 scale = HEU_HAPIUtility.GetScale(ref targetMatrix);
				scale = Vector3.one;

				ExecuteToolGenerator(toolData.name, toolData.assetPath, position, rotation, scale);
			}
			else if(toolData.toolType == HEU_ShelfToolData.ToolType.OPERATOR_SINGLE)
			{
				GameObject[] selectedObjects = HEU_EditorUtility.GetSelectedObjects();

				ExecuteToolOperatorSingle(toolData.name, toolData.assetPath, selectedObjects);
			}
			else if (toolData.toolType == HEU_ShelfToolData.ToolType.OPERATOR_MULTI)
			{
				GameObject[] selectedObjects = HEU_EditorUtility.GetSelectedObjects();

				ExecuteToolOperatorMultiple(toolData.name, toolData.assetPath, selectedObjects);
			}
			else if (toolData.toolType == HEU_ShelfToolData.ToolType.BATCH)
			{
				GameObject[] selectedObjects = HEU_EditorUtility.GetSelectedObjects();

				ExecuteToolBatch(toolData.name, toolData.assetPath, selectedObjects);
			}
		}