private void OnEnable() { _target = (MaterialFadable)target; _alphaOnly = serializedObject.FindProperty(nameof(_target.AlphaOnly)); _invertAlpha = serializedObject.FindProperty(nameof(_target.InvertAlpha)); _invertPercentage = serializedObject.FindProperty(nameof(_target.InvertPercentage)); _useRenderer = serializedObject.FindProperty(nameof(_target.UseRenderer)); _targetRenderer = serializedObject.FindProperty(nameof(_target.TargetRenderer)); _targetMaterial = serializedObject.FindProperty(nameof(_target.TargetMaterial)); _overrideColourProperty = serializedObject.FindProperty(nameof(_target.OverrideColourProperty)); _colourProperty = serializedObject.FindProperty(nameof(_target.ColourProperty)); }
public static void AddComponentToScene() { Renderer _renderer = UnityEditor.Selection.activeGameObject?.GetComponent <Renderer>(); if (_renderer != null) { MaterialFadable fadable = _renderer.gameObject.AddComponent <MaterialFadable>(); fadable.TargetRenderer = _renderer; return; } GameObject _gameObject = new GameObject("Material Fadable", typeof(MaterialFadable)); if (UnityEditor.Selection.activeTransform != null) { _gameObject.transform.SetParent(UnityEditor.Selection.activeTransform); } UnityEditor.Selection.activeGameObject = _gameObject; }
private void OnEnable() { _target = (MaterialFadable)target; }