void Start() { // Set target direction to the camera's initial orientation. targetDirection = transform.localRotation.eulerAngles; // Set target direction for the character body to its inital state. if (characterBody) { targetCharacterDirection = characterBody.transform.localRotation.eulerAngles; } _background = GameObject.FindGameObjectWithTag("Background").GetComponent <UnityEngine.UIElements.Background>(); }
private bool SetStyleValue(StylePropertyId id, StyleBackground inlineValue, Background sharedValue) { var sv = new StyleValue(); if (TryGetStyleValue(id, ref sv)) { var vectorImage = sv.resource.IsAllocated ? sv.resource.Target as VectorImage : null; var sprite = sv.resource.IsAllocated ? sv.resource.Target as Sprite : null; var texture = sv.resource.IsAllocated ? sv.resource.Target as Texture2D : null; var renderTexture = sv.resource.IsAllocated ? sv.resource.Target as RenderTexture : null; if ((vectorImage == inlineValue.value.vectorImage && texture == inlineValue.value.texture && sprite == inlineValue.value.sprite && renderTexture == inlineValue.value.renderTexture) && sv.keyword == inlineValue.keyword) { return(false); } if (sv.resource.IsAllocated) { sv.resource.Free(); } } else if (inlineValue.keyword == StyleKeyword.Null) { return(false); } sv.id = id; sv.keyword = inlineValue.keyword; if (inlineValue.value.vectorImage != null) { sv.resource = GCHandle.Alloc(inlineValue.value.vectorImage); } else if (inlineValue.value.sprite != null) { sv.resource = GCHandle.Alloc(inlineValue.value.sprite); } else if (inlineValue.value.texture != null) { sv.resource = GCHandle.Alloc(inlineValue.value.texture); } else if (inlineValue.value.renderTexture != null) { sv.resource = GCHandle.Alloc(inlineValue.value.renderTexture); } else { sv.resource = new GCHandle(); } SetStyleValue(sv); if (inlineValue.keyword == StyleKeyword.Null) { if (sharedValue.texture != null) { sv.resource = GCHandle.Alloc(sharedValue.texture); } else if (sharedValue.sprite != null) { sv.resource = GCHandle.Alloc(sharedValue.sprite); } else if (sharedValue.renderTexture != null) { sv.resource = GCHandle.Alloc(sharedValue.renderTexture); } else if (sharedValue.vectorImage != null) { sv.resource = GCHandle.Alloc(sharedValue.vectorImage); } else { sv.resource = new GCHandle(); } } ApplyStyleValue(sv); return(true); }