private void SetGuid(AK.Wwise.TreeView.TreeViewItem in_item)
    {
        m_serializedObject.Update();

        var obj = in_item.DataContext as AkWwiseTreeView.AkTreeInfo;

        //we set the items guid
        AkUtilities.SetByteArrayProperty(m_selectedItemGuid[0], obj.Guid);
        if (m_selectedItemID != null)
        {
            m_selectedItemID[0].intValue = obj.ID;
        }

        //When its a State or a Switch, we set the group's guid
        if (m_selectedItemGuid.Length == 2)
        {
            obj = in_item.Parent.DataContext as AkWwiseTreeView.AkTreeInfo;
            AkUtilities.SetByteArrayProperty(m_selectedItemGuid[1], obj.Guid);
            if (m_selectedItemID != null)
            {
                m_selectedItemID[1].intValue = obj.ID;
            }
        }

        m_serializedObject.ApplyModifiedProperties();
    }
Esempio n. 2
0
        static public int CreateLayer(string name)
        {
            //  https://forum.unity.com/threads/adding-layer-by-script.41970/#post-2274824
            UnityEditor.SerializedObject   tagManager = new UnityEditor.SerializedObject(UnityEditor.AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset")[0]);
            UnityEditor.SerializedProperty layers     = tagManager.FindProperty("layers");
            bool ExistLayer = false;

            for (int i = 8; i < layers.arraySize; i++)
            {
                UnityEditor.SerializedProperty layerSP = layers.GetArrayElementAtIndex(i);

                if (layerSP.stringValue == name)
                {
                    ExistLayer = true;
                    return(i);
                }
            }
            for (int j = 8; j < layers.arraySize; j++)
            {
                UnityEditor.SerializedProperty layerSP = layers.GetArrayElementAtIndex(j);
                if (layerSP.stringValue == "" && !ExistLayer)
                {
                    layerSP.stringValue = name;
                    tagManager.ApplyModifiedProperties();

                    return(j);
                }
            }

            return(0);
        }
Esempio n. 3
0
        public void SetNewEditor()
        {
            var so = new UnityEditor.SerializedObject(this);

            so.FindProperty("id").intValue = Random.Range(int.MinValue, int.MaxValue);
            so.ApplyModifiedProperties();
        }
Esempio n. 4
0
        public override bool DrawGui(GUIStyle textStyle, GUIStyle buttonStyle)
        {
#if UNITY_EDITOR
            UnityEditor.SerializedObject so = new UnityEditor.SerializedObject(this);
            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            UnityEditor.EditorGUILayout.PropertyField(so.FindProperty(nameof(Sprite)), GUIContent.none, true);
            GUILayout.Space(20);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            UnityEditor.EditorGUILayout.PropertyField(so.FindProperty(nameof(Frame)), GUIContent.none, true);
            so.ApplyModifiedProperties();
            GUILayout.Space(20);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            GUILayout.Label("Instanced");
            InstancedIndex = UnityEditor.EditorGUILayout.IntSlider(InstancedIndex, -1, 1);
            GUILayout.Space(20);
            GUILayout.EndHorizontal();
#endif
            return(false);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        public void AwakeMe()
        {
            if (gameObject.activeInHierarchy)
            {
                if (sparseRemove.Length < 10)
                {
                    System.Array.Resize(ref sparseRemove, 10);
                }
                if (sparseRandom.Length < 10)
                {
                    System.Array.Resize(ref sparseRandom, 10);
                }

                for (int i = 0; i < numberOfModifiers; i++)
                {
                    iteration = i;
                    if (rooftopElements[0] != null)
                    {
                        if (useAdvertising)
                        {
                            bmComponent    = gameObject.GetComponent <BuildingModifier>();
                            roofTopsObject = null;
                            // rooftopHolder = null;
                            if (rooftopHolder[iteration] == null)
                            {
                                rooftopHolder[iteration] = new GameObject(gameObject.transform.name + "_Detail");
#if UNITY_EDITOR
                                if (rooftopHolder[iteration].GetComponent <LODGroup>() == null)
                                {
                                    lodComponent = rooftopHolder[iteration].AddComponent <LODGroup>();
                                    UnityEditor.SerializedObject obj = new UnityEditor.SerializedObject(lodComponent);

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

                                        if (j == 0)
                                        {
                                            sHeight.doubleValue = 0.8;
                                        }
                                        if (j == 1)
                                        {
                                            sHeight.doubleValue = 0.5;
                                        }
                                        if (j == 2)
                                        {
                                            sHeight.doubleValue = 0.1;
                                        }
                                    }
                                    obj.ApplyModifiedProperties();
                                }
#endif
                            }
                            UpdateElements();
                        }
                    }
                }
            }
        }
Esempio n. 7
0
		public void DrawGeneralFunction()
		{
			AmplifyShaderFunction function = ParentWindow.CurrentGraph.CurrentShaderFunction:
			if ( function == null )
				return:

			float cacheWidth = EditorGUIUtility.labelWidth:
			EditorGUIUtility.labelWidth = 115:

			SerializedObject serializedObject = new UnityEditor.SerializedObject( function ):

			if ( serializedObject != null )
			{
				SerializedProperty temo = serializedObject.FindProperty( "m_description" ):
				EditorGUILayout.PropertyField( temo, new GUIContent( "    Description" ) ):

				SerializedProperty cat = serializedObject.FindProperty( "m_nodeCategory" ):
				SerializedProperty ppos = serializedObject.FindProperty( "m_previewPosition" ):
				
				EditorGUILayout.PropertyField( ppos, new GUIContent( "Preview Position" ) ):
				cat.intValue = ParentWindow.CurrentGraph.CurrentOutputNode.EditorGUILayoutPopup( "Category", cat.intValue, UIUtils.CategoryPresets ):

				if( cat.enumValueIndex == 0 )
				{
					SerializedProperty custCat = serializedObject.FindProperty( "m_customNodeCategory" ):
					EditorGUILayout.PropertyField( custCat, new GUIContent( "Custom" ) ):
				}
				SerializedProperty hidden = serializedObject.FindProperty( "m_hidden" ):
				EditorGUILayout.PropertyField( hidden, new GUIContent( "Hidden" ) ):
				serializedObject.ApplyModifiedProperties():
			}
			EditorGUIUtility.labelWidth = cacheWidth:
		}
Esempio n. 8
0
        void GetMeshes()
        {
            if (m_Prepared)
            {
                UnityEditor.EditorUtility.DisplayDialog("Error", "Make sure is default state and not check prepared", "OK");
                return;
            }
            UnityEditor.SerializedObject target = new UnityEditor.SerializedObject(this);
            target.Update();
            var skin = target.FindProperty("m_LodSkins");

            skin.ClearArray();
            //if(skin.arraySize == 0)
            {
                var meshes = GetComponentsInChildren <SkinnedMeshRenderer>();
                for (int i = 0; i < meshes.Length; i++)
                {
                    skin.InsertArrayElementAtIndex(i);
                    var pro = skin.GetArrayElementAtIndex(i).FindPropertyRelative("m_Mesh");
                    pro.objectReferenceValue = meshes[i];
                    pro = skin.GetArrayElementAtIndex(i).FindPropertyRelative("m_RootBone");
                    pro.objectReferenceValue = meshes[i].rootBone;
                }
            }
            target.ApplyModifiedProperties();
        }
Esempio n. 9
0
        public void ApplyAllPhysicsSettings()
        {
            Physics.gravity = gravity;

            Time.fixedDeltaTime        = physicsTimeStep;
            Physics.autoSimulation     = autoSimulation;
            Physics.autoSyncTransforms = autoSyncTransforms;
            // Call method for security reasons
            ApplyUnsupportedSettings();

            Physics.sleepThreshold       = sleepThreashold;
            Physics.bounceThreshold      = bounceThreshold;
            Physics.defaultContactOffset = defaultContactOffset;

            Physics.defaultSolverIterations         = defaultSolverIterations;
            Physics.defaultSolverVelocityIterations = defaultSolverVelocityIterations;

            Physics.interCollisionDistance       = clothInterCollisionDistance;
            Physics.interCollisionSettingsToggle = clothInterCollisionSettingsToggle;
            Physics.interCollisionStiffness      = clothInterCollisionStiffness;

            Physics.queriesHitBackfaces = queriesHitBackfaces;
            Physics.queriesHitTriggers  = queriesHitTriggers;

            Physics.RebuildBroadphaseRegions(worldBounds, worldSubdivisions);
#if UNITY_EDITOR
            // Unsupported settings, can only be changed in editor
            var obj = UnityEditor.Unsupported.GetSerializedAssetInterfaceSingleton("PhysicsManager");
            UnityEditor.SerializedObject so = new UnityEditor.SerializedObject(obj);
            so.FindProperty("m_WorldBounds").boundsValue    = worldBounds;
            so.FindProperty("m_WorldSubdivisions").intValue = worldSubdivisions;
            so.ApplyModifiedProperties();
#endif
        }
Esempio n. 10
0
        public override bool DrawGui(GUIStyle textStyle, GUIStyle buttonStyle)
        {
#if UNITY_EDITOR
            UnityEditor.SerializedObject so = new UnityEditor.SerializedObject(this);

            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            UnityEditor.EditorGUILayout.LabelField("Vertical", textStyle);
            UnityEditor.EditorGUILayout.Slider(so.FindProperty(nameof(VerticalSwayAmount)), 0, 0.1f, GUIContent.none);
            GUILayout.Space(20);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            UnityEditor.EditorGUILayout.LabelField("Horizontal", textStyle);
            UnityEditor.EditorGUILayout.Slider(so.FindProperty(nameof(HorizontalSwayAmount)), 0, 0.1f, GUIContent.none);
            GUILayout.Space(20);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            UnityEditor.EditorGUILayout.LabelField("Sway", textStyle);
            UnityEditor.EditorGUILayout.Slider(so.FindProperty(nameof(SwaySpeed)), 0, 15f, GUIContent.none);
            GUILayout.Space(20);
            GUILayout.EndHorizontal();
            so.ApplyModifiedProperties();
#endif
            return(false);
        }
Esempio n. 11
0
        public override bool DrawGui(GUIStyle textStyle, GUIStyle buttonStyle)
        {
#if UNITY_EDITOR
            UnityEditor.SerializedObject so = new UnityEditor.SerializedObject(this);

            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            UnityEditor.EditorGUILayout.PropertyField(so.FindProperty(nameof(Curve)), GUIContent.none, true);
            GUILayout.Space(20);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            UnityEditor.EditorGUILayout.PropertyField(so.FindProperty(nameof(Duration)), GUIContent.none, true);
            GUILayout.Space(20);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            UnityEditor.EditorGUILayout.PropertyField(so.FindProperty(nameof(Target)), GUIContent.none, true);
            GUILayout.Space(20);
            GUILayout.EndHorizontal();

            so.ApplyModifiedProperties();
#endif
            return(false);
        }
Esempio n. 12
0
        public static void AddAlwaysIncludedShader(Shader shader)
        {
#if UNITY_EDITOR
            var  graphicsSettingsObj = UnityEditor.AssetDatabase.LoadAssetAtPath <UnityEngine.Rendering.GraphicsSettings>("ProjectSettings/GraphicsSettings.asset");
            var  serializedObject    = new UnityEditor.SerializedObject(graphicsSettingsObj);
            var  arrayProp           = serializedObject.FindProperty("m_AlwaysIncludedShaders");
            bool hasShader           = false;
            for (int i = 0; i < arrayProp.arraySize; ++i)
            {
                var arrayElem = arrayProp.GetArrayElementAtIndex(i);
                if (shader == arrayElem.objectReferenceValue)
                {
                    hasShader = true;
                    break;
                }
            }

            if (!hasShader)
            {
                int arrayIndex = arrayProp.arraySize;
                arrayProp.InsertArrayElementAtIndex(arrayIndex);
                var arrayElem = arrayProp.GetArrayElementAtIndex(arrayIndex);
                arrayElem.objectReferenceValue = shader;

                serializedObject.ApplyModifiedProperties();

                UnityEditor.AssetDatabase.SaveAssets();
            }
#endif
        }
        public static void SaveObjectInEditor <T>(T anyObject)
            where T : UnityEngine.Component
        {
            var serObject = new UnityEditor.SerializedObject(anyObject);

            serObject.ApplyModifiedProperties();
            UnityEditor.PrefabUtility.RecordPrefabInstancePropertyModifications(anyObject);
        }
Esempio n. 14
0
        void SetLightmapScale(MeshRenderer mr, float lightmapScale)
        {
#if UNITY_EDITOR
            UnityEditor.SerializedObject so = new UnityEditor.SerializedObject(mr);
            so.FindProperty("m_ScaleInLightmap").floatValue = lightmapScale;
            so.ApplyModifiedProperties();
#else
            return;
#endif
        }
Esempio n. 15
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())
     {
         loggable.LogLevel = ExposeLogLevel(logLevelSp);
         obj.ApplyModifiedProperties();
     }
 }
