本文整理汇总了C#中Camera.GetInstanceID方法的典型用法代码示例。如果您正苦于以下问题:C# Camera.GetInstanceID方法的具体用法?C# Camera.GetInstanceID怎么用?C# Camera.GetInstanceID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Camera
的用法示例。
在下文中一共展示了Camera.GetInstanceID方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateMirrorObjects
// On-demand create any objects we need
private void CreateMirrorObjects( Camera currentCamera, out Camera reflectionCamera )
{
reflectionCamera = null;
// Reflection render texture
if( !m_ReflectionTexture || m_OldReflectionTextureSize != m_TextureSize )
{
if( m_ReflectionTexture )
DestroyImmediate( m_ReflectionTexture );
m_ReflectionTexture = new RenderTexture( m_TextureSize, m_TextureSize, 16 );
m_ReflectionTexture.name = "__MirrorReflection" + GetInstanceID();
m_ReflectionTexture.isPowerOfTwo = true;
m_ReflectionTexture.hideFlags = HideFlags.DontSave;
m_OldReflectionTextureSize = m_TextureSize;
}
// Camera for reflection
reflectionCamera = m_ReflectionCameras[currentCamera] as Camera;
if( !reflectionCamera ) // catch both not-in-dictionary and in-dictionary-but-deleted-GO
{
GameObject go = new GameObject( "Mirror Refl Camera id" + GetInstanceID() + " for " + currentCamera.GetInstanceID(), typeof(Camera), typeof(Skybox) );
reflectionCamera = go.camera;
reflectionCamera.enabled = false;
reflectionCamera.transform.position = transform.position;
reflectionCamera.transform.rotation = transform.rotation;
reflectionCamera.gameObject.AddComponent("FlareLay er");
go.hideFlags = HideFlags.HideAndDontSave;
m_ReflectionCameras[currentCamera] = reflectionCamera;
}
}
示例2: CreateWaterObjects
// On-demand create any objects we need for water
private void CreateWaterObjects( Camera currentCamera, out Camera reflectionCamera, out Camera refractionCamera )
{
WaterMode mode = GetWaterMode();
reflectionCamera = null;
refractionCamera = null;
if( mode >= WaterMode.Reflective )
{
// Reflection render texture
if( !m_ReflectionTexture || m_OldReflectionTextureSize != m_TextureSize )
{
if( m_ReflectionTexture )
DestroyImmediate( m_ReflectionTexture );
m_ReflectionTexture = new RenderTexture( m_TextureSize, m_TextureSize, 16 );
m_ReflectionTexture.name = "__WaterReflection" + GetInstanceID();
m_ReflectionTexture.isPowerOfTwo = true;
m_ReflectionTexture.hideFlags = HideFlags.DontSave;
m_OldReflectionTextureSize = m_TextureSize;
}
// Camera for reflection
m_ReflectionCameras.TryGetValue(currentCamera, out reflectionCamera);
if (!reflectionCamera) // catch both not-in-dictionary and in-dictionary-but-deleted-GO
{
GameObject go = new GameObject( "Water Refl Camera id" + GetInstanceID() + " for " + currentCamera.GetInstanceID(), typeof(Camera), typeof(Skybox) );
reflectionCamera = go.GetComponent<Camera>();
reflectionCamera.enabled = false;
reflectionCamera.transform.position = transform.position;
reflectionCamera.transform.rotation = transform.rotation;
reflectionCamera.gameObject.AddComponent<FlareLayer>();
go.hideFlags = HideFlags.HideAndDontSave;
m_ReflectionCameras[currentCamera] = reflectionCamera;
}
}
if( mode >= WaterMode.Refractive )
{
// Refraction render texture
if( !m_RefractionTexture || m_OldRefractionTextureSize != m_TextureSize )
{
if( m_RefractionTexture )
DestroyImmediate( m_RefractionTexture );
m_RefractionTexture = new RenderTexture( m_TextureSize, m_TextureSize, 16 );
m_RefractionTexture.name = "__WaterRefraction" + GetInstanceID();
m_RefractionTexture.isPowerOfTwo = true;
m_RefractionTexture.hideFlags = HideFlags.DontSave;
m_OldRefractionTextureSize = m_TextureSize;
}
// Camera for refraction
m_RefractionCameras.TryGetValue(currentCamera, out refractionCamera);
if (!refractionCamera) // catch both not-in-dictionary and in-dictionary-but-deleted-GO
{
GameObject go = new GameObject( "Water Refr Camera id" + GetInstanceID() + " for " + currentCamera.GetInstanceID(), typeof(Camera), typeof(Skybox) );
refractionCamera = go.GetComponent<Camera>();
refractionCamera.enabled = false;
refractionCamera.transform.position = transform.position;
refractionCamera.transform.rotation = transform.rotation;
refractionCamera.gameObject.AddComponent<FlareLayer>();
go.hideFlags = HideFlags.HideAndDontSave;
m_RefractionCameras[currentCamera] = refractionCamera;
}
}
}
示例3: SetActiveCamera
/**
* change which camera is active. Must be done in a way so that there is always
* an active camera
**/
public void SetActiveCamera(Camera newActiveCamera) {
Camera oldCamera = masterCamera;
masterCamera = newActiveCamera;
//masterCamera.enabled = true;
masterCamera.camera.active = true;
if(oldCamera != null && oldCamera != masterCamera) {
oldCamera.camera.active = false;
//oldCamera.enabled = false;
}
masterCamera.GetComponent<AudioListener>().enabled = true;
Debug.Log("Camera updated to be "+newActiveCamera.GetInstanceID());
}
示例4: GetReflectionCamera
/// <summary>
/// Get or create the camera used for reflection.
/// </summary>
Camera GetReflectionCamera (Camera current, Material mat, int textureSize)
{
if (!mTex || mTexSize != textureSize)
{
if (mTex) DestroyImmediate(mTex);
mTex = new RenderTexture(textureSize, textureSize, 16);
mTex.name = "__MirrorReflection" + GetInstanceID();
mTex.isPowerOfTwo = true;
mTex.hideFlags = HideFlags.DontSave;
mTexSize = textureSize;
}
Camera cam = mCameras[current] as Camera;
if (!cam)
{
GameObject go = new GameObject("Mirror Refl Camera id" + GetInstanceID() + " for " + current.GetInstanceID(), typeof(Camera), typeof(Skybox));
go.hideFlags = HideFlags.HideAndDontSave;
cam = go.camera;
cam.enabled = false;
Transform t = cam.transform;
t.position = mTrans.position;
t.rotation = mTrans.rotation;
cam.gameObject.AddComponent("FlareLayer");
mCameras[current] = cam;
}
// Automatically update the reflection texture
if (mat.HasProperty("_ReflectionTex")) mat.SetTexture("_ReflectionTex", mTex);
return cam;
}
示例5: CreateMirrorObjects
//-----------------------------------------------------
// On-demand create any objects we need
private void CreateMirrorObjects( Camera currentCamera, out Camera reflectionCamera )
{
reflectionCamera = null;
// Reflection render texture
if( !m_ReflectionTexture || m_OldReflectionTextureSize != m_TextureSize )
{
if( m_ReflectionTexture )
DestroyImmediate( m_ReflectionTexture );
m_ReflectionTexture = new RenderTexture( m_TextureSize, m_TextureSize, 16 );
m_ReflectionTexture.name = "__MirrorReflection" + GetInstanceID();
m_ReflectionTexture.isPowerOfTwo = true;
// m_ReflectionTexture.hideFlags = HideFlags.DontSave;
m_ReflectionTexture.wrapMode = TextureWrapMode.Clamp;
m_OldReflectionTextureSize = m_TextureSize;
}
// Camera for reflection
reflectionCamera = m_ReflectionCameras[currentCamera] as Camera;
if( !reflectionCamera ) // catch both not-in-dictionary and in-dictionary-but-deleted-GO
{
GameObject go = new GameObject( "Mirror Refl Camera id" + GetInstanceID() + " for " + currentCamera.GetInstanceID(), typeof(Camera), typeof(Skybox) );
// go.transform.parent = transform; // TODO vérifier si les caméras sont bien détruites par le gc quand elles ne sont plus référencées
reflectionCamera = go.GetComponent<Camera>();
reflectionCamera.enabled = false;
reflectionCamera.transform.position = transform.position;
reflectionCamera.transform.rotation = transform.rotation;
reflectionCamera.gameObject.AddComponent<FlareLayer>();
// go.hideFlags = HideFlags.HideAndDontSave;
m_ReflectionCameras[currentCamera] = reflectionCamera;
}
}
示例6: CreateMirrorObjects
// On-demand create any objects we need
private void CreateMirrorObjects( Camera currentCamera, out Camera reflectionCamera )
{
if( !m_ReflectionTexture ){
m_ReflectionTexture = new RenderTexture( m_TextureSize, m_TextureSize, 16 );
m_ReflectionTexture.name = "__MirrorReflection" + GetInstanceID();
m_ReflectionTexture.isPowerOfTwo = true;
m_ReflectionTexture.hideFlags = HideFlags.DontSave;
}
// Camera for reflection
reflectionCamera = m_ReflectionCamera;
if( !reflectionCamera ) // catch both not-in-dictionary and in-dictionary-but-deleted-GO
{
GameObject go = new GameObject( "Mirror Refl Camera id" + GetInstanceID() + " for " + currentCamera.GetInstanceID(), typeof(Camera), typeof(Skybox) );
reflectionCamera = go.GetComponent<Camera>();
reflectionCamera.enabled = true;
go.hideFlags = HideFlags.DontSave;
m_ReflectionCamera = reflectionCamera;
// reflectionCamera.gameObject.AddComponent("ReflectionCameraControl");
reflectionCamera.gameObject.AddComponent<ReflectionCameraControl>();
}
reflectionCamera.depth = currentCamera.depth-1;
reflectionCamera.fieldOfView = currentCamera.fieldOfView;
reflectionCamera.transform.position = transform.position;
reflectionCamera.transform.rotation = transform.rotation;
}
示例7: CreateWaterObjects
// On-demand create any objects we need for water
private void CreateWaterObjects( Camera currentCamera, out Camera reflectionCamera )
{
//WaterMode mode = GetWaterMode();
GetWaterMode();
reflectionCamera = null;
// Reflection render texture
if( !m_ReflectionTexture || m_OldReflectionTextureSize != m_TextureSize )
{
if( m_ReflectionTexture )
DestroyImmediate( m_ReflectionTexture );
m_ReflectionTexture = new RenderTexture( Screen.width, Screen.height, 16 );
m_ReflectionTexture.name = "__WaterReflection" + GetInstanceID();
m_ReflectionTexture.isPowerOfTwo = false;
m_ReflectionTexture.hideFlags = HideFlags.DontSave;
m_OldReflectionTextureSize = m_TextureSize;
}
// Camera for reflection
reflectionCamera = m_ReflectionCameras[currentCamera] as Camera;
if( !reflectionCamera ) // catch both not-in-dictionary and in-dictionary-but-deleted-GO
{
GameObject go = new GameObject( "Water Refl Camera id" + GetInstanceID() + " for " + currentCamera.GetInstanceID(), typeof(Camera), typeof(Skybox) );
reflectionCamera = go.GetComponent<Camera>();
reflectionCamera.enabled = false;
reflectionCamera.transform.position = transform.position;
reflectionCamera.transform.rotation = transform.rotation;
reflectionCamera.gameObject.AddComponent<FlareLayer>();
reflectionCamera.GetComponent<Camera>().useOcclusionCulling = false;
reflectionCamera.GetComponent<Camera>().renderingPath = RenderingPath.VertexLit;
go.hideFlags = HideFlags.HideAndDontSave;
m_ReflectionCameras[currentCamera] = reflectionCamera;
}
}
示例8: CreatePortalObjects
// On-demand create any objects we need
private void CreatePortalObjects(Camera currentCamera, out Camera portalCamera)
{
portalCamera = null;
// Portal render texture
if (!m_PortalTexture || m_OldPortalTextureSize != m_TextureSize)
{
if (m_PortalTexture)
DestroyImmediate(m_PortalTexture);
m_PortalTexture = new RenderTexture(m_TextureSize, m_TextureSize, 16);
m_PortalTexture.name = "__PortalView" + GetInstanceID();
m_PortalTexture.isPowerOfTwo = true;
m_PortalTexture.hideFlags = HideFlags.DontSave;
m_OldPortalTextureSize = m_TextureSize;
}
// Camera for reflection
portalCamera = m_PortalCameras[currentCamera] as Camera;
if (!portalCamera) // catch both not-in-dictionary and in-dictionary-but-deleted-GO
{
GameObject go = new GameObject("Portal Camera id" + GetInstanceID() + " for " + currentCamera.GetInstanceID(), typeof(Camera), typeof(Skybox));
portalCamera = go.GetComponent<Camera>();
portalCamera.enabled = false;
portalCamera.transform.position = otherPortal.transform.position;
portalCamera.transform.rotation = otherPortal.transform.rotation;
portalCamera.gameObject.AddComponent<FlareLayer>();
go.hideFlags = HideFlags.HideAndDontSave;
m_PortalCameras[currentCamera] = portalCamera;
}
}