public void Setup() {

			this.particleSystem = this.GetComponent<ParticleSystem>();
			if (this.particleSystem != null) {

				//var alpha = this.lastAlpha;
				//this.SetStartAlpha(1f);

				var obj = new UnityEditor.SerializedObject(this.particleSystem);
				var module = obj.FindProperty("InitialModule").FindPropertyRelative("startColor");

				var minColor = module.FindPropertyRelative("minColor");
				var maxColor = module.FindPropertyRelative("maxColor");
				var minGradient = module.FindPropertyRelative("minGradient");
				var maxGradient = module.FindPropertyRelative("maxGradient");
				var minMaxState = module.FindPropertyRelative("minMaxState");
				this.startColor.minColor = minColor.colorValue;
				this.startColor.maxColor = maxColor.colorValue;
				this.startColor.minGradient = minGradient.GetGradient();
				this.startColor.maxGradient = maxGradient.GetGradient();
				this.startColor.minMaxState = (MinMaxState)minMaxState.intValue;

				//if (alpha >= 0f) this.SetStartAlpha(alpha);

			}

		}
        public static void SetInputManager()
        {
            #if UNITY_EDITOR
            UnityEditor.SerializedObject inputManagerSerialized = new UnityEditor.SerializedObject(UnityEditor.AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/InputManager.asset"));
            UnityEditor.SerializedProperty axesProperty = inputManagerSerialized.FindProperty("m_Axes");

            foreach (Joysticks joystick in System.Enum.GetValues(typeof(Joysticks))) {
                foreach (JoystickAxes joystickAxis in System.Enum.GetValues(typeof(JoystickAxes))) {
                    string axis = joystick.ToString() + joystickAxis;

                    UnityEditor.SerializedProperty currentAxisProperty = axesProperty.Find(property => property.FindPropertyRelative("m_Name").GetValue<string>() == axis);

                    if (currentAxisProperty == null) {
                        axesProperty.arraySize += 1;

                        currentAxisProperty = axesProperty.Last();
                        currentAxisProperty.FindPropertyRelative("m_Name").SetValue(axis);
                        currentAxisProperty.FindPropertyRelative("dead").SetValue(0.19F);
                        currentAxisProperty.FindPropertyRelative("sensitivity").SetValue(1F);
                        currentAxisProperty.FindPropertyRelative("invert").SetValue(joystickAxis == JoystickAxes.LeftStickY || joystickAxis == JoystickAxes.RightStickY);
                        currentAxisProperty.FindPropertyRelative("type").SetValue(2);
                        currentAxisProperty.FindPropertyRelative("axis").SetValue((joystickAxis == JoystickAxes.LeftTrigger || joystickAxis == JoystickAxes.RightTrigger) ? 2 : (int)joystickAxis);
                        currentAxisProperty.FindPropertyRelative("joyNum").SetValue((int)joystick);
                    }
                }
            }

            inputManagerSerialized.ApplyModifiedProperties();
            #endif
        }
		public void RepaintInspector() {
			#if UNITY_EDITOR
			UnityEditor.SerializedObject poolSerialized = new UnityEditor.SerializedObject(pool);
			UnityEditor.SerializedProperty repaintDummyProperty = poolSerialized.FindProperty("editorHelper").FindPropertyRelative("repaintDummy");
			repaintDummyProperty.SetValue(!repaintDummy);
			#endif
		}
示例#4
0
        public static int GetOrCreateByName(string layerName)
        {
            int layer = LayerMask.NameToLayer(layerName);
            if (layer == -1)
            {
            #if UNITY_EDITOR && UNITY_5
                if (string.IsNullOrEmpty(layerName))
                {
                    throw new ArgumentException("null or empty", "layerName");
                }

                // note: if Unity changes its serialization this method breaks
                // tested using "serializedVersion: 2" in Unity 5.1
                const string TagManagerAssetPath = "ProjectSettings/TagManager.asset";
                var tagManager = new UnityEditor.SerializedObject(UnityEditor.AssetDatabase.LoadAllAssetsAtPath(TagManagerAssetPath)[0]);
                var prop = tagManager.GetIterator();
                var success = false;
                while (!success && prop.NextVisible(true))
                {
                    if (prop.isArray && prop.name == "layers")
                    {
                        // skip the first 8 layers (built-in)
                        for (int i = 8; i < 32; ++i)
                        {
                            var layerProp = prop.GetArrayElementAtIndex(i);
                            if (string.IsNullOrEmpty(layerProp.stringValue))
                            {
                                layerProp.stringValue = layerName;
                                success = true;
                                break;
                            }
                        }
                        break;
                    }
                }
                if (success &&
                    tagManager.ApplyModifiedProperties() &&
                    (-1 != (layer = LayerMask.NameToLayer(layerName))))
                {
                    Debug.Log("Created layer \"" + layerName + "\" at index " + layer);
                }
                else
                {
                    Debug.LogError("No more layers available. Could not create layer named \"" + layerName + "\".");
                }
            #else
                Debug.LogError("Could not find layer named: " + layerName);
            #endif
            }
            return layer;
        }
示例#5
0
 public static void ExposeLogLevel(UnityEditor.SerializedObject obj, ILoggable loggable)
 {
     UnityEditor.SerializedProperty logLevelSp = obj.FindProperty("logLevel");
     UnityEditor.EditorGUI.BeginChangeCheck();
     UnityEditor.EditorGUILayout.PropertyField(logLevelSp, new GUIContent("Log Level", "Logging level for this Photon Voice component."));
     if (UnityEditor.EditorGUI.EndChangeCheck())
     {
         if (logLevelSp.enumValueIndex == 4)
         {
             loggable.LogLevel = DebugLevel.ALL;
         }
         else
         {
             loggable.LogLevel = (DebugLevel)logLevelSp.enumValueIndex;
         }
         obj.ApplyModifiedProperties();
     }
 }
示例#6
0
 public static void ExposeLogLevel(UnityEditor.SerializedObject obj, ILoggableDependent loggable)
 {
     UnityEditor.SerializedProperty logLevelSp = obj.FindProperty("logLevel");
     UnityEditor.EditorGUI.BeginChangeCheck();
     UnityEditor.EditorGUILayout.BeginHorizontal();
     loggable.IgnoreGlobalLogLevel = UnityEditor.EditorGUILayout.Toggle(new GUIContent("Override Default Log Level", "Override the default logging level for this type of component."), loggable.IgnoreGlobalLogLevel);
     if (loggable.IgnoreGlobalLogLevel)
     {
         UnityEditor.EditorGUILayout.PropertyField(logLevelSp, new GUIContent("Log Level", "Logging level for this Photon Voice component."));
     }
     UnityEditor.EditorGUILayout.EndHorizontal();
     if (UnityEditor.EditorGUI.EndChangeCheck())
     {
         ExposeLogLevel(logLevelSp);
         loggable.LogLevel = (DebugLevel)logLevelSp.enumValueIndex;
         obj.ApplyModifiedProperties();
     }
 }
示例#7
0
		public virtual void CheckTextureImporter( bool additionalCheck )
		{
			m_requireMaterialUpdate = true:
			Texture2DArray texture = m_materialMode ? m_materialTextureArray : m_defaultTextureArray:

			UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath( AssetDatabase.GetAssetPath( texture ), typeof( UnityEngine.Object ) ):

			if( obj != null )
			{
				SerializedObject serializedObject = new UnityEditor.SerializedObject( obj ):

				if( serializedObject != null )
				{
					SerializedProperty colorSpace = serializedObject.FindProperty( "m_ColorSpace" ):
					m_linearTexture = ( colorSpace.intValue == 0 ):
				}
			}
		}
        protected override void OnEnable()
        {
            base.OnEnable();

            // Set DataType for reset behaviour
            _dataType = GetDataType(typeof(TData));

                        #if UNITY_EDITOR
            // Ensure serialization
            var so = new UnityEditor.SerializedObject(this);
            so.FindProperty("_dataType").intValue = (int)_dataType;
            so.ApplyModifiedPropertiesWithoutUndo();
                        #endif

            UnityEngine.SceneManagement.SceneManager.activeSceneChanged += OnSceneChanged;

            Restore();
        }
        public static T Clone <T>(this T scriptable) where T : ScriptableObject
        {
            T clone = default(T);

                        #if UNITY_EDITOR
            clone = ScriptableObject.CreateInstance <T>();
            UnityEditor.SerializedObject   cloneSerialized      = new UnityEditor.SerializedObject(clone);
            UnityEditor.SerializedObject   scriptableSerialized = new UnityEditor.SerializedObject(scriptable);
            UnityEditor.SerializedProperty scriptableIterator   = scriptableSerialized.GetIterator();

            while (scriptableIterator.NextVisible(true))
            {
                cloneSerialized.FindProperty(scriptableIterator.propertyPath).SetValue(scriptableIterator.GetValue());
            }
                        #endif

            return(clone);
        }
示例#10
0
        /************************************************************************************************************************/

        private void RefreshSerializedAnimator() //刷新序列化的动画控制器
        {
            var targets = this.targets;

            if (_Animators == null || _Animators.Length != targets.Length)
            {
                _Animators = new Animator[targets.Length];
            }

            var dirty  = false;
            var hasAll = true;

            for (int i = 0; i < _Animators.Length; i++)
            {
                var animator = (targets[i] as SoloAnimation).Animator;
                if (_Animators[i] != animator)
                {
                    _Animators[i] = animator;
                    dirty         = true;
                }

                if (animator == null)
                {
                    hasAll = false;
                }
            }

            if (!dirty)
            {
                return;
            }

            OnDisable();

            if (!hasAll)
            {
                return;
            }

            _SerializedAnimator = new UnityEditor.SerializedObject(_Animators);
#if UNITY_2018_1_OR_NEWER
            _KeepStateOnDisable = _SerializedAnimator.FindProperty("m_KeepAnimatorControllerStateOnDisable");
#endif
        }
示例#11
0
        public void AwakeMe()
        {
            lodDistance = 0.2f;
            if (gameObject.activeInHierarchy)
            {
                if (rooftopElements.Length == 0)
                {
                    System.Array.Resize(ref rooftopElements, rooftopElements.Length + 1);
                }
                bmComponent = gameObject.GetComponent <BuildingModifier>();
                if (rooftopHolder == null)
                {
                    rooftopHolder = new GameObject(gameObject.transform.name + "_rooftop");
#if UNITY_EDITOR
                    if (rooftopHolder.GetComponent <LODGroup>() == null)
                    {
                        lodComponent = rooftopHolder.AddComponent <LODGroup>();
                        UnityEditor.SerializedObject obj = new UnityEditor.SerializedObject(lodComponent);

                        UnityEditor.SerializedProperty valArrProp = obj.FindProperty("m_LODs.Array");
                        for (int i = 0; valArrProp.arraySize > i; i++)
                        {
                            UnityEditor.SerializedProperty sHeight = obj.FindProperty("m_LODs.Array.data[" + i.ToString() + "].screenRelativeHeight");

                            if (i == 0)
                            {
                                sHeight.doubleValue = 0.8;
                            }
                            if (i == 1)
                            {
                                sHeight.doubleValue = 0.5;
                            }
                            if (i == 2)
                            {
                                sHeight.doubleValue = 0.1;
                            }
                        }
                        obj.ApplyModifiedProperties();
                    }
#endif
                }
                UpdateElements();
            }
        }
        public static Hash128 GetHash(this Texture2D tex)
        {
            //#if UNITY_2017_3_OR_NEWER
            //return tex.imageContentsHash;
            //#else

                                        #if UNITY_EDITOR
            UnityEditor.SerializedProperty property = new UnityEditor.SerializedObject(tex).FindProperty("m_ImageContentsHash");

            //by Broxxar
            //https://answers.unity.com/questions/1249181/how-to-get-texture-image-contents-hash-property.html

            if (property.type != "Hash128")
            {
                throw new Exception("SerializedProperty does not represent a Hash128 struct.");
            }

            var bytes = new byte[4][];

            for (var i = 0; i < 4; i++)
            {
                bytes[i] = new byte[4];

                for (var j = 0; j < 4; j++)
                {
                    property.Next(true);
                    bytes[i][j] = (byte)property.intValue;
                }
            }

            var hash = new Hash128(
                BitConverter.ToUInt32(bytes[0], 0),
                BitConverter.ToUInt32(bytes[1], 0),
                BitConverter.ToUInt32(bytes[2], 0),
                BitConverter.ToUInt32(bytes[3], 0));

            return(hash);
                                        #else
            return(new Hash128());
                                        #endif

            //#endif
        }
示例#13
0
        public static State AddState(StateMachine machine, StateLayer layer, State state)
        {
            state.hideFlags = HideFlags.HideInInspector;

            UnityEditor.SerializedObject   layerSerialized = new UnityEditor.SerializedObject(layer);
            UnityEditor.SerializedObject   stateSerialized = new UnityEditor.SerializedObject(state);
            UnityEditor.SerializedProperty statesProperty  = layerSerialized.FindProperty("stateReferences");

            stateSerialized.FindProperty("layerReference").SetValue(layer);
            stateSerialized.FindProperty("machineReference").SetValue(machine);
            stateSerialized.ApplyModifiedProperties();

            if (!statesProperty.Contains(state))
            {
                statesProperty.Add(state);
            }

            return(state);
        }
        /// <summary>
        /// Called when the inspector needs to draw
        /// </summary>
        public override bool OnInspectorGUI(UnityEditor.SerializedObject rTargetSO, UnityEngine.Object rTarget)
        {
            _EditorShowActivationType = false;
            bool lIsDirty = base.OnInspectorGUI(rTargetSO, rTarget);

            if (EditorHelper.TextField("Health ID", "Attribute identifier that represents the health attribute", HealthID, rTarget))
            {
                lIsDirty = true;
                HealthID = EditorHelper.FieldStringValue;
            }

            if (EditorHelper.TextField("Damaged Motion", "Name of motion to activate when damage occurs and the message isn't handled.", DamagedMotion, rTarget))
            {
                lIsDirty      = true;
                DamagedMotion = EditorHelper.FieldStringValue;
            }

            return(lIsDirty);
        }
示例#15
0
        /// <summary>
        /// Called when the inspector needs to draw
        /// </summary>
        public override bool OnInspectorGUI(UnityEditor.SerializedObject rTargetSO, UnityEngine.Object rTarget)
        {
            _EditorShowActivationType = false;
            bool lIsDirty = base.OnInspectorGUI(rTargetSO, rTarget);

            if (EditorHelper.TextField("Root Motion Tag", "When a motion with this tag is activated, we will disable Use Transform.", RootMotionTag, rTarget))
            {
                lIsDirty      = true;
                RootMotionTag = EditorHelper.FieldStringValue;
            }

            if (EditorHelper.BoolField("Manage NavMesh Agent", "Set NavMeshAgent.isStopped when enabling or disabling Use Transform.", ManageNavMeshAgent, rTarget))
            {
                lIsDirty           = true;
                ManageNavMeshAgent = EditorHelper.FieldBoolValue;
            }

            return(lIsDirty);
        }
        /// <summary>
        /// Called when the inspector needs to draw
        /// </summary>
        public override bool OnInspectorGUI(UnityEditor.SerializedObject rTargetSO, UnityEngine.Object rTarget)
        {
            _EditorShowActivationType = false;
            bool lIsDirty = base.OnInspectorGUI(rTargetSO, rTarget);

            if (EditorHelper.TextField("Right Hand Pose Name", "The name of the BasicHandPose motion for the right hand.", RightHandPoseName, rTarget))
            {
                lIsDirty          = true;
                RightHandPoseName = EditorHelper.FieldStringValue;
            }

            if (EditorHelper.TextField("Left Hand Pose Name", "The name of the BasicHandPose motion for the left hand.", LeftHandPoseName, rTarget))
            {
                lIsDirty         = true;
                LeftHandPoseName = EditorHelper.FieldStringValue;
            }

            return(lIsDirty);
        }
示例#17
0
        void migrateToFixedPixelsPerUnit()
        {
            var so            = new UnityEditor.SerializedObject(this);
            var scriptProp    = so.FindProperty("m_Script");
            var newScriptPath =
                UnityEditor.AssetDatabase.GetAllAssetPaths()
                .Where(path => path.EndsWithFast($"{nameof(CustomImage)}.cs"))
                .ElementAt(0);
            var newScript = UnityEditor.AssetDatabase.LoadMainAssetAtPath(newScriptPath);

            scriptProp.objectReferenceValue = newScript;

            var scaleFix = activeSprite.pixelsPerUnit / referencePPU;
            var spritePixelsPerUnitProp = so.FindProperty(nameof(spritePixelsPerUnit));

            spritePixelsPerUnitProp.floatValue = spritePixelsPerUnit /= scaleFix;

            so.ApplyModifiedProperties();
        }
        public static string[] GetKeyboardAxes()
        {
            List<string> axes = new List<string>();

            #if UNITY_EDITOR
            UnityEditor.SerializedObject inputManagerSerialized = new UnityEditor.SerializedObject(UnityEditor.AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/InputManager.asset"));
            UnityEditor.SerializedProperty inputManagerAxesProperty = inputManagerSerialized.FindProperty("m_Axes");

            for (int i = 0; i < inputManagerAxesProperty.arraySize; i++) {
                string axisName = inputManagerAxesProperty.GetArrayElementAtIndex(i).FindPropertyRelative("m_Name").GetValue<string>();

                if (!axisName.StartsWith("Any") && !axisName.StartsWith("Joystick") && !axes.Contains(axisName)) {
                    axes.Add(axisName);
                }
            }
            #endif

            return axes.ToArray();
        }
示例#19
0
    public void Init(UnityEditor.SerializedObject in_serializedObject, string in_listName = "triggerList",
                     string in_label = "Trigger On: ", bool in_showUseOtherToggle = true)
    {
        m_label = in_label;
        m_showUseOtherToggle = in_showUseOtherToggle;

        m_triggerList    = in_serializedObject.FindProperty(in_listName);
        m_useOtherObject = in_serializedObject.FindProperty("useOtherObject");

        //Get the updated list of all triggers
        if (m_triggerTypes == null)
        {
            m_triggerTypes     = AkTriggerBase.GetAllDerivedTypes();
            m_triggerTypeNames = new string[m_triggerTypes.Count];
            m_triggerTypes.Values.CopyTo(m_triggerTypeNames, 0);
            m_triggerTypeIDs = new uint[m_triggerTypes.Count];
            m_triggerTypes.Keys.CopyTo(m_triggerTypeIDs, 0);
        }
    }
示例#20
0
        public static void AddProjector(ProjectorForLWRP projector, Camera camera)
        {
#if UNITY_EDITOR
            // check if the current Forward Renderer has the ProjectorRendererFeature instance.
            LightweightRenderPipelineAsset renderPipelineAsset = UnityEngine.Rendering.LWRP.LightweightRenderPipeline.asset;
            if (renderPipelineAsset == null)
            {
                return;
            }
            UnityEditor.SerializedObject   serializedObject                = new UnityEditor.SerializedObject(renderPipelineAsset);
            UnityEditor.SerializedProperty rendererDataProperty            = serializedObject.FindProperty("m_RendererData");
            UnityEngine.Rendering.LWRP.ScriptableRendererData rendererData = rendererDataProperty.objectReferenceValue as UnityEngine.Rendering.LWRP.ScriptableRendererData;
            if (rendererData == null)
            {
                Debug.LogError("The current Lightweight Render Pipeline Asset does not have Forward Renderer Data! Please set a Forward Renderer Data which contains ProjectorRendererFeature to the current render pipeline asset.", renderPipelineAsset);
            }
            else
            {
                bool found = false;
                foreach (var rendererFeature in rendererData.rendererFeatures)
                {
                    if (rendererFeature is ProjectorRendererFeature)
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    Debug.LogError("ProjectorRendererFeature is not added to the current Forward Renderer Data.", rendererData);
                }
            }
#endif
            if (s_projectorPasses == null)
            {
#if UNITY_EDITOR
                Debug.LogError("No ProjectorRendererFeature instances are created!");
#endif
                return;
            }
            AddProjectorInternal(projector, camera);
        }
示例#21
0
        public static void ManageLayer()
        {
            var layer = LayerMask.NameToLayer("UIModuleModelObject");

            if (layer != -1)
            {
                return;
            }

            var tagManager = new UnityEditor.SerializedObject(UnityEditor.AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset"));
            var layers     = tagManager.FindProperty("layers");

            if (layers == null || !layers.isArray)
            {
                Debug.LogWarning("[Warning] Unable to set up layers.");
                return;
            }

            bool set = false;

            for (var i = 8; i < layers.arraySize; i++)
            {
                var element = layers.GetArrayElementAtIndex(i);

                if (element.stringValue == "")
                {
                    element.stringValue = "UIModuleModelObject";
                    set = true;
                    break;
                }
            }

            if (set)
            {
                Debug.Log("Layer 'UIModuleModelObject' created.");
                tagManager.ApplyModifiedProperties();
            }
            else
            {
                Debug.LogWarning("[Warning] Unable to create Layer 'UIModuleModelObject'.");
            }
        }
示例#22
0
        // Hardware Config
        public void CreateHardwarePlayer(Type hardwarePlayerClass)
        {
            // Destroy existing hardware player if needed
            DestroyHardwarePlayer();

            if (!hardwarePlayerClass.IsSubclassOf(typeof(Hardware.HardwarePlayer)))
            {
                UnityEditor.EditorUtility.DisplayDialog("Error", "Attempting to configure Hardware using class that doesn't derive from Normal.Hardware.HardwarePlayer. Bailing.", "OK");
                return;
            }

            // Get SerializedProperty objects
            UnityEditor.SerializedObject serializedObject = GetSerializedObject();
            serializedObject.Update();
            UnityEditor.SerializedProperty hardwarePlayerProperty           = serializedObject.FindProperty("_hardwarePlayer");
            UnityEditor.SerializedProperty hardwarePlayerGameObjectProperty = serializedObject.FindProperty("_hardwarePlayerGameObject");

            // Create hardware player game object if it doesn't exist yet.
            if (_hardwarePlayerGameObject == null)
            {
                _hardwarePlayerGameObject = new GameObject("Player (Hardware)");
                _hardwarePlayerGameObject.transform.SetParent(transform, false);
                hardwarePlayerGameObjectProperty.objectReferenceValue = _hardwarePlayerGameObject;
            }

            // If there's an existing hardware player component, enable it. Otherwise create it.
            _hardwarePlayer = (Hardware.HardwarePlayer)_hardwarePlayerGameObject.GetComponent(hardwarePlayerClass);
            if (_hardwarePlayer != null)
            {
                _hardwarePlayer.enabled = true;
                _hardwarePlayer.EnableDependencies();
            }
            else
            {
                _hardwarePlayer = (Hardware.HardwarePlayer)_hardwarePlayerGameObject.AddComponent(hardwarePlayerClass);
                _hardwarePlayer.CreateDependencies();
            }
            hardwarePlayerProperty.objectReferenceValue = _hardwarePlayer;

            // Apply Changes
            serializedObject.ApplyModifiedPropertiesWithoutUndo();
        }
示例#23
0
        public static void CopyState(State state, State stateToCopy)
        {
#if UNITY_EDITOR
            if (stateToCopy == null)
            {
                return;
            }

            var stateSerialized  = new UnityEditor.SerializedObject(state);
            var parentReference  = stateSerialized.FindProperty("layerReference").GetValue <UnityEngine.Object>();
            var machineReference = stateSerialized.FindProperty("machineReference").GetValue <UnityEngine.Object>();

            UnityEditorInternal.ComponentUtility.CopyComponent(stateToCopy);
            UnityEditorInternal.ComponentUtility.PasteComponentValues(state);

            stateSerialized = new UnityEditor.SerializedObject(state);
            stateSerialized.FindProperty("layerReference").SetValue(parentReference);
            stateSerialized.FindProperty("machineReference").SetValue(machineReference);
#endif
        }
            public SPEditorAddonDrawer CreateDrawer(UnityEditor.SerializedObject target)
            {
                if (target.isEditingMultipleObjects && !this.SupportsMultiObject)
                {
                    return(null);
                }

                try
                {
                    var drawer = Activator.CreateInstance(DrawerType) as SPEditorAddonDrawer;
                    drawer._serializedObject = target;
                    drawer._isFooter         = this.IsFooter;
                    drawer.OnEnable();
                    return(drawer);
                }
                catch
                {
                    return(null);
                }
            }
        private static bool IsLightweightRenderPipelineSetupCorrectly()
        {
            if (s_pipelineSetupOk)
            {
                return(true);
            }
            // check if the current Forward Renderer has the ProjectorRendererFeature instance.
            LightweightRenderPipelineAsset renderPipelineAsset = LightweightRenderPipeline.asset;

            if (renderPipelineAsset == null)
            {
                return(false);
            }
            UnityEditor.SerializedObject   serializedObject     = new UnityEditor.SerializedObject(renderPipelineAsset);
            UnityEditor.SerializedProperty rendererDataProperty = serializedObject.FindProperty("m_RendererData");
            ScriptableRendererData         rendererData         = rendererDataProperty.objectReferenceValue as ScriptableRendererData;

            if (rendererData == null)
            {
                Debug.LogError("The current Lightweight Render Pipeline Asset does not have Forward Renderer Data! Please set a Forward Renderer Data which contains ProjectorRendererFeature to the current render pipeline asset.", renderPipelineAsset);
            }
            else
            {
                bool found = false;
                foreach (var rendererFeature in rendererData.rendererFeatures)
                {
                    if (rendererFeature is ProjectorRendererFeature)
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    Debug.LogError("ProjectorRendererFeature is not added to the current Forward Renderer Data.", rendererData);
                    return(false);
                }
            }
            s_pipelineSetupOk = true;
            return(true);
        }
示例#26
0
        public static void IfMultiComponentThenChangeType <T>(T currentComponent) where T : MonoBehaviour
        {
#if UNITY_EDITOR
            if (UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode)
            {
                return;
            }

            // If there is already another instance of this component on the same object, delete this new instance and
            // change the original's type to match this one.
            var components = currentComponent.GetComponents <T>();
            if (components.Length > 1)
            {
                var oldComponent = components[0];
                var newComponent = components[1];

                if (oldComponent.GetType() != newComponent.GetType())
                {
                    // All we have to do is change the Script field to the new type and Unity will immediately deserialize
                    // the existing data as that type, so any fields shared between both types will keep their data.

                    using (var serializedObject = new UnityEditor.SerializedObject(oldComponent))
                    {
                        var scriptProperty = serializedObject.FindProperty("m_Script");
                        scriptProperty.objectReferenceValue = UnityEditor.MonoScript.FromMonoBehaviour(newComponent);
                        serializedObject.ApplyModifiedProperties();
                    }
                }

                // Destroy all components other than the first (the oldest).
                UnityEditor.EditorApplication.delayCall += () =>
                {
                    var i = 1;
                    for (; i < components.Length; i++)
                    {
                        Object.DestroyImmediate(components[i], true);
                    }
                };
            }
#endif
        }
示例#27
0
#pragma warning restore 0414 // private field assigned but not used.

#if UNITY_EDITOR
    bool AK.Wwise.IMigratable.Migrate(UnityEditor.SerializedObject obj)
    {
        if (!AkUtilities.IsMigrationRequired(AkUtilities.MigrationStep.WwiseTypes_v2018_1_6))
        {
            return(false);
        }

        var hasMigrated = AK.Wwise.TypeMigration.ProcessSingleGuidType(obj.FindProperty("data.WwiseObjectReference"), WwiseObjectType.Event,
                                                                       obj.FindProperty("valueGuidInternal"), obj.FindProperty("eventIdInternal"));

        var oldCallbackDataProperty = obj.FindProperty("m_callbackDataInternal");
        var oldCallbackData         = oldCallbackDataProperty.objectReferenceValue as AkEventCallbackData;

        if (!oldCallbackData)
        {
            return(hasMigrated);
        }

        var count = oldCallbackData.callbackFlags.Count;

        if (count != oldCallbackData.callbackFunc.Count || count != oldCallbackData.callbackGameObj.Count)
        {
            UnityEngine.Debug.LogWarning("WwiseUnity: Inconsistent callback data!");
            return(hasMigrated);
        }

        var newCallbackData = obj.FindProperty("Callbacks");

        newCallbackData.arraySize = count;
        obj.FindProperty("useCallbacks").boolValue = true;

        for (var i = 0; i < count; ++i)
        {
            var data = newCallbackData.GetArrayElementAtIndex(i);
            data.FindPropertyRelative("GameObject").objectReferenceValue = oldCallbackData.callbackGameObj[i];
            data.FindPropertyRelative("FunctionName").stringValue        = oldCallbackData.callbackFunc[i];
            data.FindPropertyRelative("Flags.value").intValue            = oldCallbackData.callbackFlags[i];
            UnityEngine.Debug.Log("WwiseUnity: Migrated Callback for function \"" + oldCallbackData.callbackFunc[i] + "\" on <" + oldCallbackData.callbackGameObj[i] + "> with flags <" + (AkCallbackType)oldCallbackData.callbackFlags[i] + ">.");
        }
        return(true);
    }
示例#28
0
        public static void RemoveLayer(StateLayer layer)
        {
                        #if UNITY_EDITOR
            UnityEditor.SerializedObject   layerSerialized = new UnityEditor.SerializedObject(layer);
            UnityEditor.SerializedProperty statesProperty  = layerSerialized.FindProperty("stateReferences");

            foreach (UnityEngine.Object state in statesProperty.GetValues <UnityEngine.Object>())
            {
                if (state is StateLayer)
                {
                    RemoveLayer(state as StateLayer);
                }
                else
                {
                    state.Remove();
                }
            }

            layer.Remove();
                        #endif
        }
示例#29
0
        public override void GatherProperties(PlayableDirector director, IPropertyCollector driver)
        {
#if UNITY_EDITOR
            var binding = director.GetGenericBinding(this) as Transform;
            if (binding == null)
            {
                return;
            }
            var so   = new UnityEditor.SerializedObject(binding);
            var iter = so.GetIterator();
            while (iter.NextVisible(true))
            {
                if (iter.hasVisibleChildren)
                {
                    continue;
                }
                driver.AddFromName <Transform>(binding.gameObject, iter.propertyPath);
            }
#endif
            base.GatherProperties(director, driver);
        }
示例#30
0
        public override void GatherProperties(PlayableDirector director, IPropertyCollector driver)
        {
#if UNITY_EDITOR
            GameObject trackBinding = director.GetGenericBinding(this) as GameObject;
            if (trackBinding != null)
            {
                var serializedObject = new UnityEditor.SerializedObject(trackBinding);
                var iterator         = serializedObject.GetIterator();
                while (iterator.NextVisible(true))
                {
                    if (iterator.hasVisibleChildren)
                    {
                        continue;
                    }

                    driver.AddFromName(trackBinding, iterator.propertyPath);
                }
            }
#endif
            base.GatherProperties(director, driver);
        }
示例#31
0
        public static string[] GetKeyboardAxes()
        {
            var axes = new List <string>();

#if UNITY_EDITOR
            var inputManagerSerialized   = new UnityEditor.SerializedObject(UnityEditor.AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/InputManager.asset"));
            var inputManagerAxesProperty = inputManagerSerialized.FindProperty("m_Axes");

            for (int i = 0; i < inputManagerAxesProperty.arraySize; i++)
            {
                string axisName = inputManagerAxesProperty.GetArrayElementAtIndex(i).FindPropertyRelative("m_Name").GetValue <string>();

                if (!axisName.StartsWith("Any") && !axisName.StartsWith("Joystick") && !axes.Contains(axisName))
                {
                    axes.Add(axisName);
                }
            }
#endif

            return(axes.ToArray());
        }
示例#32
0
        public static bool TagExists(string test)
        {
            if (Array.IndexOf(BuiltInTags, test) != -1)
            {
                return(true);
            }

                        #if UNITY_EDITOR
            var findTagManagerAsset = UnityEditor.AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset");
            if (findTagManagerAsset.Length == 0)
            {
                                #if DEV_MODE
                UnityEngine.Debug.LogError("Failed to find TagManager");
                                #endif
                return(false);
            }

            var tagManager             = findTagManagerAsset[0];
            var tagsSerializedProperty = new UnityEditor.SerializedObject(tagManager).FindProperty("tags");
            for (int n = tagsSerializedProperty.arraySize - 1; n >= 0; n--)
            {
                var tag = tagsSerializedProperty.GetArrayElementAtIndex(n).stringValue;
                if (string.Equals(tag, test))
                {
                                        #if DEV_MODE && DEBUG_ENABLED
                    UnityEngine.Debug.Log("CanPasteTag: YES (tag found in tag manager at index " + n + ")");
                                        #endif
                    return(true);
                }
                                #if DEV_MODE && DEBUG_ENABLED
                UnityEngine.Debug.Log("\"" + test + "\" != \"" + tag + "\"...");
                                #endif
            }
                        #if DEV_MODE && DEBUG_ENABLED
            UnityEngine.Debug.Log("CanPasteTag: NO (tag not found in tag manager's tag array of size " + tagsSerializedProperty.arraySize + ")");
                        #endif
                        #endif

            return(false);
        }
        public static void UpdateProperties(ChiselModel model, MeshRenderer[] meshRenderers)
        {
            if (meshRenderers == null || meshRenderers.Length == 0)
            {
                return;
            }

            var renderSettings = model.RenderSettings;

#if UNITY_EDITOR
            // Warning: calling new UnityEditor.SerializedObject with an empty array crashes Unity
            using (var serializedObject = new UnityEditor.SerializedObject(meshRenderers))
            {
                serializedObject.SetPropertyValue("m_ImportantGI", renderSettings.importantGI);
                serializedObject.SetPropertyValue("m_PreserveUVs", renderSettings.optimizeUVs);
                serializedObject.SetPropertyValue("m_IgnoreNormalsForChartDetection", renderSettings.ignoreNormalsForChartDetection);
                serializedObject.SetPropertyValue("m_AutoUVMaxDistance", renderSettings.autoUVMaxDistance);
                serializedObject.SetPropertyValue("m_AutoUVMaxAngle", renderSettings.autoUVMaxAngle);
                serializedObject.SetPropertyValue("m_MinimumChartSize", renderSettings.minimumChartSize);
            }
#endif

            for (int i = 0; i < meshRenderers.Length; i++)
            {
                var meshRenderer = meshRenderers[i];
                meshRenderer.lightProbeProxyVolumeOverride = renderSettings.lightProbeProxyVolumeOverride;
                meshRenderer.probeAnchor = renderSettings.probeAnchor;
                meshRenderer.motionVectorGenerationMode = renderSettings.motionVectorGenerationMode;
                meshRenderer.reflectionProbeUsage       = renderSettings.reflectionProbeUsage;
                meshRenderer.lightProbeUsage            = renderSettings.lightProbeUsage;
                meshRenderer.allowOcclusionWhenDynamic  = renderSettings.allowOcclusionWhenDynamic;
                meshRenderer.renderingLayerMask         = renderSettings.renderingLayerMask;
#if UNITY_EDITOR
                meshRenderer.stitchLightmapSeams = renderSettings.stitchLightmapSeams;
                meshRenderer.scaleInLightmap     = renderSettings.scaleInLightmap;
                meshRenderer.receiveGI           = renderSettings.receiveGI;
#endif
            }
        }
示例#34
0
        static public void RegisterInputs(List <InputManagerEntry> entries)
        {
            // Grab reference to input manager
            var currentSelection = UnityEditor.Selection.activeObject;

            UnityEditor.EditorApplication.ExecuteMenuItem("Edit/Project Settings/Input");
            var inputManager = UnityEditor.Selection.activeObject;

            // Wrap in serialized object
            var soInputManager = new UnityEditor.SerializedObject(inputManager);
            var spAxes         = soInputManager.FindProperty("m_Axes");

            foreach (InputManagerEntry entry in entries)
            {
                WriteEntry(spAxes, entry);
            }

            // Commit
            soInputManager.ApplyModifiedProperties();

            UnityEditor.Selection.activeObject = currentSelection;
        }
        protected virtual void OnValidate()
        {
            // change old DeviceRole value to viveRole value
            var serializedObject = new UnityEditor.SerializedObject(this);

            var roleValueProp = serializedObject.FindProperty("role");
            var oldRoleValue  = roleValueProp.intValue;

            if (oldRoleValue != (int)DeviceRole.Invalid)
            {
                Type newRoleType;
                int  newRoleValue;

                if (oldRoleValue == -1)
                {
                    newRoleType  = typeof(DeviceRole);
                    newRoleValue = (int)DeviceRole.Hmd;
                }
                else
                {
                    newRoleType  = typeof(HandRole);
                    newRoleValue = oldRoleValue;
                }

                if (Application.isPlaying)
                {
                    roleValueProp.intValue = (int)DeviceRole.Invalid;
                    m_viveRole.Set(newRoleType, newRoleValue);
                }
                else
                {
                    roleValueProp.intValue = (int)DeviceRole.Invalid;
                    serializedObject.ApplyModifiedProperties();
                    m_viveRole.Set(newRoleType, newRoleValue);
                    serializedObject.Update();
                }
            }
            serializedObject.Dispose();
        }
        public static StateLayer AddLayer(StateMachine machine, StateLayer layer, UnityEngine.Object parent)
        {
            #if UNITY_EDITOR
            layer.hideFlags = HideFlags.HideInInspector;

            var parentSerialized = new UnityEditor.SerializedObject(parent);
            var layerSerialized = new UnityEditor.SerializedObject(layer);
            var layersProperty = parentSerialized.FindProperty("stateReferences");
            var parentProperty = layerSerialized.FindProperty("parentReference");

            if (parentProperty.GetValue<UnityEngine.Object>() == null)
                parentProperty.SetValue(parent);

            layerSerialized.FindProperty("machineReference").SetValue(machine);
            layerSerialized.ApplyModifiedProperties();

            if (!layersProperty.Contains(layer))
                layersProperty.Add(layer);

            UpdateLayerStates(machine, layer);
            UpdateCallbacks(machine);
            #endif

            return layer;
        }
示例#37
0
        public static void SetupInputManager()
        {
            #if UNITY_EDITOR
            var inputManagerSerialized = new UnityEditor.SerializedObject(UnityEditor.AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/InputManager.asset"));
            var axesProperty = inputManagerSerialized.FindProperty("m_Axes");

            var joysticks = (Joysticks[])System.Enum.GetValues(typeof(Joysticks));

            for (int i = 0; i < joysticks.Length; i++)
            {
                var joystick = joysticks[i];
                var joystickAxes = (JoystickAxes[])System.Enum.GetValues(typeof(JoystickAxes));

                for (int j = 0; j < joystickAxes.Length; j++)
                {
                    var joystickAxis = joystickAxes[j];
                    var axis = joystick.ToString() + joystickAxis;
                    var currentAxisProperty = axesProperty.Find(property => property.FindPropertyRelative("m_Name").GetValue<string>() == axis);

                    if (currentAxisProperty == null)
                    {
                        axesProperty.arraySize += 1;
                        currentAxisProperty = axesProperty.Last();
                        currentAxisProperty.SetValue("m_Name", axis);
                        currentAxisProperty.SetValue("descriptiveName", "");
                        currentAxisProperty.SetValue("descriptiveNegativeName", "");
                        currentAxisProperty.SetValue("negativeButton", "");
                        currentAxisProperty.SetValue("positiveButton", "");
                        currentAxisProperty.SetValue("altNegativeButton", "");
                        currentAxisProperty.SetValue("altPositiveButton", "");
                        currentAxisProperty.SetValue("gravity", 0f);
                        currentAxisProperty.SetValue("dead", 0.2f);
                        currentAxisProperty.SetValue("sensitivity", 1f);
                        currentAxisProperty.SetValue("snap", false);
                        currentAxisProperty.SetValue("invert", joystickAxis == JoystickAxes.LeftStickY || joystickAxis == JoystickAxes.RightStickY);
                        currentAxisProperty.SetValue("type", value: 2);
                        currentAxisProperty.SetValue("axis", value: (joystickAxis == JoystickAxes.LeftTrigger || joystickAxis == JoystickAxes.RightTrigger) ? 2 : (int)joystickAxis);
                        currentAxisProperty.SetValue("joyNum", value: (int)joystick);
                    }
                    else
                        break;
                }
            }

            inputManagerSerialized.ApplyModifiedProperties();
            #endif
        }
        public static State AddState(StateMachine machine, StateLayer layer, State state)
        {
            #if UNITY_EDITOR
            state.hideFlags = HideFlags.HideInInspector;

            var layerSerialized = new UnityEditor.SerializedObject(layer);
            var stateSerialized = new UnityEditor.SerializedObject(state);
            var statesProperty = layerSerialized.FindProperty("stateReferences");

            stateSerialized.FindProperty("layerReference").SetValue(layer);
            stateSerialized.FindProperty("machineReference").SetValue(machine);
            stateSerialized.ApplyModifiedProperties();

            if (!statesProperty.Contains(state))
                statesProperty.Add(state);
            #endif

            return state;
        }
        public static void RemoveLayer(StateMachine machine, StateLayer layer)
        {
            #if UNITY_EDITOR
            var layerSerialized = new UnityEditor.SerializedObject(layer);
            var statesProperty = layerSerialized.FindProperty("stateReferences");
            var states = statesProperty.GetValues<UnityEngine.Object>();

            for (int i = 0; i < states.Length; i++)
            {
                var state = states[i];
                var sublayer = state as StateLayer;

                if (sublayer != null)
                    RemoveLayer(machine, sublayer);
                else
                    state.Destroy();
            }

            layer.Destroy();
            UpdateCallbacks(machine);
            #endif
        }
        public static void MoveLayerTo(StateLayer layer, UnityEngine.Object parent)
        {
            #if UNITY_EDITOR
            var layerSerialized = new UnityEditor.SerializedObject(layer);
            var newParentSerialized = new UnityEditor.SerializedObject(parent);
            var oldParentProperty = layerSerialized.FindProperty("parentReference");
            var oldParentSerialized = new UnityEditor.SerializedObject(oldParentProperty.GetValue<UnityEngine.Object>());

            oldParentProperty.SetValue(parent);
            oldParentSerialized.FindProperty("stateReferences").Remove(layer);
            newParentSerialized.FindProperty("stateReferences").Add(layer);

            layerSerialized.ApplyModifiedProperties();
            newParentSerialized.ApplyModifiedProperties();
            oldParentSerialized.ApplyModifiedProperties();
            #endif
        }
        public static void AddMissingStates(StateMachine machine, StateLayer layer)
        {
            #if UNITY_EDITOR
            UnityEditor.SerializedObject layerSerialized = new UnityEditor.SerializedObject(layer);
            UnityEditor.SerializedProperty statesProperty = layerSerialized.FindProperty("stateReferences");

            foreach (Type stateType in LayerStateDict[layer.GetType()]) {
                if (!Array.Exists(statesProperty.GetValues<UnityEngine.Object>(), state => state.GetType() == stateType)) {
                    AddState(machine, layer, stateType);
                }
            }
            #endif
        }
        public static void CopyState(State state, State stateToCopy)
        {
            #if UNITY_EDITOR
            if (stateToCopy == null)
                return;

            var stateSerialized = new UnityEditor.SerializedObject(state);
            var parentReference = stateSerialized.FindProperty("layerReference").GetValue<UnityEngine.Object>();
            var machineReference = stateSerialized.FindProperty("machineReference").GetValue<UnityEngine.Object>();

            UnityEditorInternal.ComponentUtility.CopyComponent(stateToCopy);
            UnityEditorInternal.ComponentUtility.PasteComponentValues(state);

            stateSerialized = new UnityEditor.SerializedObject(state);
            stateSerialized.FindProperty("layerReference").SetValue(parentReference);
            stateSerialized.FindProperty("machineReference").SetValue(machineReference);
            #endif
        }
        public static void CopyLayer(StateLayer layer, StateLayer layerToCopy, bool copyStates, bool copySublayers)
        {
            #if UNITY_EDITOR
            if (layerToCopy == null)
                return;

            var layerSerialized = new UnityEditor.SerializedObject(layer);
            var parentReference = layerSerialized.FindProperty("parentReference").GetValue<UnityEngine.Object>();
            var machineReference = layerSerialized.FindProperty("machineReference").GetValue<UnityEngine.Object>();
            var stateReferences = layerSerialized.FindProperty("stateReferences").GetValues<UnityEngine.Object>();
            var activeStateReferences = layerSerialized.FindProperty("activeStateReferences").GetValues<UnityEngine.Object>();

            UnityEditorInternal.ComponentUtility.CopyComponent(layerToCopy);
            UnityEditorInternal.ComponentUtility.PasteComponentValues(layer);

            layerSerialized = new UnityEditor.SerializedObject(layer);
            layerSerialized.FindProperty("parentReference").SetValue(parentReference);
            layerSerialized.FindProperty("machineReference").SetValue(machineReference);
            layerSerialized.FindProperty("stateReferences").SetValues(stateReferences);
            layerSerialized.FindProperty("activeStateReferences").SetValues(activeStateReferences);

            for (int i = 0; i < stateReferences.Length; i++)
            {
                var stateReference = stateReferences[i];
                var state = stateReference as State;
                var sublayer = stateReference as StateLayer;

                if (copyStates && state != null)
                {
                    var stateToCopy = layerToCopy.GetState(state.GetType()) as State;

                    if (stateToCopy != null)
                        CopyState(state, stateToCopy);
                }

                if (copySublayers && sublayer != null)
                {
                    var sublayerToCopy = layerToCopy.GetState(sublayer.GetType()) as StateLayer;

                    if (sublayerToCopy != null)
                        CopyLayer(sublayer, sublayerToCopy, copyStates, copySublayers);
                }
            }
            #endif
        }
        private void Rebuild2DCGCollider()
        {
            try {
                Init();
                if(!initialized) return;

                float ppu = GetPPU(); // get pixels per unit from GameSettings
                SpriteFactory.SF2DColliderGenHelper.Data data = script.CheckCollider(); // get the data we need from the helper script
                if(data == null) throw new System.Exception();

                UnityEngine.Component alphaMeshCollider = script.GetComponent("AlphaMeshCollider");
                if(alphaMeshCollider == null) throw new System.Exception("No AlphaMeshCollider component was found on Sprite! If you have removed the 2D Collider Gen collider, please remove the helper component");
                System.Type type_alphaMeshCollider = alphaMeshCollider.GetType();

                // Verify the 2D Collider Gen fields we need exist
                Verify2DCGFields(type_alphaMeshCollider);

                // Get the serialized objects
                UnityEditor.SerializedObject so = new UnityEditor.SerializedObject(alphaMeshCollider);
                UnityEditor.SerializedProperty sp;
                so.Update();

                // CUSTOM TEX
                sp = so.FindProperty("mRegionIndependentParameters.mCustomTex");
                if(sp == null) FieldException("Required field not found!");

                UnityEngine.Texture2D tex = FindFrameTexture(data.masterSprite);
                if(tex == null) {
                    UnityEngine.Debug.LogWarning("Frame texture not found! 2D Collider Gen mesh collider will not generate correctly.");
                }
                sp.objectReferenceValue = tex;

                // CUSTOM SCALE
                sp = so.FindProperty("mRegionIndependentParameters.mCustomScale");
                if(sp == null) FieldException("Required field not found!");

                UnityEngine.Vector2 scale = data.pixelScale / ppu; // convert pixel scale to units
                sp.vector2Value = scale; // update scale

                // FLIP
                UnityEngine.Vector2 offset = data.unitOffset; // get offset which is affected by flip

                // FLIP X
                sp = so.FindProperty("mRegionIndependentParameters.mFlipHorizontal");
                if(sp == null) FieldException("Required field not found!");

                if(sp.boolValue != data.isFlippedX) sp.boolValue = data.isFlippedX;
                if(data.isFlippedX) {
                    offset.x *= -1.0f;
                }

                // FLIP Y
                sp = so.FindProperty("mRegionIndependentParameters.mFlipVertical");
                if(sp == null) FieldException("Required field not found!");

                if(sp.boolValue != data.isFlippedY) sp.boolValue = data.isFlippedY;
                if(data.isFlippedY) {
                    offset.y *= -1.0f;
                }

                // CUSTOM OFFSET
                sp = so.FindProperty("mRegionIndependentParameters.mCustomOffset");
                if(sp == null) FieldException("Required field not found!");

                sp.vector3Value = offset; // update offset

                // Finish up with the serialized object
                so.ApplyModifiedProperties();

                // Rebuild the 2DCG collider
                type_alphaMeshCollider.InvokeMember("RecalculateCollider", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.InvokeMethod, null, alphaMeshCollider, null);

            } catch(System.Exception e) {
                UnityEngine.Debug.LogError(e.Message);
                UnityEngine.Debug.LogError("STACK TRACE: " + e.StackTrace);
            }
        }
		public void RepaintInspector() {
			#if UNITY_EDITOR
			if (pureData.generalSettings.IsMainThread()) {
				UnityEditor.SerializedObject pureDataSerialized = new UnityEditor.SerializedObject(pureData);
				UnityEditor.SerializedProperty repaintDummyProperty = pureDataSerialized.FindProperty("editorHelper").FindPropertyRelative("repaintDummy");
				repaintDummyProperty.SetValue(!repaintDummy);
			}
			else {
				repaint = true;
			}
			#endif
		}
        public static StateLayer[] GetSubLayersRecursive(StateLayer layer)
        {
            var subLayers = new List<StateLayer>();

            #if UNITY_EDITOR
            var layerSerialized = new UnityEditor.SerializedObject(layer);
            var subLayersProperty = layerSerialized.FindProperty("stateReferences");

            for (int i = 0; i < subLayersProperty.arraySize; i++)
            {
                var subLayer = subLayersProperty.GetValue(i) as StateLayer;

                if (subLayer != null)
                {
                    subLayers.Add(subLayer);
                    subLayers.AddRange(GetSubLayersRecursive(subLayer));
                }
            }
            #endif

            return subLayers.ToArray();
        }
        public static void AddMissingStates(StateMachine machine, StateLayer layer)
        {
            #if UNITY_EDITOR
            var layerSerialized = new UnityEditor.SerializedObject(layer);
            var statesProperty = layerSerialized.FindProperty("stateReferences");
            var stateTypes = LayerTypeStateTypeDict[layer.GetType()];

            for (int i = 0; i < stateTypes.Count; i++)
            {
                var stateType = stateTypes[i];

                if (statesProperty != null && !Array.Exists(statesProperty.GetValues<UnityEngine.Object>(), state => state.GetType() == stateType))
                    AddState(machine, layer, stateType);
            }
            #endif
        }
        public static bool IsParent(StateLayer layer, UnityEngine.Object parent)
        {
            bool isParent = false;

            #if UNITY_EDITOR
            var layerSerialized = new UnityEditor.SerializedObject(layer);
            isParent = layerSerialized.FindProperty("parentReference").GetValue<UnityEngine.Object>() == parent;
            #endif

            return isParent;
        }
        public static void RemoveLayer(StateLayer layer)
        {
            #if UNITY_EDITOR
            UnityEditor.SerializedObject layerSerialized = new UnityEditor.SerializedObject(layer);
            UnityEditor.SerializedProperty statesProperty = layerSerialized.FindProperty("stateReferences");

            foreach (UnityEngine.Object state in statesProperty.GetValues<UnityEngine.Object>()) {
                if (state is StateLayer) {
                    RemoveLayer(state as StateLayer);
                }
                else {
                    state.Remove();
                }
            }

            layer.Remove();
            #endif
        }