Esempio n. 16
0
        public void ImportText()
        {
            // get text from clipboard
            var text = GUIUtility.systemCopyBuffer;

            var serializedObject = new UnityEditor.SerializedObject(this);
            var textProperty     = serializedObject.FindProperty("text");

            textProperty.stringValue = text;

            serializedObject.ApplyModifiedProperties();
        }
Esempio n. 17
0
        void RegisterInputs()
        {
#if UNITY_EDITOR
            // 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");

            // Add new bindings
            new InputManagerEntry {
                name = kEnableDebugBtn1, kind = InputManagerEntry.Kind.KeyOrButton, btnPositive = "left ctrl", altBtnPositive = "joystick button 8"
            }.WriteEntry(spAxes);
            new InputManagerEntry {
                name = kEnableDebugBtn2, kind = InputManagerEntry.Kind.KeyOrButton, btnPositive = "backspace", altBtnPositive = "joystick button 9"
            }.WriteEntry(spAxes);

            new InputManagerEntry {
                name = kDebugNextBtn, kind = InputManagerEntry.Kind.KeyOrButton, btnPositive = "page down", altBtnPositive = "joystick button 5"
            }.WriteEntry(spAxes);
            new InputManagerEntry {
                name = kDebugPreviousBtn, kind = InputManagerEntry.Kind.KeyOrButton, btnPositive = "page up", altBtnPositive = "joystick button 4"
            }.WriteEntry(spAxes);

            new InputManagerEntry {
                name = kDPadHorizontal, kind = InputManagerEntry.Kind.KeyOrButton, btnPositive = "right", btnNegative = "left", gravity = 1000.0f, deadZone = 0.001f, sensitivity = 1000.0f
            }.WriteEntry(spAxes);
            new InputManagerEntry {
                name = kDPadHorizontal, kind = InputManagerEntry.Kind.Axis, axis = InputManagerEntry.Axis.Sixth, btnPositive = "right", btnNegative = "left", gravity = 1000.0f, deadZone = 0.001f, sensitivity = 1000.0f
            }.WriteEntry(spAxes);
            new InputManagerEntry {
                name = kDPadVertical, kind = InputManagerEntry.Kind.KeyOrButton, btnPositive = "up", btnNegative = "down", gravity = 1000.0f, deadZone = 0.001f, sensitivity = 1000.0f
            }.WriteEntry(spAxes);
            new InputManagerEntry {
                name = kDPadVertical, kind = InputManagerEntry.Kind.Axis, axis = InputManagerEntry.Axis.Seventh, btnPositive = "up", btnNegative = "down", gravity = 1000.0f, deadZone = 0.001f, sensitivity = 1000.0f
            }.WriteEntry(spAxes);

            new InputManagerEntry {
                name = kValidateBtn, kind = InputManagerEntry.Kind.KeyOrButton, btnPositive = "return", altBtnPositive = "joystick button 0"
            }.WriteEntry(spAxes);
            new InputManagerEntry {
                name = kPersistentBtn, kind = InputManagerEntry.Kind.KeyOrButton, btnPositive = "right shift", altBtnPositive = "joystick button 2"
            }.WriteEntry(spAxes);

            // Commit
            soInputManager.ApplyModifiedProperties();

            UnityEditor.Selection.activeObject = currentSelection;
#endif
        }
