// Use this for initialization void Start() { //add listener to change background color based on color picker picker.SetOnValueChangeCallback((color) => { changeBGColor(color); }); }
// Start is called before the first frame update void Start() { previewCamCtrlr = FindObjectOfType <CinemachineVirtualCamera>(); if (previewCamCtrlr == null) { Debug.Log("Preview Cam Controller not found by " + this.name + "!"); } objectTitle = transform.Find("TitleObj").GetComponent <Text>(); if (!objectTitle) { Debug.LogError("Context Menu's 'TitleObj' not found!"); } inptPosX = transform.Find("txtPosX/inptPosX").GetComponent <InputField>(); if (!inptPosX) { Debug.LogError("Context Menu's 'inptPosX' not found!"); } inptPosY = transform.Find("txtPosY/inptPosY").GetComponent <InputField>(); if (!inptPosY) { Debug.LogError("Context Menu's 'inptPosY' not found!"); } inptPosZ = transform.Find("txtPosZ/inptPosZ").GetComponent <InputField>(); if (!inptPosZ) { Debug.LogError("Context Menu's 'inptPosZ' not found!"); } inptMassVal = transform.Find("txtMass/inptMassVal").GetComponent <InputField>(); if (!inptMassVal) { Debug.LogError("Context Menu's 'inptMassVal' not found!"); } inptRadiusVal = transform.Find("txtRadius/inptRadiusVal").GetComponent <InputField>(); if (!inptRadiusVal) { Debug.LogError("Context Menu's 'inptRadiusVal' not found!"); } inptDensityVal = transform.Find("txtDensity/inptDensityVal").GetComponent <InputField>(); if (!inptDensityVal) { Debug.LogError("Context Menu's 'inptDensityVal' not found!"); } canvas = FindObjectOfType <Canvas>(); orbitControls = GameObject.FindObjectOfType <OrbitControls>(); lineRenderer = GetComponent <LineRenderer>(); colourPicker = FindObjectOfType <CUIColorPicker>(); colourPicker.SetOnValueChangeCallback(SetTrailColour); }
void Awake() { _cachedTransform = transform; readOnly = false; _textureColorStorage = TextureColorStorage.instance; _renderer = GetComponent <MeshRenderer>(); _filter = GetComponent <MeshFilter>(); // register colorPicker value change event if (colorPicker != null) { colorPicker.Color = Color.white; colorPicker.SetOnValueChangeCallback(c => { paintColor = c; }); } // init mesh filter of Quad var quadGo = GameObject.CreatePrimitive(PrimitiveType.Quad); _filter.mesh = quadGo.GetComponent <MeshFilter>().mesh; Destroy(quadGo.gameObject); // init paint color // var initColor = Color.white; paintColor = colorPicker == null ? Color.white : colorPicker.Color; paintColor.a = 1; CreateTexture(); // create instance of texture // _texture = new Texture2D(textureWidth, textureHeight, TextureFormat.RGBA32, true); // _colors = new Color[textureWidth * textureHeight]; // for(var x = 0; x < _texture.width; x++){ // for(var y = 0; y < _texture.height; y++){ // //var initColor = Color.white; //(x & y) != 0 ? Color.white : Color.grey; // _colors[x + y * _texture.width] = initColor; // } // } // _texture.SetPixels(_colors); // _texture.Apply(); // _texture.wrapMode = TextureWrapMode.Clamp; // _texture.filterMode = FilterMode.Point; // assign into material renderer's texture // var mainMaterial = _renderer.materials[0]; // mainMaterial.mainTexture = _texture; // mainMaterial.shader = Shader.Find("Sprites/Default"); // start drag event; StartCoroutine(Dragging()); }