void Start() { rends = gameObject.GetComponentsInChildren <Renderer>(); // Retrieve the one and only instance of PaintableTexture (singleton pattern) pt = PaintableTexture.Instance; // Paintable objects must all live in a layer called "Paintable" layerMask = (1 << LayerMask.NameToLayer("Paintable")); makeInvisible(); }
// ====================================================================================================================== // INITIALIZE ------------------------------------------------------------------- void Start() { // Main cam initialization --------------------------------------------------- mainC = Camera.main; if (mainC == null) { mainC = this.GetComponent <Camera>(); } if (mainC == null) { mainC = GameObject.FindObjectOfType <Camera>(); } // Texture and Mat initalization --------------------------------------------- markedIlsandes = new RenderTexture(baseTexture.width, baseTexture.height, 0, RenderTextureFormat.R8); albedo = new PaintableTexture(Color.white, baseTexture.width, baseTexture.height, "_MainTex" , UVShader, meshToDraw, fixIlsandEdgesShader, markedIlsandes); metalic = new PaintableTexture(Color.white, baseTexture.width, baseTexture.height, "_MetallicGlossMap" , UVShader, meshToDraw, fixIlsandEdgesShader, markedIlsandes); smoothness = new PaintableTexture(Color.black, baseTexture.width, baseTexture.height, "_GlossMap" , UVShader, meshToDraw, fixIlsandEdgesShader, markedIlsandes); metalicGlossMapCombined = new RenderTexture(metalic.runTimeTexture.descriptor) { format = RenderTextureFormat.ARGB32, }; meshMaterial.SetTexture(albedo.id, albedo.runTimeTexture); meshMaterial.SetTexture(metalic.id, metalicGlossMapCombined); meshMaterial.EnableKeyword("_METALLICGLOSSMAP"); createMetalicGlossMap = new Material(combineMetalicSmoothnes); // Command buffer inialzation ------------------------------------------------ cb_markingIlsdands = new CommandBuffer(); cb_markingIlsdands.name = "markingIlsnads"; cb_markingIlsdands.SetRenderTarget(markedIlsandes); Material mIlsandMarker = new Material(ilsandMarkerShader); cb_markingIlsdands.DrawMesh(meshToDraw, Matrix4x4.identity, mIlsandMarker); mainC.AddCommandBuffer(CameraEvent.AfterDepthTexture, cb_markingIlsdands); albedo.SetActiveTexture(mainC); }
void Start() { pt = PaintableTexture.Instance; sb = stickHolder.GetComponent <StickBehavior>(); h2c = h2view.GetComponent <h2viewcontrol>(); stickInitQ = stickHolder.transform.localRotation; cameraInitQ = camera.transform.localRotation; surfaceInitQ = surface.transform.localRotation; Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; }
void Start() { pt = PaintableTexture.Instance; // Todo: replace below with singletons to avoid need for linking in the editor sb = stickHolder.GetComponent <StickBehavior>(); helpScreen = helpScreenParent.GetComponent <HelpScreen>(); h2c = h2view.GetComponent <h2viewcontrol>(); stickInitQ = stickHolder.transform.localRotation; cameraInitQ = camera.transform.localRotation; surfaceInitQ = surface.transform.localRotation; Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; }
private void Awake() { // Ensure single instance if (_instance != null && _instance != this) { Debug.LogError("Awake() called on a second PaintableTexture object. There must be only one PaintableTexture script in the scene. Removing: " + this.gameObject.name); Destroy(this.gameObject); } else { _instance = this; } // Actual initialization mainTexturePropertyID = Shader.PropertyToID("_MainTex"); paintUVPropertyID = Shader.PropertyToID("_PaintUV"); spotColorPropertyID = Shader.PropertyToID("_SpotColor"); spotSizePropertyID = Shader.PropertyToID("_SpotSize"); }
void Start() { // Exact spot of the tool platform. Will change when we change where the tool platform goes. respawn = new Vector3(-0.71f, 0.25f, -7.09f); rends = gameObject.GetComponentsInChildren <Renderer>(); // Retrieve the one and only instance of PaintableTexture (singleton pattern) pt = PaintableTexture.Instance; // Paintable objects must all live in a layer called "Paintable" layerMask = (1 << LayerMask.NameToLayer("Paintable")); // colorMask is to get the color from a single-colored material colorMask = (1 << LayerMask.NameToLayer("Color")); // textureColorMask is for getting a color from a texture textureColorMask = (1 << LayerMask.NameToLayer("TextureColor")); // invisibleMask is to set the alpha to 0 for a transparent collor invisibleMask = (1 << LayerMask.NameToLayer("Transparent")); // drillMask is to toggle the drill bool drillMask = (1 << LayerMask.NameToLayer("Drill")); if (maxDist < maxForward) { maxForward = maxDist; } // Find the beam object. It must have the "Beam" tag. foreach (Renderer r in rends) { if (r.gameObject.CompareTag("Beam")) { beamRenderer = r; beamRB = r.gameObject.GetComponent <Rigidbody>(); break; } } if (beamRenderer == null) { Debug.Log("StickBehavior did not find a beam object (wrong material set?)"); } makeInvisible(); makeInactive(); }
// ====================================================================================================================== // INITIALIZE ------------------------------------------------------------------- void Start() { Vector4 mwp = new Vector4(100, 100, 100, 100); Shader.SetGlobalVector("_Mouse", mwp); // Texture and Mat initalization --------------------------------------------- markedIlsandes = new RenderTexture(baseTexture.width, baseTexture.height, 0, RenderTextureFormat.R8); albedo = new PaintableTexture(Color.white, baseTexture.width, baseTexture.height, "_MainTex", UVShader, meshToDraw, fixIlsandEdgesShader, markedIlsandes); meshMaterial.SetTexture(albedo.id, albedo.runTimeTexture); // Command buffer inialzation ------------------------------------------------ cb_markingIlsdands = new CommandBuffer(); cb_markingIlsdands.name = "markingIlsnads"; cb_markingIlsdands.SetRenderTarget(markedIlsandes); Material mIlsandMarker = new Material(ilsandMarkerShader); cb_markingIlsdands.DrawMesh(meshToDraw, Matrix4x4.identity, mIlsandMarker); mainCamera.AddCommandBuffer(CameraEvent.AfterEverything, cb_markingIlsdands); albedo.SetActiveTexture(mainCamera); Shader.SetGlobalFloat("_BrushOpacity", 1); Shader.SetGlobalColor("_BrushColor", Color.red); Shader.SetGlobalFloat("_BrushSize", .13f); Shader.SetGlobalFloat("_BrushHardness", .1f); mainCamera.depthTextureMode = DepthTextureMode.Depth; albedo.UpdateShaderParameters(meshGameobject.transform.localToWorldMatrix); }