Esempio n. 18
0
        public void ApplyBoundSettings()
        {
            Physics.RebuildBroadphaseRegions(worldBounds, worldSubdivisions);
#if UNITY_EDITOR
            // Unsupported settings, can only be changed in editor
            var obj = UnityEditor.Unsupported.GetSerializedAssetInterfaceSingleton("PhysicsManager");
            UnityEditor.SerializedObject so = new UnityEditor.SerializedObject(obj);
            so.FindProperty("m_WorldBounds").boundsValue    = worldBounds;
            so.FindProperty("m_WorldSubdivisions").intValue = worldSubdivisions;
            so.ApplyModifiedProperties();
#endif
        }
Esempio n. 19
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);
        }
Esempio n. 20
0
        public void ApplyUnsupportedSettings(PhysicMaterial defaultMaterial, bool enhancedDeterminism, bool adaptiveForce, bool unifiedHeightmaps, FrictionType frictionType)
        {
#if UNITY_EDITOR
            var obj = UnityEditor.Unsupported.GetSerializedAssetInterfaceSingleton("PhysicsManager");
            UnityEditor.SerializedObject so = new UnityEditor.SerializedObject(obj);
            so.FindProperty("m_DefaultMaterial").objectReferenceValue = this.defaultMaterial = defaultMaterial;
            so.FindProperty("m_EnableEnhancedDeterminism").boolValue  = this.enhancedDeterminism = enhancedDeterminism;
            so.FindProperty("m_EnableAdaptiveForce").boolValue        = this.enableAdaptiveForce = adaptiveForce;
            so.FindProperty("m_EnableUnifiedHeightmaps").boolValue    = this.unifiedHeightmaps = unifiedHeightmaps;
            so.FindProperty("m_FrictionType").intValue = (int)(this.frictionType = frictionType);
            so.ApplyModifiedProperties();
#endif
        }
