plantilla base para movimiento básico
This commit is contained in:
Robii Aragon
2026-02-05 05:07:55 -08:00
parent ed7b223c04
commit fd87a6ffd5
14441 changed files with 13711084 additions and 20 deletions

View File

@@ -0,0 +1,13 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class cameraEffect : MonoBehaviour
{
public bool useRenderEffect = true;
public virtual void renderEffect (RenderTexture source, RenderTexture destination, Camera mainCamera)
{
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: d3727478154588d43a905558c8995957
timeCreated: 1576378337
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Camera/Camera Effect/cameraEffect.cs
uploadId: 814740

View File

@@ -0,0 +1,293 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class cameraEffectSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool cameraEffectEnabled = true;
public bool renderEffectActive = true;
public bool startWithCameraEffectActive;
public bool cameraEffectChangeDisabled;
public int currentCameraEffectIndex;
[Space]
[Header ("Extra Cameras Effect")]
[Space]
public bool renderExtraCameras;
public List<extraCameraEffectSystem> extraCameraEffectSystemList = new List<extraCameraEffectSystem> ();
[Space]
[Header ("Debug")]
[Space]
public bool cameraEffectActive;
public cameraEffect currentCameraEffect;
[Space]
[Header ("Camera Effect Info List")]
[Space]
public List<cameraEffectInfo> cameraEffectInfoList = new List<cameraEffectInfo> ();
[Space]
[Header ("Components")]
[Space]
public Camera mainCamera;
bool cameraEffectAtStartConfigured;
void Start ()
{
if (startWithCameraEffectActive) {
setCameraEffectActiveState (true);
} else {
this.enabled = false;
}
}
private void OnRenderImage (RenderTexture source, RenderTexture destination)
{
if (!renderEffectActive) {
return;
}
if (cameraEffectActive && currentCameraEffect != null && currentCameraEffect.useRenderEffect) {
if (mainCamera == null) {
mainCamera = Camera.main;
}
currentCameraEffect.renderEffect (source, destination, mainCamera);
}
}
public void extraRenderImage (RenderTexture source, RenderTexture destination, Camera currentCamera)
{
if (!renderEffectActive) {
return;
}
if (cameraEffectActive && currentCameraEffect != null && currentCameraEffect.useRenderEffect) {
currentCameraEffect.renderEffect (source, destination, currentCamera);
}
}
public void setCameraEffectByName (string cameraStateName)
{
int cameraEffectIndex = cameraEffectInfoList.FindIndex (a => a.Name == cameraStateName);
if (cameraEffectIndex > -1) {
currentCameraEffectIndex = cameraEffectIndex;
setCameraEffectActiveState (true);
}
}
public void setMainCameraEffectByName (string cameraStateName)
{
int cameraEffectIndex = cameraEffectInfoList.FindIndex (a => a.Name == cameraStateName);
if (cameraEffectIndex > -1) {
currentCameraEffectIndex = cameraEffectIndex;
for (int i = 0; i < cameraEffectInfoList.Count; i++) {
if (currentCameraEffectIndex == i) {
cameraEffectInfoList [i].activeAsMainCameraEffect = true;
} else {
cameraEffectInfoList [i].activeAsMainCameraEffect = false;
}
}
setCameraEffectActiveState (true);
}
}
public void disableMainCameraEffectActiveState (string cameraStateName)
{
int cameraEffectIndex = cameraEffectInfoList.FindIndex (a => a.Name == cameraStateName);
if (cameraEffectIndex > -1) {
currentCameraEffectIndex = cameraEffectIndex;
cameraEffectInfoList [currentCameraEffectIndex].activeAsMainCameraEffect = false;
setCameraEffectActiveState (false);
}
}
public void setIfCurrentCameraEffectRemainActive (bool state)
{
if (state) {
checkIfMainCameraEffectsAreActive ();
} else {
if (cameraEffectActive) {
setCameraEffectActiveState (false);
}
}
}
public void checkIfMainCameraEffectsAreActive ()
{
for (int i = 0; i < cameraEffectInfoList.Count; i++) {
if (cameraEffectInfoList [i].activeAsMainCameraEffect) {
print ("main camera effect active " + cameraEffectInfoList [i].Name);
cameraEffectActive = true;
currentCameraEffectIndex = i;
setCameraEffectActiveState (true);
return;
}
}
}
public bool canUseCameraEffect ()
{
if (!cameraEffectEnabled) {
return false;
}
if (cameraEffectChangeDisabled && (!startWithCameraEffectActive || cameraEffectAtStartConfigured)) {
return false;
}
return true;
}
public void enableOrDisableCameraEffectActive ()
{
setCameraEffectActiveState (!cameraEffectActive);
}
public void setCameraEffectActiveState (bool state)
{
if (!canUseCameraEffect ()) {
return;
}
if (startWithCameraEffectActive) {
cameraEffectAtStartConfigured = true;
}
if (!state) {
for (int i = 0; i < cameraEffectInfoList.Count; i++) {
if (cameraEffectInfoList [i].activeAsMainCameraEffect) {
print ("main camera effect active " + cameraEffectInfoList [i].Name);
cameraEffectActive = true;
currentCameraEffectIndex = i;
}
}
}
cameraEffectActive = state;
this.enabled = cameraEffectActive;
if (cameraEffectActive) {
currentCameraEffect = cameraEffectInfoList [currentCameraEffectIndex].mainCameraEffect;
cameraEffectInfoList [currentCameraEffectIndex].eventToEnableEffect.Invoke ();
} else {
cameraEffectInfoList [currentCameraEffectIndex].eventToDisableEffect.Invoke ();
}
if (renderExtraCameras) {
for (int i = 0; i < extraCameraEffectSystemList.Count; i++) {
extraCameraEffectSystemList [i].enabled = cameraEffectActive;
}
}
}
public void setCurrentCameraEffect (cameraEffect newCameraEffect)
{
currentCameraEffect = newCameraEffect;
}
public void setNextCameraEffect ()
{
if (!canUseCameraEffect ()) {
return;
}
cameraEffectInfoList [currentCameraEffectIndex].eventToDisableEffect.Invoke ();
currentCameraEffectIndex++;
if (currentCameraEffectIndex >= cameraEffectInfoList.Count) {
currentCameraEffectIndex = 0;
}
currentCameraEffect = cameraEffectInfoList [currentCameraEffectIndex].mainCameraEffect;
cameraEffectInfoList [currentCameraEffectIndex].eventToEnableEffect.Invoke ();
if (!cameraEffectActive) {
setCameraEffectActiveState (true);
}
}
public void setPreviousCameraEffect ()
{
if (!canUseCameraEffect ()) {
return;
}
cameraEffectInfoList [currentCameraEffectIndex].eventToDisableEffect.Invoke ();
currentCameraEffectIndex--;
if (currentCameraEffectIndex < 0) {
currentCameraEffectIndex = cameraEffectInfoList.Count - 1;
}
currentCameraEffect = cameraEffectInfoList [currentCameraEffectIndex].mainCameraEffect;
cameraEffectInfoList [currentCameraEffectIndex].eventToEnableEffect.Invoke ();
if (!cameraEffectActive) {
setCameraEffectActiveState (true);
}
}
public void inputSetNextCameraEffect ()
{
setNextCameraEffect ();
}
public void inputSetPreviousCameraEffect ()
{
setPreviousCameraEffect ();
}
public void inputEnableOrDisableCameraEffectActive ()
{
enableOrDisableCameraEffectActive ();
}
[System.Serializable]
public class cameraEffectInfo
{
public string Name;
public bool activeAsMainCameraEffect;
public cameraEffect mainCameraEffect;
[Space]
public UnityEvent eventToEnableEffect;
public UnityEvent eventToDisableEffect;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 1fbc8a24b8590ba41b6cca3145278da4
timeCreated: 1576370101
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Camera/Camera Effect/cameraEffectSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,22 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class customCameraEffect : cameraEffect
{
public Material mainMaterial;
public bool useReleaseMethodEnabled;
public override void renderEffect (RenderTexture source, RenderTexture destination, Camera mainCamera)
{
if (useReleaseMethodEnabled) {
var temporaryTexture = RenderTexture.GetTemporary (source.width, source.height);
Graphics.Blit (source, temporaryTexture, mainMaterial, 0);
Graphics.Blit (temporaryTexture, destination, mainMaterial, 1);
RenderTexture.ReleaseTemporary (temporaryTexture);
} else {
Graphics.Blit (source, destination, mainMaterial);
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 80616fc2119ddf94e91826771009f799
timeCreated: 1581232009
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Camera/Camera Effect/customCameraEffect.cs
uploadId: 814740

View File

@@ -0,0 +1,27 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class extraCameraEffectSystem : MonoBehaviour
{
public cameraEffectSystem maincameraEffectSystem;
public Camera mainCamera;
private void OnRenderImage (RenderTexture source, RenderTexture destination)
{
if (!maincameraEffectSystem.renderEffectActive) {
return;
}
if (mainCamera == null) {
mainCamera = Camera.main;
}
if (!mainCamera.enabled) {
return;
}
maincameraEffectSystem.extraRenderImage (source, destination, mainCamera);
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: c0f54290bb41dc248a2513912a7ac203
timeCreated: 1581697643
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Camera/Camera Effect/extraCameraEffectSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,395 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class photoModeSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool photoModeEnabled = true;
public float rotationSpeed;
public float smoothCameraRotationSpeedVertical;
public float smoothCameraRotationSpeedHorizontal;
public Vector2 clampTiltX;
public float movementSpeed;
public float sidesRotationSpeed = 1;
public bool clampCameraDistance;
public float maxCameraRadius;
public bool setCustomTimeScale;
public float customTimeScale;
public bool freezeAllCharactersOnScene;
public bool canUseTurboEnabled = true;
public float turboSpeedMultiplier = 2;
[Space]
[Header ("Events Settings")]
[Space]
public UnityEvent eventOnPhotoModeActive;
public UnityEvent eventOnPhotoModeDeactive;
public UnityEvent eventOnTakePhoto;
[Space]
[Header ("Debug")]
[Space]
public Vector2 movementAxisValues;
public Vector2 mouseAxisValues;
public Vector2 currentLookAngle;
public bool photoModeInputActive;
public bool photoModeActive;
public bool turboActive;
[Space]
[Header ("Component Elements")]
[Space]
public Transform mainTransform;
public Transform pivotTransform;
public Transform mainCameraTransform;
public playerInputManager playerInput;
public playerCamera mainPlayerCamera;
public timeBullet mainTimeBullet;
public menuPause pauseManager;
Transform previousMainCameraParent;
Quaternion currentPivotRotation;
float currentCameraUpRotation;
Vector3 moveInput;
bool movingCameraUp;
bool movingCameraDown;
bool rotatingCameraToRight;
bool rotatingCameraToLeft;
Vector3 lastCameraPosition;
bool cameraRotationActive = true;
bool resetingCamera;
float previosScaleTime;
Coroutine resetCameraPositionCoroutine;
Coroutine mainUpdateCoroutine;
public void stopUpdateCoroutine ()
{
if (mainUpdateCoroutine != null) {
StopCoroutine (mainUpdateCoroutine);
}
}
IEnumerator updateCoroutine ()
{
var waitTime = new WaitForSeconds (0.00001f);
while (true) {
// void Update ()
// {
if (photoModeActive && photoModeInputActive) {
movementAxisValues = playerInput.getPlayerRawMovementAxisWithoutCheckingEnabled ();
mouseAxisValues = playerInput.getPlayerMouseAxis ();
//get the look angle value
if (cameraRotationActive) {
currentLookAngle.x = mouseAxisValues.x * rotationSpeed;
currentLookAngle.y -= mouseAxisValues.y * rotationSpeed;
}
//clamp these values to limit the camera rotation
currentLookAngle.y = Mathf.Clamp (currentLookAngle.y, -clampTiltX.x, clampTiltX.y);
//set every angle in the camera and the pivot
currentPivotRotation = Quaternion.Euler (currentLookAngle.y, 0, 0);
pivotTransform.localRotation = Quaternion.Slerp (pivotTransform.localRotation, currentPivotRotation, smoothCameraRotationSpeedVertical * Time.unscaledDeltaTime);
currentCameraUpRotation = Mathf.Lerp (currentCameraUpRotation, currentLookAngle.x, smoothCameraRotationSpeedHorizontal * Time.unscaledDeltaTime);
mainTransform.Rotate (0, currentCameraUpRotation, 0);
if (rotatingCameraToRight) {
mainTransform.Rotate (0, 0, -sidesRotationSpeed);
rotatingCameraToRight = false;
}
if (rotatingCameraToLeft) {
mainTransform.Rotate (0, 0, sidesRotationSpeed);
rotatingCameraToLeft = false;
}
float currentSpeed = movementSpeed;
if (turboActive) {
currentSpeed *= turboSpeedMultiplier;
}
moveInput = (movementAxisValues.y * pivotTransform.forward + movementAxisValues.x * pivotTransform.right) * currentSpeed;
if (movingCameraUp) {
moveInput += Vector3.up * currentSpeed;
movingCameraUp = false;
}
if (movingCameraDown) {
moveInput -= Vector3.up * currentSpeed;
movingCameraDown = false;
}
mainTransform.position += (moveInput * Time.unscaledDeltaTime);
if (clampCameraDistance) {
Vector3 newLocation = mainTransform.position;
Vector3 centerPosition = lastCameraPosition;
float distance = GKC_Utils.distance (newLocation, centerPosition);
if (distance > maxCameraRadius) {
Vector3 fromOriginToObject = newLocation - centerPosition;
fromOriginToObject *= maxCameraRadius / distance;
newLocation = centerPosition + fromOriginToObject;
}
mainTransform.position = newLocation;
}
}
yield return waitTime;
}
}
public void setPhotoModeActiveState (bool state)
{
if (state == photoModeActive) {
return;
}
if (resetingCamera) {
return;
}
photoModeActive = state;
stopUpdateCoroutine ();
if (photoModeActive) {
mainUpdateCoroutine = StartCoroutine (updateCoroutine ());
}
if (setCustomTimeScale) {
if (photoModeActive) {
previosScaleTime = Time.timeScale;
mainTimeBullet.setTimeValues (true, customTimeScale);
pauseManager.setTimeScale (customTimeScale);
} else {
if (previosScaleTime < 1) {
mainTimeBullet.setTimeValues (true, previosScaleTime);
pauseManager.setTimeScale (previosScaleTime);
} else {
mainTimeBullet.disableTimeBullet ();
pauseManager.setTimeScale (1);
}
}
}
if (freezeAllCharactersOnScene) {
GKC_Utils.pauseOrResumeAllCharactersScene (state);
}
currentLookAngle = Vector2.zero;
if (photoModeActive) {
eventOnPhotoModeActive.Invoke ();
movementAxisValues = Vector2.zero;
mouseAxisValues = Vector2.zero;
lastCameraPosition = mainCameraTransform.position;
previousMainCameraParent = mainCameraTransform.parent;
mainTransform.position = mainCameraTransform.position;
mainTransform.rotation = mainPlayerCamera.transform.rotation;
mainTransform.eulerAngles = new Vector3 (mainTransform.eulerAngles.x, mainCameraTransform.eulerAngles.y, mainTransform.eulerAngles.z);
pivotTransform.rotation = mainCameraTransform.rotation;
pivotTransform.localEulerAngles = new Vector3 (pivotTransform.localEulerAngles.x, 0, 0);
currentLookAngle.y = pivotTransform.localEulerAngles.x;
if (currentLookAngle.y > 180) {
currentLookAngle.y -= 360;
}
mainCameraTransform.SetParent (pivotTransform);
photoModeInputActive = true;
} else {
photoModeInputActive = false;
resetCameraPosition ();
}
turboActive = false;
}
public void enableOrDisablePhotoMode ()
{
setPhotoModeActiveState (!photoModeActive);
}
public void takePhoto ()
{
eventOnTakePhoto.Invoke ();
}
public void resetCameraPosition ()
{
if (resetCameraPositionCoroutine != null) {
StopCoroutine (resetCameraPositionCoroutine);
}
resetCameraPositionCoroutine = StartCoroutine (resetCameraCoroutine ());
}
IEnumerator resetCameraCoroutine ()
{
setCameraDirection ();
if (previousMainCameraParent) {
resetingCamera = true;
mainCameraTransform.SetParent (previousMainCameraParent);
Vector3 worldTargetPosition = previousMainCameraParent.position;
float dist = GKC_Utils.distance (mainCameraTransform.position, worldTargetPosition);
float duration = dist / movementSpeed;
float t = 0;
while ((t < 1 && (mainCameraTransform.localPosition != Vector3.zero || mainCameraTransform.localRotation != Quaternion.identity))) {
t += Time.unscaledDeltaTime / duration;
mainCameraTransform.localPosition = Vector3.Lerp (mainCameraTransform.localPosition, Vector3.zero, t);
mainCameraTransform.localRotation = Quaternion.Lerp (mainCameraTransform.localRotation, Quaternion.identity, t);
yield return null;
}
resetingCamera = false;
}
eventOnPhotoModeDeactive.Invoke ();
}
public void setCameraDirection ()
{
if (mainPlayerCamera.isUsingRegularGravity ()) {
mainPlayerCamera.transform.eulerAngles = (mainPlayerCamera.transform.up * mainTransform.eulerAngles.y);
} else {
float angleToRotate = Vector3.SignedAngle (mainPlayerCamera.transform.forward, mainTransform.forward, mainPlayerCamera.transform.up);
mainPlayerCamera.transform.Rotate (0, angleToRotate, 0);
}
Quaternion newCameraRotation = pivotTransform.localRotation;
mainPlayerCamera.getPivotCameraTransform ().localRotation = newCameraRotation;
float newLookAngleValue = newCameraRotation.eulerAngles.x;
if (newLookAngleValue > 180) {
newLookAngleValue -= 360;
}
mainPlayerCamera.setLookAngleValue (new Vector2 (0, newLookAngleValue));
}
public void inputTakePhoto ()
{
if (photoModeActive) {
takePhoto ();
}
}
public void inputToogleCameraRotation ()
{
if (photoModeActive) {
cameraRotationActive = !cameraRotationActive;
}
}
public void inputEnableOrDisablePhotoMode ()
{
enableOrDisablePhotoMode ();
}
public void inputSetTurboMode (bool state)
{
if (photoModeActive) {
if (canUseTurboEnabled) {
turboActive = state;
}
}
}
public void inputMoveCameraUp ()
{
movingCameraUp = true;
}
public void inputMoveCameraDown ()
{
movingCameraDown = true;
}
public void inputRotategCameraToRight ()
{
rotatingCameraToRight = true;
}
public void inputRotateCameraToLeft ()
{
rotatingCameraToLeft = true;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 6e57019b7baed8c4dba40c93a55fe075
timeCreated: 1576284117
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Camera/Camera Effect/photoModeSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,60 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class pixelCameraEffect : cameraEffect
{
public Shader mainShader;
public bool useEffectColor;
public Color effectColor = Color.white;
public string blockCountName = "BlockCount";
public string blockSizeName = "BlockSize";
public string colorName = "_TintColor";
[Range (64.0f, 1024.0f)] public float BlockCount = 128;
Material mainMaterial;
int blockCountID = -1;
int blockSizeID = -1;
int colorID = -1;
public override void renderEffect (RenderTexture source, RenderTexture destination, Camera mainCamera)
{
float k = mainCamera.aspect;
Vector2 count = new Vector2 (BlockCount, BlockCount / k);
Vector2 size = new Vector2 (1.0f / count.x, 1.0f / count.y);
setMaterial ();
if (blockCountID == -1) {
blockCountID = Shader.PropertyToID (blockCountName);
}
if (blockSizeID == -1) {
blockSizeID = Shader.PropertyToID (blockSizeName);
}
if (colorID == -1) {
colorID = Shader.PropertyToID (colorName);
}
mainMaterial.SetVector (blockCountID, count);
mainMaterial.SetVector (blockSizeID, size);
if (useEffectColor) {
mainMaterial.SetColor (colorID, effectColor);
}
Graphics.Blit (source, destination, mainMaterial);
}
public void setMaterial ()
{
if (mainMaterial == null) {
mainMaterial = new Material (mainShader);
mainMaterial.hideFlags = HideFlags.HideAndDontSave;
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 9756f6f9a410f1f458a706803dcbbeb6
timeCreated: 1576377887
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Camera/Camera Effect/pixelCameraEffect.cs
uploadId: 814740

View File

@@ -0,0 +1,78 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class solidCameraEffect : cameraEffect
{
public Shader mainShader;
public Color regularColor = Color.white;
public bool useEffectColor;
public Color effectColor = Color.white;
public Texture2D mainTexture;
public string blockCountName = "BlockCount";
public string blockSizeName = "BlockSize";
public string tintColorName = "_TintColor";
public string sprTexName = "_SprTex";
public string colorName = "_Color";
Material mainMaterial;
int blockCountID = -1;
int blockSizeID = -1;
int tintColorID = -1;
int sprTexID = -1;
int colorID = -1;
public override void renderEffect (RenderTexture source, RenderTexture destination, Camera mainCamera)
{
float w = mainCamera.pixelWidth;
float h = mainCamera.pixelHeight;
Vector2 count = new Vector2 (w / mainTexture.height, h / mainTexture.height);
Vector2 size = new Vector2 (1.0f / count.x, 1.0f / count.y);
setMaterial ();
if (blockCountID == -1) {
blockCountID = Shader.PropertyToID (blockCountName);
}
if (blockSizeID == -1) {
blockSizeID = Shader.PropertyToID (blockSizeName);
}
if (tintColorID == -1) {
tintColorID = Shader.PropertyToID (tintColorName);
}
if (sprTexID == -1) {
sprTexID = Shader.PropertyToID (sprTexName);
}
if (colorID == -1) {
colorID = Shader.PropertyToID (colorName);
}
mainMaterial.SetVector (blockCountID, count);
mainMaterial.SetVector (blockSizeID, size);
mainMaterial.SetColor (colorID, regularColor);
mainMaterial.SetTexture (sprTexID, mainTexture);
if (useEffectColor) {
mainMaterial.SetColor (tintColorID, effectColor);
}
Graphics.Blit (source, destination, mainMaterial);
}
public void setMaterial ()
{
if (mainMaterial == null) {
mainMaterial = new Material (mainShader);
mainMaterial.hideFlags = HideFlags.HideAndDontSave;
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 5b99c8075436e0046bb43ed1da435316
timeCreated: 1576379118
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Camera/Camera Effect/solidCameraEffect.cs
uploadId: 814740