浏览代码

Merge pull request #658 from Unity-Technologies/Update-decal

Update decal menu
/namespace
GitHub 7 年前
当前提交
2e8c02da
共有 6 个文件被更改,包括 50 次插入17 次删除
  1. 16
      ScriptableRenderPipeline/HDRenderPipeline/Decal/DecalProjectorComponent.cs
  2. 10
      ScriptableRenderPipeline/HDRenderPipeline/Decal/DecalSystem.cs
  3. 8
      ScriptableRenderPipeline/HDRenderPipeline/Decal/Editor.meta
  4. 22
      ScriptableRenderPipeline/HDRenderPipeline/Decal/Editor/DecalMenuItems.cs
  5. 11
      ScriptableRenderPipeline/HDRenderPipeline/Decal/Editor/DecalMenuItems.cs.meta

16
ScriptableRenderPipeline/HDRenderPipeline/Decal/DecalProjectorComponent.cs


using System;
using UnityEditor;
using UnityEngine;
namespace UnityEngine.Experimental.Rendering.HDPipeline
{
[ExecuteInEditMode]

public void Start()
{
m_PropertyBlock = new MaterialPropertyBlock();
m_PropertyBlock = new MaterialPropertyBlock();
DecalSystem.instance.AddDecal(this);
}

public void OnDrawGizmosSelected()
{
DrawGizmo(true);
}
[MenuItem("GameObject/Effects/Decal", false, 0)]
static void CreateDecal(MenuCommand menuCommand)
{
// Create a custom game object
GameObject go = new GameObject("Decal");
go.AddComponent<DecalProjectorComponent>();
// Ensure it gets re-parented if this was a context click (otherwise does nothing)
GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject);
// Register the creation in the undo system
Undo.RegisterCreatedObjectUndo(go, "Create " + go.name);
Selection.activeObject = go;
}
public void UpdatePropertyBlock(Vector3 cameraPos)

10
ScriptableRenderPipeline/HDRenderPipeline/Decal/DecalSystem.cs


public DecalSystem()
{
CreateCubeMesh();
CreateCubeMesh();
}
void CreateCubeMesh()

public void AddDecal(DecalProjectorComponent d)
{
// If no decal material assign, don't add it
if (d.m_Material == null)
return;
m_Decals.Add(d);
m_Decals.Add(d);
}
}

if (m_CubeMesh == null)
CreateCubeMesh();
foreach (var decal in m_Decals)
{
{
decal.UpdatePropertyBlock(cameraPos);
cmd.DrawMesh(m_CubeMesh, decal.transform.localToWorldMatrix, decal.m_Material, 0, 0, decal.GetPropertyBlock());
}

8
ScriptableRenderPipeline/HDRenderPipeline/Decal/Editor.meta


fileFormatVersion: 2
guid: d48c34658396f5e478714620e1290cfc
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

22
ScriptableRenderPipeline/HDRenderPipeline/Decal/Editor/DecalMenuItems.cs


using System.IO;
using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
public class DecalMenuItems
{
[MenuItem("GameObject/Render Pipeline/High Definition/DecalProjector", false, 0)]
static void CreateDecal(MenuCommand menuCommand)
{
// Create a custom game object
GameObject go = new GameObject("DecalProjector");
go.AddComponent<DecalProjectorComponent>();
// Ensure it gets re-parented if this was a context click (otherwise does nothing)
GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject);
// Register the creation in the undo system
Undo.RegisterCreatedObjectUndo(go, "Create " + go.name);
Selection.activeObject = go;
}
}
}

11
ScriptableRenderPipeline/HDRenderPipeline/Decal/Editor/DecalMenuItems.cs.meta


fileFormatVersion: 2
guid: b5a73f64291613049982d2958ead1667
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存