Esempio n. 21
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;
        }
Esempio n. 22
0
        static void CreateLayer()
        {
#if UNITY_EDITOR
            /* when running in the editor, check that UI_layer and UI_layer + 1 are free,
             * and then give them useful names.  This is based on
             * https://forum.unity3d.com/threads/adding-layer-by-script.41970/reply?quote=2274824
             * but with a constant value for UI_layer.  The problem is that this code cannot run
             * outside the editor.  So I can find no reasonable way to dynamically pick an unused
             * layer in builds that run outside the editor...
             */
            UnityEditor.SerializedObject tagManager = new UnityEditor.SerializedObject(
                UnityEditor.AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset")[0]);
            UnityEditor.SerializedProperty layers  = tagManager.FindProperty("layers");
            UnityEditor.SerializedProperty layer29 = layers.GetArrayElementAtIndex(UI_layer);
            UnityEditor.SerializedProperty layer30 = layers.GetArrayElementAtIndex(UI_layer + 1);

            if (layer29.stringValue == "")
            {
                layer29.stringValue = "BaroqueUI dialog";
                tagManager.ApplyModifiedProperties();
            }
            if (layer30.stringValue == "")
            {
                layer30.stringValue = "BaroqueUI dialog rendering";
                tagManager.ApplyModifiedProperties();
            }

            Debug.Assert(layer29.stringValue == "BaroqueUI dialog");
            Debug.Assert(layer30.stringValue == "BaroqueUI dialog rendering");
#endif

            /* we want all cameras to hide these two layers */
            if (!camera_onprecull_set)
            {
                Camera.onPreCull    += Camera_OnPreCull;
                camera_onprecull_set = true;
            }
        }
Esempio n. 23
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
        }
