void Start() { currentTexture = 0; textures = new UnityEngine.RenderTexture[2]; Resize(); cameraRender = GetComponent<Camera>(); materialRender = GetComponentInChildren<Renderer>().material; cameraEffect = Camera.main; materialEffect = cameraEffect.GetComponentInChildren<Renderer>().material; UnityEngine.Shader.SetGlobalTexture("_SamplerRenderTarget", GetCurrentTexture()); NextTexture(); cameraRender.targetTexture = GetCurrentTexture(); materialEffect.mainTexture = GetCurrentTexture(); }
private void DrawCameraStage() { EditorGUILayout.LabelField("Camera", EditorStyles.boldLabel); EditorWindowTools.StartIndentedSection(); UnityEngine.Camera playerCamera = pcObject.GetComponentInChildren <UnityEngine.Camera>() ?? UnityEngine.Camera.main; SmoothCameraWithBumper smoothCamera = (playerCamera != null) ? playerCamera.GetComponent <SmoothCameraWithBumper>() : null; EditorGUILayout.BeginHorizontal(); bool useSmoothCamera = EditorGUILayout.Toggle((smoothCamera != null), GUILayout.Width(ToggleWidth)); EditorGUILayout.LabelField("Use Smooth Follow Camera", EditorStyles.boldLabel); EditorGUILayout.EndHorizontal(); if (useSmoothCamera) { if (playerCamera == null) { GameObject playerCameraObject = new GameObject("Player Camera"); playerCameraObject.transform.parent = pcObject.transform; playerCamera = playerCameraObject.AddComponent <UnityEngine.Camera>(); playerCamera.tag = "MainCamera"; } smoothCamera = playerCamera.GetComponentInChildren <SmoothCameraWithBumper>() ?? playerCamera.gameObject.AddComponent <SmoothCameraWithBumper>(); EditorWindowTools.StartIndentedSection(); if (smoothCamera.target == null) { EditorGUILayout.HelpBox("Specify the transform (usually the head) that the camera should follow.", MessageType.Info); } smoothCamera.target = EditorGUILayout.ObjectField("Target", smoothCamera.target, typeof(Transform), true) as Transform; EditorWindowTools.EndIndentedSection(); } else { DestroyImmediate(smoothCamera); } if (GUILayout.Button("Select Camera", GUILayout.Width(100))) { Selection.activeObject = playerCamera; } EditorWindowTools.EndIndentedSection(); DrawNavigationButtons(true, true, false); }
//private Texture2D stampTexture; //private Vector2 swipeAngle = Vector2.zero; //private Vector3 localUp = Vector3.up; //private Vector3 localLeft = Vector3.left; private void Start() { OriginalSlider = PaintSlider.sprite; OriginalSliderBar = PaintSliderBar.sprite; MainCamera = GameObject.FindObjectOfType<Camera>(); Renderer rend = MainCamera.GetComponentInChildren<Renderer>(); ModelTransform = rend.transform; ModelTexture = new Texture2D(GlobalSettings.TextureSize, GlobalSettings.TextureSize); Color[] colors = ModelTexture.GetPixels(); for (int i = 0; i < colors.Length; ++i) { colors[i] = Color.white; } ModelTexture.SetPixels(colors); ModelTexture.Apply(); rend.material.mainTexture = ModelTexture; Palette = GameObject.FindObjectOfType<ColorPalette>(); //PaintImage = PaintButton.targetGraphic as Image; //OriginalPaintSprite = PaintImage.sprite; //RotateImage = RotateButton.targetGraphic as Image; //OriginalRotate = RotateImage.sprite; //OffsetPoints = new List<Vector3>(); //OffsetPoints.Add(new Vector3(1, 0, 0)); //OffsetPoints.Add(new Vector3(-1, 0, 0)); //OffsetPoints.Add(new Vector3(0, 1, 0)); //OffsetPoints.Add(new Vector3(0, -1, 0)); PaintSliderControl.minValue = 1; PaintSliderControl.maxValue = IngameSettings.MaxBrushCount; PaintSliderControl.value = (IngameSettings.MaxBrushCount / 2); EraserSliderControl.minValue = 1; EraserSliderControl.maxValue = IngameSettings.MaxBrushCount; EraserSliderControl.value = (IngameSettings.MaxBrushCount / 2); ToggleEraser(false); TogglePaint(true); }
public void Awake() { // Get reference to Game Manager within the scene m_gameManager = FindObjectOfType<GameManager>(); // Get capture camera reference m_captureCamera = GetComponentInChildren<Camera>(); // Get capture canvas reference and ensure it's at 0,0,0 in local space m_captureCanvas = m_captureCamera.GetComponentInChildren<Canvas>(); m_captureCanvas.transform.localPosition = Vector3.zero; // Cache common properties m_transform = transform; }