Esempio n. 24
0
        public static void Copy <T>(T copyTo, T copyFrom) where T : Object
        {
                        #if UNITY_EDITOR
            UnityEditor.SerializedObject   copyToSerialized   = new UnityEditor.SerializedObject(copyTo);
            UnityEditor.SerializedObject   copyFromSerialized = new UnityEditor.SerializedObject(copyFrom);
            UnityEditor.SerializedProperty iterator           = copyFromSerialized.GetIterator();

            while (iterator.Next(true))
            {
                copyToSerialized.CopyFromSerializedProperty(iterator);
            }

            copyToSerialized.ApplyModifiedProperties();
                        #endif
        }
Esempio n. 25
0
        internal void UpdateMarkerSize(Vector2 markerSize)
        {
#if UNITY_EDITOR
            if (!ValidateMarkerRenderer())
            {
                return;
            }

            // We do the transform scale modification in order to trigger a SimulatedObject refresh
            // to be able to update the Bounds of the synthetic marker in the MARS Database
            m_MarkerRendererSerializedObjectTransform.Update();
            m_MarkerRendererTransformLocalScaleProperty.vector3Value = new Vector3(markerSize.x, 0.01f, markerSize.y);
            m_MarkerRendererSerializedObjectTransform.ApplyModifiedProperties();
#endif
        }
 private void EditorSelect(GameObject obj)
 {
                 #if UNITY_EDITOR
     for (int i = 0; i < objects.Count; i++)
     {
         if (objects [i])
         {
             var so = new UnityEditor.SerializedObject(objects[i]);
             so.Update();
             so.FindProperty("m_IsActive").boolValue = objects [i] == obj;
             so.ApplyModifiedProperties();
         }
     }
                 #endif
 }
Esempio n. 27
0
        void Start()
        {
            if (UnityEditor.PrefabUtility.IsPartOfPrefabInstance(this) == false)
            {
                return;
            }

            string     teleportAssetPath = UnityEditor.PrefabUtility.GetPrefabAssetPathOfNearestInstanceRoot(this);
            GameObject teleportPrefab    = UnityEditor.AssetDatabase.LoadAssetAtPath <GameObject>(teleportAssetPath);

            Teleport teleport = teleportPrefab.GetComponent <Teleport>();

            UnityEditor.SerializedObject serializedTeleport = new UnityEditor.SerializedObject(teleport);
            serializedTeleport.Update();
            bool changed = false;

            changed |= FindURPVersion(serializedTeleport, "areaHighlightedMaterial");

            changed |= FindURPVersion(serializedTeleport, "areaLockedMaterial");

            changed |= FindURPVersion(serializedTeleport, "areaVisibleMaterial");

            changed |= FindURPVersion(serializedTeleport, "pointHighlightedMaterial");

            changed |= FindURPVersion(serializedTeleport, "pointLockedMaterial");

            changed |= FindURPVersion(serializedTeleport, "pointVisibleMaterial");

            if (changed)
            {
                serializedTeleport.ApplyModifiedProperties();
                UnityEditor.EditorUtility.SetDirty(teleport);
            }

            TeleportArc arc = teleportPrefab.GetComponent <TeleportArc>();

            UnityEditor.SerializedObject serializedArc = new UnityEditor.SerializedObject(arc);
            serializedArc.Update();

            changed = FindURPVersion(serializedArc, "material");

            if (changed)
            {
                serializedArc.ApplyModifiedProperties();
                UnityEditor.EditorUtility.SetDirty(arc);
            }
        }
Esempio n. 28
0
        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
        }
Esempio n. 29
0
        // ---------[ EVENTS ]---------
        #if UNITY_EDITOR
        // BUG(@jackson): There's something that needs to be done here with serialization
        // potentially - the dropdown seems to load the option data late?
        /// <summary>Fills the Dropdown options with the supplied data.</summary>
        private void OnValidate()
        {
            UnityEditor.EditorApplication.delayCall += () =>
            {
                if (this == null || Application.isPlaying)
                {
                    return;
                }

                // sync dropdown
                Dropdown d = this.dropdown;
                if (d == null)
                {
                    return;
                }

                d.ClearOptions();

                List <string> displayTextList = new List <string>();
                foreach (OptionData option in this.options)
                {
                    displayTextList.Add(option.displayText);
                }
                d.AddOptions(displayTextList);

                // set explorer view default sort
                ExplorerView view = this.GetComponentInParent <ExplorerView>();
                if (view != null)
                {
                    bool   defaultAscending = false;
                    string defaultField     = ModIO.API.GetAllModsFilterFields.dateLive;

                    if (this.options != null && this.options.Length > 0)
                    {
                        defaultAscending = this.options[0].isAscending;
                        defaultField     = this.options[0].fieldName;
                    }

                    var so = new UnityEditor.SerializedObject(view);
                    so.FindProperty("defaultSortMethod.ascending").boolValue   = defaultAscending;
                    so.FindProperty("defaultSortMethod.fieldName").stringValue = defaultField;
                    so.ApplyModifiedProperties();
                }
            };
        }
Esempio n. 30
0
        void OnValidate()
        {
            if (!attachedLight)
            {
                TryGetComponent(out attachedLight);
            }
            if (!attachedPolygon)
            {
                TryGetComponent(out attachedPolygon);
            }
#if UNITY_EDITOR
            var lightObj = new UnityEditor.SerializedObject(attachedLight);
            lightObj.FindProperty("m_ShapePath").arraySize = pathLength;
            lightObj.ApplyModifiedProperties();
            path = new Vector2[pathLength];
            FixedUpdate();
#endif
        }
Esempio n. 31
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();
     }
 }
        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);
            }
        }
Esempio n. 33
0
        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 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;
        }
        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 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
        }
Esempio n. 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
        }