SerializedObject and SerializedProperty are classes for editing properties on objects in a completely generic way that automatically handles undo and styling UI for prefabs.

Пример #1
6
	private static void FindMissingReferences(string context, GameObject[] objects)
	{
		foreach (var go in objects)
		{
			var components = go.GetComponents<Component>();

			foreach (var c in components)
			{
				if (!c)
				{
					Debug.LogError("Missing Component in GO: " + FullPath(go), go);
					continue;
				}

				SerializedObject so = new SerializedObject(c);
				var sp = so.GetIterator();

				while (sp.NextVisible(true))
				{
					if (sp.propertyType == SerializedPropertyType.ObjectReference)
					{
						if (sp.objectReferenceValue == null
						    && sp.objectReferenceInstanceIDValue != 0)
						{
							ShowError(context, go, c.GetType().Name, ObjectNames.NicifyVariableName(sp.name));
						}
					}
				}
			}
		}
	}
        /// <summary>
        /// Add the observer to the outfit with proper change tracking.
        /// </summary>
        /// <remarks>
        /// <para>
        /// It is safe to use this method to add an existing observer.  In this case the update will force a
        /// change record.  (Useful when the observer has already been added, but wasn't properly recorded
        /// for serialization.)
        /// </para>
        /// </remarks>
        /// <param name="outfit">The outfit. (Required)</param>
        /// <param name="observer">The observer to add, or to update so it has change tracking. (Required)</param>
        public static void AddObserverWithUndo(Outfit outfit, IOutfitObserver observer)
        {
            // Design note: Adding an observer can sometimes fail when added using the standard method.
            // Don't know why yet.  This method works in all cases.

            var obj = (Object)observer;

            var so   = new UnityEditor.SerializedObject(outfit);
            var prop = so.FindProperty("m_Observers.m_Items");
            int idx  = -1;

            for (int i = 0; i < prop.arraySize; i++)
            {
                if (prop.GetArrayElementAtIndex(i).objectReferenceValue == obj)
                {
                    prop.GetArrayElementAtIndex(idx).objectReferenceValue = null;
                    idx = i;
                    break;
                }
            }

            if (idx == -1)
            {
                idx = prop.arraySize;
                prop.arraySize++;
            }

            prop.GetArrayElementAtIndex(idx).objectReferenceValue = obj;
            so.ApplyModifiedProperties();
        }
    void OnEnable()
    {
		displayManager = target as RUISDisplayManager;
		
        displays = serializedObject.FindProperty("displays");
		ruisMenuPrefab = serializedObject.FindProperty("ruisMenuPrefab");
		
		guiX = serializedObject.FindProperty("guiX");
		guiY = serializedObject.FindProperty("guiY");
		guiZ = serializedObject.FindProperty("guiZ");
		guiScaleX = serializedObject.FindProperty("guiScaleX");
		guiScaleY = serializedObject.FindProperty("guiScaleY");
		hideMouseOnPlay = serializedObject.FindProperty("hideMouseOnPlay");
		
		displayManagerLink = new SerializedObject(displayManager);
		guiDisplayChoiceLink = displayManagerLink.FindProperty("guiDisplayChoice");
		
//        allowResolutionDialog = serializedObject.FindProperty("allowResolutionDialog");
        displayPrefab = Resources.Load("RUIS/Prefabs/Main RUIS/RUISDisplay") as GameObject;

        displayBoxStyle = new GUIStyle();
        displayBoxStyle.normal.textColor = Color.white;
        displayBoxStyle.alignment = TextAnchor.MiddleCenter;
        displayBoxStyle.border = new RectOffset(2, 2, 2, 2);
        displayBoxStyle.margin = new RectOffset(1, 0, 0, 0);
        displayBoxStyle.wordWrap = true;

        monoDisplayTexture = Resources.Load("RUIS/Editor/Textures/monodisplay") as Texture2D;
        stereoDisplayTexture = Resources.Load("RUIS/Editor/Textures/stereodisplay") as Texture2D;
		
		menuCursorPrefab = serializedObject.FindProperty("menuCursorPrefab");
		menuLayer = serializedObject.FindProperty("menuLayer");
    }
Пример #4
0
        void OnEnable () {
            serObj = new SerializedObject (target);

            screenBlendMode = serObj.FindProperty("screenBlendMode");
            hdr = serObj.FindProperty("hdr");

            sepBlurSpread = serObj.FindProperty("sepBlurSpread");
            useSrcAlphaAsMask = serObj.FindProperty("useSrcAlphaAsMask");

            bloomIntensity = serObj.FindProperty("bloomIntensity");
            bloomthreshold = serObj.FindProperty("bloomThreshold");
            bloomBlurIterations = serObj.FindProperty("bloomBlurIterations");

            lensflares = serObj.FindProperty("lensflares");

            lensflareMode = serObj.FindProperty("lensflareMode");
            hollywoodFlareBlurIterations = serObj.FindProperty("hollywoodFlareBlurIterations");
            hollyStretchWidth = serObj.FindProperty("hollyStretchWidth");
            lensflareIntensity = serObj.FindProperty("lensflareIntensity");
            lensflarethreshold = serObj.FindProperty("lensflareThreshold");
            flareColorA = serObj.FindProperty("flareColorA");
            flareColorB = serObj.FindProperty("flareColorB");
            flareColorC = serObj.FindProperty("flareColorC");
            flareColorD = serObj.FindProperty("flareColorD");
            lensFlareVignetteMask = serObj.FindProperty("lensFlareVignetteMask");

            tweakMode = serObj.FindProperty("tweakMode");
        }
Пример #5
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"));
                }
                serializedObject.ApplyModifiedProperties();
            }
            EditorGUIUtility.labelWidth = cacheWidth;
        }
Пример #6
0
//--> checkIfIDExist
    private void checkIfIDExist(SerializedProperty selectedID)
    {
        string objectPath2 = "Assets/AP/Assets/Datas/ProjectManagerDatas.asset";
        datasProjectManager _datasProjectManager = AssetDatabase.LoadAssetAtPath(objectPath2, typeof(UnityEngine.Object)) as datasProjectManager;


        string   objectPath = "Assets/AP/Assets/Resources/" + _datasProjectManager.currentDatasProjectFolder + "/TextList/wItem.asset";
        TextList _textList  = AssetDatabase.LoadAssetAtPath(objectPath, typeof(UnityEngine.Object)) as TextList;

        if (_textList)
        {
            SerializedObject serializedObject2 = new UnityEditor.SerializedObject(_textList);

            if (selectedID.intValue < serializedObject2.FindProperty("diaryList").GetArrayElementAtIndex(0).FindPropertyRelative("_languageSlot").arraySize &&
                selectedID.intValue >= 0)
            {
                SerializedProperty _Title = serializedObject2.FindProperty("diaryList").GetArrayElementAtIndex(0).FindPropertyRelative("_languageSlot").GetArrayElementAtIndex(selectedID.intValue).FindPropertyRelative("diaryTitle").GetArrayElementAtIndex(0);

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Item :", GUILayout.Width(40));
                EditorGUILayout.LabelField(_Title.stringValue.ToString());
                EditorGUILayout.EndHorizontal();
            }
            else
            {
                EditorGUILayout.HelpBox("This ID doesn't exist", MessageType.Warning);
            }
        }
    }
Пример #7
0
    private void clearSlectedCustomMethods(int value, actionsWhenPuzzleIsSolved myScript, bool b_Clear)
    {
        SerializedObject serializedObject2 = new UnityEditor.SerializedObject(myScript);

        SerializedProperty obj            = serializedObject2.FindProperty("methodsList").GetArrayElementAtIndex(value).FindPropertyRelative("obj");
        SerializedProperty scriptRef      = serializedObject2.FindProperty("methodsList").GetArrayElementAtIndex(value).FindPropertyRelative("scriptRef");
        SerializedProperty indexScript    = serializedObject2.FindProperty("methodsList").GetArrayElementAtIndex(value).FindPropertyRelative("indexScript");
        SerializedProperty indexMethod    = serializedObject2.FindProperty("methodsList").GetArrayElementAtIndex(value).FindPropertyRelative("indexMethod");
        SerializedProperty methodInfoName = serializedObject2.FindProperty("methodsList").GetArrayElementAtIndex(value).FindPropertyRelative("methodInfoName");
        SerializedProperty intValue       = serializedObject2.FindProperty("methodsList").GetArrayElementAtIndex(value).FindPropertyRelative("intValue");
        SerializedProperty floatValue     = serializedObject2.FindProperty("methodsList").GetArrayElementAtIndex(value).FindPropertyRelative("floatValue");
        SerializedProperty stringValue    = serializedObject2.FindProperty("methodsList").GetArrayElementAtIndex(value).FindPropertyRelative("stringValue");
        SerializedProperty objValue       = serializedObject2.FindProperty("methodsList").GetArrayElementAtIndex(value).FindPropertyRelative("objValue");



        serializedObject2.Update();
        if (b_Clear)
        {
            obj.objectReferenceValue = null;
        }

        scriptRef.objectReferenceValue = null;
        indexScript.intValue           = 0;
        indexMethod.intValue           = 0;
        methodInfoName.stringValue     = "";
        intValue.intValue             = 0;
        floatValue.floatValue         = 0;
        stringValue.stringValue       = "";
        objValue.objectReferenceValue = null;

        serializedObject2.ApplyModifiedProperties();
    }
Пример #8
0
    private static void HandleSortingLayer(StringBuilder sb)
    {
        sb.AppendLine("public class SortingDefine");
        sb.AppendLine("{");
        //处理预定义部分
        sb.AppendLine("\tpublic const string " + "SORTING_Default".ToUpper() + " = " + "\"Default\";");
        var asset = UnityEditor.AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset");

        if ((asset != null) && (asset.Length > 0))
        {
            for (int i = 0; i < asset.Length; i++)
            {
                var so = new UnityEditor.SerializedObject(asset[i]);

                var sortings = so.FindProperty("m_SortingLayers");
                for (int j = 0; j < sortings.arraySize; ++j)
                {
                    var item = sortings.GetArrayElementAtIndex(j).stringValue;
                    sb.AppendLine("\tpublic const string SORTING_" + item.ToUpper() + " = " + item + ";");
                }
            }
        }

        sb.AppendLine("}");
    }
Пример #9
0
        public void DrawGeneralFunction()
        {
            AmplifyShaderFunction function = ParentWindow.CurrentGraph.CurrentShaderFunction;

            if (function == null)
            {
                return;
            }

            string oldName = function.FunctionName;

            //oldName = EditorGUILayout.TextField( "Name", oldName );
            //if ( oldName != function.FunctionName )
            //{
            //	function.FunctionName = oldName;
            //	EditorUtility.SetDirty( function );
            //}

            SerializedObject serializedObject = new UnityEditor.SerializedObject(function);

            if (serializedObject != null)
            {
                SerializedProperty temo = serializedObject.FindProperty("m_description");
                oldName = temo.stringValue;
                EditorGUILayout.PropertyField(temo, new GUIContent("    Description"));
                if (!oldName.Equals(temo.stringValue))
                {
                    function.Description = temo.stringValue;
                    oldName = temo.stringValue;
                }
            }
        }
        // 导出ExportAudioTrack
        private int ExportAudioTrack(AudioTrack audioTrack, JSONObject trackListArr, JSONObject clipListArr)
        {
            JSONObject trackJSON = GenerateBaseTrack(audioTrack, PlaybaleTrackTypeMap["AudioTrack"]);

#if UNITY_2019_1_OR_NEWER
            UnityEditor.SerializedObject   serializedObject           = new UnityEditor.SerializedObject(audioTrack);
            UnityEditor.SerializedProperty propertiesserializedObject = serializedObject.FindProperty("m_TrackProperties");
            float volume       = propertiesserializedObject.FindPropertyRelative("volume").floatValue;
            float stereoPan    = propertiesserializedObject.FindPropertyRelative("stereoPan").floatValue;
            float spatialBlend = propertiesserializedObject.FindPropertyRelative("spatialBlend").floatValue;
            trackJSON.AddField("volume", volume);
            trackJSON.AddField("stereoPan", stereoPan);
            trackJSON.AddField("spatialBlend", spatialBlend);
#else
            trackJSON.AddField("volume", 1);
            trackJSON.AddField("stereoPan", 0);
            trackJSON.AddField("spatialBlend", 0);
#endif

            JSONObject clipsIndexArr = trackJSON.GetField("clips");
            IEnumerable <TimelineClip> timelineClipList = audioTrack.GetClips();
            int num = 0;
            foreach (TimelineClip timelineClip in timelineClipList)
            {
                JSONObject clipJSON = GenerateBaseTimelineClip(timelineClip, PlaybaleClipTypeMap["Audio"]);
                JSONObject clipData = new JSONObject(JSONObject.Type.OBJECT);
                clipJSON.AddField("data", clipData);

                AudioPlayableAsset asset = (AudioPlayableAsset)timelineClip.asset;
                if ((UnityEngine.Object)asset.clip != (UnityEngine.Object)null)
                {
                    WXAudioClip converter = new WXAudioClip(asset.clip, gameObject);
                    string      clipPath  = AddDependencies(converter);
                    clipData.AddField("clip", clipPath);
                }
                else
                {
                    clipData.AddField("clip", JSONObject.nullJO);
                }
                // clipData.AddField("clipCaps", ClipCapsMap.ContainsKey(timelineClip.clipCaps) ? ClipCapsMap[timelineClip.clipCaps] : ClipCapsMap[ClipCaps.None]);
                // clipData.AddField("duration", (float)asset.duration);

                // 兼容2017没有loop
                UnityEditor.SerializedObject assetSerializedObject = new UnityEditor.SerializedObject(asset);
                bool loop = assetSerializedObject.FindProperty("m_Loop").boolValue;
                clipData.AddField("loop", loop);

#if UNITY_2019_1_OR_NEWER
                UnityEditor.SerializedProperty clipProperties = assetSerializedObject.FindProperty("m_ClipProperties");
                float clipVolume = clipProperties.FindPropertyRelative("volume").floatValue;
                clipData.AddField("volume", clipVolume);
#else
                clipData.AddField("volume", 1);
#endif

                clipsIndexArr.Add(ExportTimelineClip(clipJSON, clipListArr));
                num++;
            }
            return(ExportTrack(trackJSON, trackListArr));
        }
Пример #11
0
//--> Move tile in scene view
    private void MoveTileInSceneView(int oldPosition, string direction, SlidingPuzzle myScript)
    {
        if (oldPosition != -1)
        {
            // Debug.Log("oldPosition : " + oldPosition);
            SerializedObject serializedObject2 = new UnityEditor.SerializedObject(myScript.tilesList[myScript.positionList[oldPosition]].GetComponent <Transform>());
            serializedObject2.Update();
            SerializedProperty m_Position = serializedObject2.FindProperty("m_LocalPosition");

            if (direction == "Down")
            {
                m_Position.vector3Value = new Vector3(m_Position.vector3Value.x, m_Position.vector3Value.y - .25f, 0);
            }
            if (direction == "Up")
            {
                m_Position.vector3Value = new Vector3(m_Position.vector3Value.x, m_Position.vector3Value.y + .25f, 0);
            }
            if (direction == "Left")
            {
                m_Position.vector3Value = new Vector3(m_Position.vector3Value.x - .25f, m_Position.vector3Value.y, 0);
            }
            if (direction == "Right")
            {
                m_Position.vector3Value = new Vector3(m_Position.vector3Value.x + .25f, m_Position.vector3Value.y, 0);
            }

            serializedObject2.ApplyModifiedProperties();
        }
    }
Пример #12
0
    public static SerializedProperty GetSerializedProperty(object p_object, string p_propertyName)
    {
        SerializedObject   _obj      = new UnityEditor.SerializedObject((Object)p_object);
        SerializedProperty _property = _obj.FindProperty(p_propertyName);

        return(_property);
    }
Пример #13
0
    public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
    {
        float totalHeight         = 0;
        SerializedProperty isList = property.FindPropertyRelative("m_isList");

        totalHeight += EditorGUI.GetPropertyHeight(property, label, true) + EditorGUIUtility.standardVerticalSpacing;
        totalHeight += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("m_isList"), label, true) + EditorGUIUtility.standardVerticalSpacing;
        totalHeight += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("m_isNot"), label, true) + EditorGUIUtility.standardVerticalSpacing;

        if (!isList.boolValue)
        {
            UnityEngine.Object command = property.FindPropertyRelative("m_conditionCommand").objectReferenceValue;
            if (command != null)
            {
                SerializedObject commandObject = new UnityEditor.SerializedObject(command as ConditionCommand);

                SerializedProperty propertyIterator = commandObject.GetIterator();

                while (propertyIterator.NextVisible(true))
                {
                    totalHeight += EditorGUI.GetPropertyHeight(propertyIterator, label, true) + EditorGUIUtility.standardVerticalSpacing;
                }


                SerializedProperty methodProperty = commandObject.FindProperty("m_method");

                totalHeight += EditorGUI.GetPropertyHeight(methodProperty, label, true) + EditorGUIUtility.standardVerticalSpacing;

                MethodInfo methodInfo = (command as ConditionCommand).GetType().GetMethod(methodProperty.stringValue);
                if (methodInfo != null)
                {
                    for (int i = 0; i < methodInfo.GetParameters().Length; i++)
                    {
                        ParameterInfo parametter = methodInfo.GetParameters()[i];

                        propertyIterator = commandObject.GetIterator();

                        while (propertyIterator.Next(true))
                        {
                            if (propertyIterator.name == parametter.Name)
                            {
                                totalHeight += EditorGUI.GetPropertyHeight(propertyIterator, label, true) + EditorGUIUtility.standardVerticalSpacing;
                                break;
                            }
                        }
                    }
                }
            }
        }
        else
        {
            totalHeight += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("m_isOr"), label, true) + EditorGUIUtility.standardVerticalSpacing;
            totalHeight += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("m_conditions"), label, true) + EditorGUIUtility.standardVerticalSpacing;
        }


        totalHeight += EditorGUIUtility.standardVerticalSpacing * 3;

        return(totalHeight);
    }
    public override void OnInspectorGUI()
    {
        //DrawDefaultInspector();


        CreatorScript    myscript         = (CreatorScript)target;
        SerializedObject serializedObject = new UnityEditor.SerializedObject(myscript);

        creationPosition = EditorGUILayout.Vector3Field("Creation Position", creationPosition);
        GUILayout.Space(10);
        loop         = EditorGUILayout.Toggle("Loop", loop);
        loopInterval = EditorGUILayout.IntField("Loop Interval", loopInterval);
        loopOffset   = EditorGUILayout.Vector3Field("Loop Offset", loopOffset);

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Cube", GUILayout.Width(Screen.width / 2.2f)))
        {
            myscript.MakeCube(creationPosition, loop, loopInterval, loopOffset);
        }

        if (GUILayout.Button("Quad", GUILayout.Width(Screen.width / 2.2f)))
        {
            myscript.MakeQuad(creationPosition, loop, loopInterval, loopOffset);
        }
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Capsule", GUILayout.Width(Screen.width / 2.2f)))
        {
            myscript.MakeCapsule(creationPosition, loop, loopInterval, loopOffset);
        }

        if (GUILayout.Button("Cylinder", GUILayout.Width(Screen.width / 2.2f)))
        {
            myscript.MakeCylinder(creationPosition, loop, loopInterval, loopOffset);
        }

        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Sphere", GUILayout.Width(Screen.width / 2.2f)))
        {
            myscript.MakeSphere(creationPosition, loop, loopInterval, loopOffset);
        }
        if (GUILayout.Button("Empty", GUILayout.Width(Screen.width / 2.2f)))
        {
            myscript.MakeEmpty(creationPosition, loop, loopInterval, loopOffset);
        }
        GUILayout.EndHorizontal();

        GUILayout.Space(10);

        duplicateThis     = EditorGUILayout.ObjectField("Duplicate This", duplicateThis, typeof(GameObject), true);
        duplicateOffset   = EditorGUILayout.Vector3Field("Duplicate Position Offset", duplicateOffset);
        duplicateRotation = EditorGUILayout.Vector3Field("Duplicate Rotation Offset", duplicateRotation);
        copies            = EditorGUILayout.IntField("Copies", copies);

        if (GUILayout.Button("Duplicate Special"))
        {
            myscript.DuplicateSpecial(duplicateThis as GameObject, duplicateOffset, duplicateRotation, copies);
        }
    }
Пример #15
0
        public static void FixByOneKey(string projectCode, string folder, bool isCombProj = false)
        {
            string root = Path.GetFullPath(".") + Path.DirectorySeparatorChar + "Assets" + Path.DirectorySeparatorChar;

            string searchPath = root + folder + (isCombProj ? Path.DirectorySeparatorChar + projectCode : "");

            if (!Directory.Exists(searchPath))
            {
                return;
            }

            List <string> filePath = new List <string>();

            filePath.AddRange(
                Directory.GetFiles(searchPath, "*.*", SearchOption.AllDirectories)
                );
            int counter = -1;

            foreach (string file in filePath)
            {
                string tempFolder = file.Substring(root.Length);
                EditorUtility.DisplayProgressBar("Search File", tempFolder, counter / (float)filePath.Count);
                counter++;

                string ext = Path.GetExtension(file).ToLower();
                if (ext.Equals(".mp3") || ext.Equals(".wav") || ext.Equals(".ogg") || ext.Equals(".m4a"))
                {
                    string    path          = file.Substring(file.IndexOf("Assets/"));
                    AudioClip audio         = AssetDatabase.LoadAssetAtPath <AudioClip>(path);
                    var       audioImporter = (AudioImporter)AudioImporter.GetAtPath(path);
                    var       isDirty       = false;
                    if (audio && audio.length > MAX_LENGTH &&
                        audioImporter.defaultSampleSettings.loadType != AudioClipLoadType.Streaming)
                    {
                        var setting = audioImporter.defaultSampleSettings;
                        setting.loadType = AudioClipLoadType.Streaming;
                        audioImporter.defaultSampleSettings = setting;
                        isDirty = true;
                    }
                    if (audio && audioImporter.forceToMono == false)
                    {
                        audioImporter.forceToMono = true;
                        isDirty = true;

                        SerializedObject   serializedObject = new UnityEditor.SerializedObject(audioImporter);
                        SerializedProperty normalize        = serializedObject.FindProperty("m_Normalize");
                        normalize.boolValue = false;
                        serializedObject.ApplyModifiedProperties();
                    }
                    if (isDirty)
                    {
                        audioImporter.SaveAndReimport();
                        EditorUtility.SetDirty(audio);
                    }
                }
            }

            EditorUtility.ClearProgressBar();
            AssetDatabase.Refresh();
        }
        void OnEnable()
        {
            serObj = new SerializedObject (target);

            visualizeFocus = serObj.FindProperty ("visualizeFocus");

            focalLength = serObj.FindProperty ("focalLength");
            focalSize = serObj.FindProperty ("focalSize");
            aperture = serObj.FindProperty ("aperture");
            focalTransform = serObj.FindProperty ("focalTransform");
            maxBlurSize = serObj.FindProperty ("maxBlurSize");
            highResolution = serObj.FindProperty ("highResolution");

            blurType = serObj.FindProperty ("blurType");
            blurSampleCount = serObj.FindProperty ("blurSampleCount");

            nearBlur = serObj.FindProperty ("nearBlur");
            foregroundOverlap = serObj.FindProperty ("foregroundOverlap");

            dx11BokehThreshold = serObj.FindProperty ("dx11BokehThreshold");
            dx11SpawnHeuristic = serObj.FindProperty ("dx11SpawnHeuristic");
            dx11BokehTexture = serObj.FindProperty ("dx11BokehTexture");
            dx11BokehScale = serObj.FindProperty ("dx11BokehScale");
            dx11BokehIntensity = serObj.FindProperty ("dx11BokehIntensity");
        }
Пример #17
0
    private static void HandleTag(StringBuilder sb)
    {
        sb.AppendLine("public class TagDefine");
        sb.AppendLine("{");

        //处理预定义部分
        sb.AppendLine("\tpublic const string " + "TAG_Untagged".ToUpper() + " = " + "\"Untagged\";");
        sb.AppendLine("\tpublic const string " + "TAG_Respawn".ToUpper() + " = " + "\"Respawn\";");
        sb.AppendLine("\tpublic const string " + "TAG_Finish".ToUpper() + " = " + "\"Finish\";");
        sb.AppendLine("\tpublic const string " + "TAG_EditorOnly".ToUpper() + " = " + "\"EditorOnly\";");
        sb.AppendLine("\tpublic const string " + "TAG_MainCamera".ToUpper() + "= " + "\"MainCamera\";");
        sb.AppendLine("\tpublic const string " + "TAG_Player".ToUpper() + " = " + "\"Player\";");
        sb.AppendLine("\tpublic const string " + "TAG_GameController".ToUpper() + " = " + "\"GameController\";");                    //把一部分内置Tag先写死

        var asset = UnityEditor.AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset");

        if ((asset != null) && (asset.Length > 0))
        {
            for (int i = 0; i < asset.Length; i++)
            {
                //创建序列化对象
                var so   = new UnityEditor.SerializedObject(asset[i]);
                var tags = so.FindProperty("tags");          //读取具体字段
                for (int j = 0; j < tags.arraySize; ++j)
                {
                    var item = tags.GetArrayElementAtIndex(j).stringValue;
                    sb.AppendLine("\tpublic const string TAG_" + item.ToUpper() + " = \"" + item + "\";"); //添加到模板
                }
            }
        }

        sb.AppendLine("}");
    }
Пример #18
0
        private static void SetupWrldMap(GameObject wrldMapGameobject, Camera streamingCamera, double latitudeDegrees,
                                         double longitudeDegrees, string materialDirectory)
        {
            if (wrldMapGameobject != null)
            {
                WrldMap            wrldMap = wrldMapGameobject.AddComponent <WrldMap> ();
                SerializedObject   serializedWrldMapObject          = new UnityEditor.SerializedObject(wrldMap);
                SerializedProperty streamingCameraProperty          = serializedWrldMapObject.FindProperty("m_streamingCamera");
                SerializedProperty latitudeDegreesProperty          = serializedWrldMapObject.FindProperty("m_latitudeDegrees");
                SerializedProperty longitudeDegreesProperty         = serializedWrldMapObject.FindProperty("m_longitudeDegrees");
                SerializedProperty materialDirectoryProperty        = serializedWrldMapObject.FindProperty("m_materialDirectory");
                SerializedProperty useBuiltInCameraControlsProperty = serializedWrldMapObject.FindProperty("m_useBuiltInCameraControls");

                streamingCameraProperty.objectReferenceValue = streamingCamera;
                latitudeDegreesProperty.doubleValue          = latitudeDegrees;
                longitudeDegreesProperty.doubleValue         = longitudeDegrees;
                materialDirectoryProperty.stringValue        = materialDirectory;
                useBuiltInCameraControlsProperty.boolValue   = false;

                serializedWrldMapObject.ApplyModifiedProperties();
            }
            else
            {
                Debug.LogError("WrldMap gameobject not referenced in WRLDARKitSetupHelper.");
            }
        }
 public void OnEnable()
 {
     movingPlatform = (StationaryMovingPlatform)target;
     mObj = new SerializedObject(target);
     mDuration = mObj.FindProperty("duration");
     mStationsList = mObj.FindProperty("stationList");
 }
	static void GetValues( AmplifyMotionObjectBase obj )
	{
		// if the object is a Particle System (Shuriken)
		ParticleSystem particleSystem = obj.GetComponent<ParticleSystem>();
		if ( particleSystem != null )
		{
			SerializedObject so = null;
			try
			{
				so = new SerializedObject( particleSystem );
			}
			catch
			{
				Debug.LogWarning( "[AmplifyMotion] Can't serialize particle system object " + particleSystem.name + ". Aborting." );
				return;
			}

			obj.ParticleSystemDesc.sizeOverLifeTimeActive = so.FindProperty( "SizeModule.enabled" ).boolValue;
			obj.ParticleSystemDesc.sizeBySpeedActive = so.FindProperty( "SizeBySpeedModule.enabled" ).boolValue;

			if ( obj.ParticleSystemDesc.sizeOverLifeTimeActive )
			{
				// size by lifetime
				obj.ParticleSystemDesc.curveSizeOverLifeTime = so.FindProperty( "SizeModule.curve.maxCurve" ).animationCurveValue;
			}
			if ( obj.ParticleSystemDesc.sizeBySpeedActive )
			{
				// size by speed
				obj.ParticleSystemDesc.curveBySpeed = so.FindProperty( "SizeBySpeedModule.curve.maxCurve" ).animationCurveValue;
				obj.ParticleSystemDesc.speedRangeMin = so.FindProperty( "SizeBySpeedModule.range.x" ).floatValue;
				obj.ParticleSystemDesc.speedRangeMax = so.FindProperty( "SizeBySpeedModule.range.y" ).floatValue;
			}
		}
	}
    public void OnEnable()
    {
        disableBehaviour = new SerializedObject(this.target);
        this.fireTime = disableBehaviour.FindProperty("firetime");
        this.componentsProperty = disableBehaviour.FindProperty("Behaviour");
        this.editorRevert = disableBehaviour.FindProperty("editorRevertMode");
        this.runtimeRevert = disableBehaviour.FindProperty("runtimeRevertMode");
        Component currentComponent = componentsProperty.objectReferenceValue as Component;

        DisableBehaviour behaviour = (target as DisableBehaviour);
        if (behaviour == null || behaviour.ActorTrackGroup == null || behaviour.ActorTrackGroup.Actor == null)
        {
            return;
        }
        GameObject actor = behaviour.ActorTrackGroup.Actor.gameObject;

        Component[] behaviours = DirectorHelper.getEnableableComponents(actor);
        for (int j = 0; j < behaviours.Length; j++)
        {
            if (behaviours[j] == currentComponent)
            {
                componentSelection = j;
            }
        }
    }
Пример #22
0
	protected void DrawColors ()
	{
		if (serializedObject.FindProperty("tweenTarget").objectReferenceValue == null) return;

		if (NGUIEditorTools.DrawHeader("Colors", "Colors", false, true))
		{
			NGUIEditorTools.BeginContents(true);
			NGUIEditorTools.SetLabelWidth(76f);
			UIButtonColor btn = target as UIButtonColor;

			if (btn.tweenTarget != null)
			{
				UIWidget widget = btn.tweenTarget.GetComponent<UIWidget>();

				if (widget != null)
				{
					EditorGUI.BeginDisabledGroup(serializedObject.isEditingMultipleObjects);
					{
						SerializedObject obj = new SerializedObject(widget);
						obj.Update();
						NGUIEditorTools.DrawProperty("Normal", obj, "mColor");
						obj.ApplyModifiedProperties();
					}
					EditorGUI.EndDisabledGroup();
				}
			}

			NGUIEditorTools.DrawProperty("Hover", serializedObject, "hover");
			NGUIEditorTools.DrawProperty("Pressed", serializedObject, "pressed");
			NGUIEditorTools.DrawProperty("Disabled", serializedObject, "disabledColor");
			NGUIEditorTools.EndContents();
		}
	}
Пример #23
0
    void displayTracks(MainMenu myScript, int i)
    {
        // inventoryOnlineTracks

        //EditorGUILayout.PropertyField(inventoryOnlineTracks, new GUIContent(""));

        SerializedObject serializedObject0 = new UnityEditor.SerializedObject(myScript.S_CurrentBackground.GetComponent <Image>());

        serializedObject0.Update();

        SerializedProperty m_Scale = serializedObject0.FindProperty("m_Sprite");

        if (m_Scale.objectReferenceValue != (Sprite)TableBackgroundSpriteList.GetArrayElementAtIndex(i).objectReferenceValue)
        {
            m_Scale.objectReferenceValue = null;
            m_Scale.objectReferenceValue = (Sprite)TableBackgroundSpriteList.GetArrayElementAtIndex(i).objectReferenceValue;
        }


        // if (m_Scale.objectReferenceValue != (Sprite)TableBackgroundSpriteList.GetArrayElementAtIndex(i).objectReferenceValue)
        //   m_Scale.objectReferenceValue = (Sprite)TableBackgroundSpriteList.GetArrayElementAtIndex(i).objectReferenceValue;


        serializedObject0.ApplyModifiedProperties();
    }
Пример #24
0
	protected SerializedProperty DrawProperty(SerializedObject obj,string propertyPath){
		SerializedProperty property = obj.FindProperty (propertyPath);
		if (property != null) {
			EditorGUILayout.PropertyField (property);
		}
		return property;
	}
    // Scale Shuriken particle system 
    void ScaleShurikenSystems(float scaleFactor)
    {
        #if UNITY_EDITOR
        ParticleSystem[] systems = GetComponentsInChildren<ParticleSystem>();

        foreach (ParticleSystem system in systems)
        {
            system.startSpeed *= scaleFactor;
            system.startSize *= scaleFactor;
            system.gravityModifier *= scaleFactor;

            SerializedObject so = new SerializedObject(system);

            so.FindProperty("VelocityModule.x.scalar").floatValue *= scaleFactor;
            so.FindProperty("VelocityModule.y.scalar").floatValue *= scaleFactor;
            so.FindProperty("VelocityModule.z.scalar").floatValue *= scaleFactor;
            so.FindProperty("ClampVelocityModule.magnitude.scalar").floatValue *= scaleFactor;
            so.FindProperty("ClampVelocityModule.x.scalar").floatValue *= scaleFactor;
            so.FindProperty("ClampVelocityModule.y.scalar").floatValue *= scaleFactor;
            so.FindProperty("ClampVelocityModule.z.scalar").floatValue *= scaleFactor;
            so.FindProperty("ForceModule.x.scalar").floatValue *= scaleFactor;
            so.FindProperty("ForceModule.y.scalar").floatValue *= scaleFactor;
            so.FindProperty("ForceModule.z.scalar").floatValue *= scaleFactor;
            so.FindProperty("ColorBySpeedModule.range").vector2Value *= scaleFactor;
            so.FindProperty("SizeBySpeedModule.range").vector2Value *= scaleFactor;
            so.FindProperty("RotationBySpeedModule.range").vector2Value *= scaleFactor;          

            so.ApplyModifiedProperties();
        }
        #endif
    }
Пример #26
0
 public void OnEnable()
 {
     serObj = new SerializedObject (target);
     sharedMaterial = serObj.FindProperty("sharedMaterial");
     waterQuality = serObj.FindProperty("waterQuality");
     edgeBlend = serObj.FindProperty("edgeBlend");
 }
 private bool Validate(SerializedObject serializedObject, out System.Type missingComponentType)
 {
     var c = serializedObject.targetObject as Component;
     missingComponentType = null;
     if (c == null) return true;
     return !com.spacepuppy.Utils.Assertions.AssertRequireComponentInEntityAttrib(c, out missingComponentType, true);
 }
Пример #28
0
	void OnEnable(){
		settingProfileAsset = new SerializedObject(SettingsManager.LoadMainSettings());
		selectableLayerField = AssetUtility.LoadPropertyAsInt ("layerCaster", settingProfileAsset);
		selectableLayerMask = AssetUtility.LoadPropertyAsInt("layerMask", settingProfileAsset);


	}
Пример #29
0
        /// <summary>
        /// Called when the inspector needs to draw
        /// </summary>
        public override bool OnInspectorGUI(UnityEditor.SerializedObject rTargetSO, UnityEngine.Object rTarget)
        {
            bool lIsDirty = base.OnInspectorGUI(rTargetSO, rTarget);

            if (mActorCore == null && mOwner != null)
            {
                mActorCore = mOwner.GetComponent <ActorCore>();
            }

            if (_StoredUnityEventIndex < 0)
            {
                lIsDirty = true;
                _StoredUnityEventIndex = mActorCore.StoreUnityEvent(-1, new ReactorActionEvent());
            }

            //EditorGUILayout.LabelField(_StoredUnityEventIndex.ToString() + " of " + mActorCore._StoredUnityEvents.Count);

            SerializedProperty lArray = rTargetSO.FindProperty("_StoredUnityEvents");

            if (lArray.isArray && lArray.arraySize > _StoredUnityEventIndex)
            {
                SerializedProperty lItem = lArray.GetArrayElementAtIndex(_StoredUnityEventIndex);

                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(lItem);
                if (EditorGUI.EndChangeCheck())
                {
                    lIsDirty = true;
                }
            }

            return(lIsDirty);
        }
Пример #30
0
	void OnEnable()
	{
		m_target = (AntonovSuitProbe)target;
		m_AntonovSuitProbe = new SerializedObject(target);

		m_cubemapRadius = m_AntonovSuitProbe.FindProperty("probeRadius");
		m_cubemapBoxSize = m_AntonovSuitProbe.FindProperty("probeBoxSize");

		m_diffuseSamples = m_AntonovSuitProbe.FindProperty("diffuseSamples");
		m_specularSamples = m_AntonovSuitProbe.FindProperty("specularSamples");
		
		m_cubemapFolder = m_AntonovSuitProbe.FindProperty("cubemapFolder");
		m_cubemapName = m_AntonovSuitProbe.FindProperty("cubemapName");
		m_diffuseSize = m_AntonovSuitProbe.FindProperty("diffuseSize");
		m_specularSize = m_AntonovSuitProbe.FindProperty("specularSize");
		m_smoothEdge = m_AntonovSuitProbe.FindProperty("smoothEdge");
		//m_edgeScale = m_AntonovSuitProbe.FindProperty("edgeScale");
		m_Meshes = m_AntonovSuitProbe.FindProperty("Meshes");

		m_irradianceModel = m_AntonovSuitProbe.FindProperty("irradianceModel");
		m_radianceModel = m_AntonovSuitProbe.FindProperty("radianceModel");
		m_projectionType = m_AntonovSuitProbe.FindProperty("typeOfProjection");

		m_atten = m_AntonovSuitProbe.FindProperty("useAtten");
		m_attenRadius = m_AntonovSuitProbe.FindProperty("attenSphereRadius");
		m_attenBoxSize = m_AntonovSuitProbe.FindProperty("attenBoxSize");

		m_diffuseExposure = m_AntonovSuitProbe.FindProperty("diffuseExposure");
		m_specularExposure = m_AntonovSuitProbe.FindProperty("specularExposure");

		//m_bakeDirectAndIBL = m_AntonovSuitProbe.FindProperty("bakeDirectAndIBL");
	}
        /// <summary>
        /// Checks the tags to make sure they are defined.
        /// </summary>
        /// <param name="tagManager">Tag manager.</param>
        private static void CheckTags(SerializedObject tagManager)
        {
            SerializedProperty tagsProp = tagManager.FindProperty("tags");

            for (int index = 0; index < requiredTags.Length; index++)
            {
                string tag = requiredTags[index];
                bool found = false;
                for (int i = 0; i < tagsProp.arraySize; i++)
                {
                    SerializedProperty t = tagsProp.GetArrayElementAtIndex(i);
                    if (t.stringValue == tag)
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    tagsProp.InsertArrayElementAtIndex(0);
                    SerializedProperty n = tagsProp.GetArrayElementAtIndex(0);
                    n.stringValue = tag;
                    Debug.Log("Adding tag: " + tag);
                }
            }
        }
		protected override void OnEnable()
		{
			base.OnEnable();
			
			requester = new SerializedObject(target);
			whenToRequest = requester.FindProperty("whenToRequest");
			placement = requester.FindProperty("placement");
			showsOverlayImmediately = requester.FindProperty("showsOverlayImmediately");
			rewardMayBeDelivered = requester.FindProperty("rewardMayBeDelivered");
			rewardMessageType = requester.FindProperty("rewardMessageType");
			requestDelay = requester.FindProperty("requestDelay");
			limitedUse = requester.FindProperty("limitedUse");
			maxUses = requester.FindProperty("maxUses");
			exhaustAction = requester.FindProperty("exhaustAction");
			useDefaultTestReward = requester.FindProperty("useDefaultTestReward");
			defaultTestRewardName = requester.FindProperty("defaultTestRewardName");
			defaultTestRewardQuantity = requester.FindProperty("defaultTestRewardQuantity");
			prefetch = requester.FindProperty("prefetch");
			refetchWhenUsed = requester.FindProperty("refetchWhenUsed");
			connectionForPrefetch = requester.FindProperty("connectionForPrefetch");
			//pauseGameWhenDisplayed = serializedObject.FindProperty("pauseGameWhenDisplayed");
			
			originalBackgroundColor = GUI.backgroundColor;
			
			delayRequest = requestDelay.floatValue >= DELAY_MIN;
			
			// settings
			settings = PlayHavenSettings.Get();
			RefreshPlacementList();
			RefreshRewardsList();
		}
Пример #33
0
 public static int ShowBoneMapping(int shownBodyView, AvatarControl.BodyPartFeedback bodyPartCallback, AvatarSetupTool.BoneWrapper[] bones, SerializedObject serializedObject, AvatarMappingEditor editor)
 {
   GUILayout.BeginHorizontal();
   GUILayout.FlexibleSpace();
   if ((bool) ((Object) AvatarControl.styles.Silhouettes[shownBodyView].image))
   {
     Rect rect = GUILayoutUtility.GetRect(AvatarControl.styles.Silhouettes[shownBodyView], GUIStyle.none, new GUILayoutOption[1]{ GUILayout.MaxWidth((float) AvatarControl.styles.Silhouettes[shownBodyView].image.width) });
     AvatarControl.DrawBodyParts(rect, shownBodyView, bodyPartCallback);
     for (int i = 0; i < bones.Length; ++i)
       AvatarControl.DrawBone(shownBodyView, i, rect, bones[i], serializedObject, editor);
   }
   else
     GUILayout.Label("texture missing,\nfix me!");
   GUILayout.FlexibleSpace();
   GUILayout.EndHorizontal();
   Rect lastRect = GUILayoutUtility.GetLastRect();
   string[] strArray = new string[4]{ "Body", "Head", "Left Hand", "Right Hand" };
   lastRect.x += 5f;
   lastRect.width = 70f;
   lastRect.yMin = lastRect.yMax - 69f;
   lastRect.height = 16f;
   for (int index = 0; index < strArray.Length; ++index)
   {
     if (GUI.Toggle(lastRect, shownBodyView == index, strArray[index], EditorStyles.miniButton))
       shownBodyView = index;
     lastRect.y += 16f;
   }
   return shownBodyView;
 }
	public override void OnInspectorGUI()
	{
		//target.lookAtPoint = EditorGUILayout.Vector3Field ("Look At Point", target.lookAtPoint);
		
		EditorGUIUtility.LookLikeInspector();
		DrawDefaultInspector();
		
		ParticleBurstQuantity burstScript = target as ParticleBurstQuantity; 
		
		
		if (GUILayout.Button("Sync burst data"))
		{
			foreach(ParticleSystem iteratorParticleSystem in burstScript.GetComponentsInChildren<ParticleSystem>())
			{
				ParticleBurstQuantity tempParticleBurstQuantity = iteratorParticleSystem.GetComponent<ParticleBurstQuantity>();
				
				if (tempParticleBurstQuantity == null)
					tempParticleBurstQuantity = iteratorParticleSystem.gameObject.AddComponent<ParticleBurstQuantity>();
				
				SerializedObject serializedObject = new SerializedObject(iteratorParticleSystem);
				
				SerializedProperty serializedBurst 		= serializedObject.FindProperty("EmissionModule.cnt0");
			
				tempParticleBurstQuantity.burstQuantity = serializedBurst.intValue;
			}
		}
		
		if (GUI.changed)
            EditorUtility.SetDirty (target);
    }
Пример #35
0
	public void OnEnable () {
		serObj = new SerializedObject (target); 
		
		reflectionMask = serObj.FindProperty("reflectionMask");   		
		reflectSkybox = serObj.FindProperty("reflectSkybox");   		
		clearColor = serObj.FindProperty("clearColor");   		
	}
Пример #36
0
	public void UpdateData () {
		#if UNITY_EDITOR
		UnityEditor.SerializedObject s = new UnityEditor.SerializedObject ( bitmapFont );

		info.name = s.FindProperty ( "m_Name" ).stringValue;
		info.kerning = s.FindProperty ( "m_Kerning" ).floatValue;
		info.lineSpacing = s.FindProperty ( "m_LineSpacing" ).floatValue;
		info.ascent = s.FindProperty ( "m_Ascent" ).floatValue;
		info.characterPadding = s.FindProperty ( "m_CharacterPadding" ).intValue;
		info.characterSpacing = s.FindProperty ( "m_CharacterSpacing" ).intValue;
		info.convertCase = s.FindProperty ( "m_ConvertCase" ).intValue;

		int size = s.FindProperty ( "m_CharacterRects.Array.size" ).intValue;
		info.characterRects = new OGCharacterInfo[size];

		for ( int i = 0; i < size; i++ ) {
			OGCharacterInfo ci = new OGCharacterInfo ();
			
			ci.index = s.FindProperty ( "m_CharacterRects.Array.data[" + i + "].index" ).intValue; 
			ci.uv = s.FindProperty ( "m_CharacterRects.Array.data[" + i + "].uv" ).rectValue; 
			ci.vert = s.FindProperty ( "m_CharacterRects.Array.data[" + i + "].vert" ).rectValue; 
			ci.width = s.FindProperty ( "m_CharacterRects.Array.data[" + i + "].width" ).floatValue; 
			ci.flipped = s.FindProperty ( "m_CharacterRects.Array.data[" + i + "].flipped" ).boolValue;

			info.characterRects[i] = ci;
		}
		
		atlasSize = new Vector2 ( bitmapFont.material.mainTexture.width, bitmapFont.material.mainTexture.height );
		#endif
	}
Пример #37
0
        public void Draw(Condition condition, SerializedObject serializedObject)
        {
            foldout = EditorGUILayout.Foldout(foldout, "Condition Editor");
            if (!foldout || (serializedObject == null)) return;

            serializedObject.Update();

            if (drawReferenceDatabase) {
                EditorTools.selectedDatabase = EditorGUILayout.ObjectField(new GUIContent("Reference Database", "Database to use for Lua and Quest conditions"), EditorTools.selectedDatabase, typeof(DialogueDatabase), true) as DialogueDatabase;
            }

            luaConditionWizard.database = EditorTools.selectedDatabase;
            if (luaConditionWizard.database != null) {
                if (!luaConditionWizard.IsOpen) {
                    luaConditionWizard.OpenWizard(string.Empty);
                }
                currentLuaWizardContent = luaConditionWizard.Draw(new GUIContent("Lua Condition Wizard", "Use to add Lua conditions below"), currentLuaWizardContent, false);
                if (!luaConditionWizard.IsOpen && !string.IsNullOrEmpty(currentLuaWizardContent)) {
                    List<string> luaList = new List<string>(condition.luaConditions);
                    luaList.Add(currentLuaWizardContent);
                    condition.luaConditions = luaList.ToArray();
                    currentLuaWizardContent = string.Empty;
                    luaConditionWizard.OpenWizard(string.Empty);
                }
            }

            EditorWindowTools.StartIndentedSection();

            SerializedProperty conditions = serializedObject.FindProperty("condition");
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(conditions, true);
            if (EditorGUI.EndChangeCheck()) serializedObject.ApplyModifiedProperties();

            EditorWindowTools.EndIndentedSection();
        }
Пример #38
0
        public override void ShowGUI()
        {
            if (this == null)
            {
                return;
            }

            var serializedObject = new UnityEditor.SerializedObject(this);

            serializedObject.Update();
            SerializedProperty eventProperty = serializedObject.FindProperty("unityEvent");

            EditorGUILayout.PropertyField(eventProperty, true);

            ignoreWhenSkipping = EditorGUILayout.Toggle("Ignore when skipping?", ignoreWhenSkipping);
            if (ignoreWhenSkipping)
            {
                SerializedProperty skipEventProperty = serializedObject.FindProperty("skipEvent");
                EditorGUILayout.PropertyField(skipEventProperty, true);
            }

            serializedObject.ApplyModifiedProperties();

            EditorGUILayout.HelpBox("Parameters passed from here cannot be set, unfortunately, due to a Unity limitation.", MessageType.Warning);

            AfterRunningOption();
        }
Пример #39
0
    void RemoveACar(int value)
    {
        // --> Find and Pause Cars
        GameObject[] arrCars = GameObject.FindGameObjectsWithTag("Car");

        List <GameObject> tmpList = new List <GameObject> ();

        foreach (GameObject car in arrCars)
        {
            if (car.GetComponent <CarController> () && car.GetComponent <CarController> ().playerNumber == (value + 1))
            {
                tmpList.Add(car);
            }
        }

        for (var i = tmpList.Count - 1; i >= 0; i--)
        {
            Undo.DestroyObjectImmediate(tmpList[i]);
        }
        tmpList.Clear();

        SerializedObject serializedObject0 = new UnityEditor.SerializedObject(inventoryItemList);

        serializedObject0.Update();
        SerializedProperty m_carName = serializedObject0.FindProperty("inventoryItem").GetArrayElementAtIndex(0).FindPropertyRelative("list_Cars");


        if (inventoryItemList)
        {
            m_carName.GetArrayElementAtIndex(value).objectReferenceValue = null;
        }
        serializedObject0.ApplyModifiedProperties();
    }
Пример #40
0
    void ScaleLegacySystems(float scaleFactor)
    {
        //get all emitters we need to do scaling on
        ParticleEmitter[] emitters = GetComponentsInChildren<ParticleEmitter>();

        //get all animators we need to do scaling on
        ParticleAnimator[] animators = GetComponentsInChildren<ParticleAnimator>();

        //apply scaling to emitters
        foreach (ParticleEmitter emitter in emitters)
        {
            emitter.minSize *= scaleFactor;
            emitter.maxSize *= scaleFactor;
            emitter.worldVelocity *= scaleFactor;
            emitter.localVelocity *= scaleFactor;
            emitter.rndVelocity *= scaleFactor;

            //some variables cannot be accessed through regular script, we will acces them through a serialized object
            SerializedObject so = new SerializedObject(emitter);

            so.FindProperty("m_Ellipsoid").vector3Value *= scaleFactor;
            so.FindProperty("tangentVelocity").vector3Value *= scaleFactor;
            so.ApplyModifiedProperties();
        }

        //apply scaling to animators
        foreach (ParticleAnimator animator in animators)
        {
            animator.force *= scaleFactor;
            animator.rndForce *= scaleFactor;
        }
    }
Пример #41
0
    public static void UpgradeSkies()
    {
        Undo.RegisterSceneUndo("Upgrade Skies");
        Component[] all = GameObject.FindObjectsOfType(typeof(Transform)) as Component[];

        //Create a dummy game object, add a namespaced Sky to it, find its serialized script type
        GameObject refObj = new GameObject("_dummy_sky");
        mset.Sky refSky = refObj.AddComponent<mset.Sky>();
        SerializedObject refSr = new SerializedObject(refSky);
        SerializedProperty scriptType = refSr.FindProperty("m_Script");

        int count = 0;
        //Find all old sky objects, swap out the Sky script references to mset.Sky
        for(int i=0; i<all.Length; ++i) {
            GameObject obj = all[i].gameObject;
            if(obj) {
                Sky old = obj.GetComponent<Sky>() as Sky;
                if(old != null) {
                    SerializedObject sr = new SerializedObject(old);
                    sr.CopyFromSerializedProperty(scriptType);
                    sr.ApplyModifiedProperties();
                    count++;
                }
            }
        }
        if( count == 0 ) {
            EditorUtility.DisplayDialog("Done Upgrading!", "No deprecated skies found.\n\nPro Tip: Don't forget to use the \"mset\" namespace when scripting with the Sky class.", "Ok");
        } else {
            EditorUtility.DisplayDialog("Done Upgrading!", count + " deprecated skies found and upgraded.\n\nPro Tip: Don't forget to use the \"mset\" namespace when scripting with the Sky class.", "Ok");
        }
        Component.DestroyImmediate(refObj);
    }
Пример #42
0
    void OnEnable()
    {
        srcObj = new SerializedObject(target);

        strength = srcObj.FindProperty("strength");
        clamp = srcObj.FindProperty("clamp");
    }
	public EditorLayerData(SerializedObject manager,SerializedProperty property,string layerName,int id,bool hide){
		LayerID=id;
		Manager=manager;
		Property=property;
		LayerName=layerName;
		HideFromCameras=hide;
	}
    public void ShurikenParticleScaleChange(float _Value)
    {
        ParticleSystem[] ParticleSystems = GetComponentsInChildren<ParticleSystem>();

        transform.localScale *= _Value;

        foreach(ParticleSystem _ParticleSystem in ParticleSystems) {
            _ParticleSystem.startSpeed *= _Value;
            _ParticleSystem.startSize *= _Value;
            _ParticleSystem.gravityModifier *= _Value;
            SerializedObject _SerializedObject = new SerializedObject(_ParticleSystem);
            _SerializedObject.FindProperty("CollisionModule.particleRadius").floatValue *= _Value;
            _SerializedObject.FindProperty("ShapeModule.radius").floatValue *= _Value;
            _SerializedObject.FindProperty("ShapeModule.boxX").floatValue *= _Value;
            _SerializedObject.FindProperty("ShapeModule.boxY").floatValue *= _Value;
            _SerializedObject.FindProperty("ShapeModule.boxZ").floatValue *= _Value;
            _SerializedObject.FindProperty("VelocityModule.x.scalar").floatValue *= _Value;
            _SerializedObject.FindProperty("VelocityModule.y.scalar").floatValue *= _Value;
            _SerializedObject.FindProperty("VelocityModule.z.scalar").floatValue *= _Value;
            _SerializedObject.FindProperty("ClampVelocityModule.x.scalar").floatValue *= _Value;
            _SerializedObject.FindProperty("ClampVelocityModule.y.scalar").floatValue *= _Value;
            _SerializedObject.FindProperty("ClampVelocityModule.z.scalar").floatValue *= _Value;
            _SerializedObject.FindProperty("ClampVelocityModule.magnitude.scalar").floatValue *= _Value;
            _SerializedObject.ApplyModifiedProperties();
        }
    }
Пример #45
0
    //Change Color
    private void applyColor()
    {
        foreach(GameObject go in Selection.gameObjects)
        {
            ParticleSystem[] systems;
            if(IncludeChildren)		systems = go.GetComponentsInChildren<ParticleSystem>(true);
            else 					systems = go.GetComponents<ParticleSystem>();

            foreach(ParticleSystem ps in systems)
            {
                SerializedObject psSerial = new SerializedObject(ps);
                if(!AffectAlpha)
                {
                    psSerial.FindProperty("InitialModule.startColor.maxColor").colorValue = new Color(ColorValue.r, ColorValue.g, ColorValue.b, psSerial.FindProperty("InitialModule.startColor.maxColor").colorValue.a);
                    psSerial.FindProperty("InitialModule.startColor.minColor").colorValue = new Color(ColorValue2.r, ColorValue2.g, ColorValue2.b, psSerial.FindProperty("InitialModule.startColor.minColor").colorValue.a);
                }
                else
                {
                    psSerial.FindProperty("InitialModule.startColor.maxColor").colorValue = ColorValue;
                    psSerial.FindProperty("InitialModule.startColor.minColor").colorValue = ColorValue2;
                }
                psSerial.ApplyModifiedProperties();
            }
        }
    }
Пример #46
0
	void OnEnable()
	{
		srcObj = new SerializedObject(target);

		displace = srcObj.FindProperty("displace");
		amount = srcObj.FindProperty("amount");
	}
    void OnEnable()
    {
        srcObj = new SerializedObject(target);

        sharpness = srcObj.FindProperty("sharpness");
        darkness = srcObj.FindProperty("darkness");
    }
Пример #48
0
	public static void Initialize (PlaygroundC targetRef) {
		playgroundScriptReference = targetRef;
		PlaygroundC.reference = targetRef;
		if (playgroundScriptReference==null) return;
		playground = new SerializedObject(playgroundScriptReference);
		particleSystems = playground.FindProperty("particleSystems");
		manipulators = playground.FindProperty("manipulators");
		calculate = playground.FindProperty("calculate");
		pixelFilterMode = playground.FindProperty("pixelFilterMode");
		autoGroup = playground.FindProperty("autoGroup");
		buildZeroAlphaPixels = playground.FindProperty("buildZeroAlphaPixels");
		drawGizmos = playground.FindProperty("drawGizmos");
		drawSourcePositions = playground.FindProperty("drawSourcePositions");
		drawWireframe = playground.FindProperty("drawWireframe");
		drawSplinePreview = playground.FindProperty("drawSplinePreview");
		paintToolbox = playground.FindProperty("paintToolbox");
		showShuriken = playground.FindProperty("showShuriken");
		showSnapshots = playground.FindProperty("showSnapshotsInHierarchy");
		threads = playground.FindProperty("threadMethod");
		threadsTurbulence = playground.FindProperty("turbulenceThreadMethod");
		threadsSkinned = playground.FindProperty("skinnedMeshThreadMethod");
		maxThreads = playground.FindProperty("maxThreads");
		
		playgroundSettings = PlaygroundSettingsC.GetReference();
		playgroundLanguage = PlaygroundSettingsC.GetLanguage();
	}
Пример #49
0
        /// <summary>
        /// Called when the inspector needs to draw
        /// </summary>
        public virtual bool OnInspectorGUI(UnityEditor.SerializedObject rTargetSO, UnityEngine.Object rTarget)
        {
            bool lIsDirty = false;

            GUILayout.Space(3f);

            if (_EditorShowActivationType)
            {
                if (EditorHelper.PopUpField("Activation Type", "Determines how the reactor is activate", ActivationType, ReactorAction.ACTIVATION_STYLES, rTarget))
                {
                    lIsDirty       = true;
                    ActivationType = EditorHelper.FieldIntValue;
                }

                // State set
                if (_ActivationType == 1)
                {
                    if (EditorHelper.TextField("State", "Name of the state that is being tested.", ActivationStateName, rTarget))
                    {
                        lIsDirty            = true;
                        ActivationStateName = EditorHelper.FieldStringValue;
                    }

                    if (EditorHelper.IntField("Value", "New value of the state that is being set.", ActivationValue, rTarget))
                    {
                        lIsDirty        = true;
                        ActivationValue = EditorHelper.FieldIntValue;
                    }
                }
                // State changed
                else if (_ActivationType == 2)
                {
                    if (EditorHelper.TextField("State", "Name of the state that is being tested.", ActivationStateName, rTarget))
                    {
                        lIsDirty            = true;
                        ActivationStateName = EditorHelper.FieldStringValue;
                    }

                    if (EditorHelper.IntField("Value", "Old value of the state that is being changed.", ActivationValue, rTarget))
                    {
                        lIsDirty        = true;
                        ActivationValue = EditorHelper.FieldIntValue;
                    }
                }
                // Message received
                else if (_ActivationType == 0)
                {
                    if (EditorHelper.IntField("Message ID", "Message ID to look for and activate on. If 0, all messages will be tested.", ActivationValue, rTarget))
                    {
                        lIsDirty        = true;
                        ActivationValue = EditorHelper.FieldIntValue;
                    }
                }

                EditorHelper.DrawLine();
            }

            return(lIsDirty);
        }
Пример #50
0
    UnityEditor.SerializedObject dlb_halo;     // effet d'une aura autour du joueur pour indiquer si il est sous l'effet d'un bonus

    void Start()
    {
        dlb_gameManager = GameObject.Find("GameManager").GetComponent <dlb_GameManager>();

        dlb_rb = GetComponent <Rigidbody2D>();

        dlb_halo = new SerializedObject(gameObject.GetComponent("Halo"));         // dlb_halo = (Behaviour)GetComponent("Halo");
    }
Пример #51
0
    void LoadCar()
    {
        // --> Find and Pause Cars
        GameObject[] arrCars = GameObject.FindGameObjectsWithTag("Car");


        List <GameObject> tmpList = new List <GameObject> ();

        foreach (GameObject car in arrCars)
        {
            if (car.GetComponent <CarController> ())
            {
                tmpList.Add(car);
            }
        }
        for (var i = tmpList.Count - 1; i >= 0; i--)
        {
            //Debug.Log(arrCars.Length + " : " +  arrCars[i].name);
            Undo.DestroyObjectImmediate(tmpList[i]);
        }
        tmpList.Clear();


        for (var i = 0; i < 4; i++)
        {
            SerializedObject serializedObject0 = new UnityEditor.SerializedObject(inventoryItemList);
            serializedObject0.Update();
            SerializedProperty m_carName    = serializedObject0.FindProperty("inventoryItem").GetArrayElementAtIndex(0).FindPropertyRelative("list_Cars");
            SerializedProperty m_PlayerType = serializedObject0.FindProperty("inventoryItem").GetArrayElementAtIndex(0).FindPropertyRelative("list_playerType");

            if (inventoryItemList)
            {
                if (m_carName.GetArrayElementAtIndex(i).objectReferenceValue != null)
                {
                    GameObject instance = (GameObject)Instantiate(m_carName.GetArrayElementAtIndex(i).objectReferenceValue);

                    Undo.RegisterCreatedObjectUndo(instance, instance.name);

                    instance.name = instance.name.Replace("(Clone)", "");

                    GameObject tmpPosition = GameObject.Find("Start_Position_0" + (i + 1));

                    if (tmpPosition)
                    {
                        Undo.RegisterFullObjectHierarchyUndo(instance, "Pos_" + instance.name);

                        instance.GetComponent <CarController> ().playerNumber = i + 1;                                                                  // Select the player number

                        instance.GetComponent <CarAI>().enabled = m_PlayerType.GetArrayElementAtIndex(i).boolValue;

                        instance.transform.position    = new Vector3(tmpPosition.transform.position.x, tmpPosition.transform.position.y + .15f, tmpPosition.transform.position.z);
                        instance.transform.eulerAngles = tmpPosition.transform.eulerAngles;
                    }
                }
            }
            serializedObject0.ApplyModifiedProperties();
        }
    }
Пример #52
0
    public virtual void OnDrawEditSettings()
    {
        //Poly
        SerializedObject   serializedObject = new UnityEditor.SerializedObject(area2d);
        SerializedProperty serializedLine   = serializedObject.FindProperty("_poly");

        EditorGUILayout.PropertyField(serializedLine);
        serializedObject.ApplyModifiedProperties();
    }
Пример #53
0
        public static int GetLocalIdentfierInFile(Object comp)
        {
            var inspectorModeInfo = typeof(UnityEditor.SerializedObject).GetProperty("inspectorMode", BindingFlags.NonPublic | BindingFlags.Instance);

            UnityEditor.SerializedObject serializedObject = new UnityEditor.SerializedObject(comp);
            inspectorModeInfo.SetValue(serializedObject, UnityEditor.InspectorMode.Debug, null);
            UnityEditor.SerializedProperty localIdProp = serializedObject.FindProperty("m_LocalIdentfierInFile");

            return(localIdProp.intValue);
        }
Пример #54
0
    public static void ShowWindow()
    {
        EditorWindow a   = EditorWindow.GetWindow(typeof(FontReplacer), true, "Font Replacer");
        var          obj = ScriptableObject.CreateInstance <MyFont>();
        var          serializedObject = new UnityEditor.SerializedObject(obj);

        sp = serializedObject.FindProperty("font");

        Debug.Log("font " + sp.propertyType + " >> " + a);
    }
Пример #55
0
        public float GetLegStretch(Avatar avatar)
        {
            if (avatar == null)
            {
                return(0f);
            }
            var serializedObject = new UnityEditor.SerializedObject(avatar);
            var pLegStretch      = serializedObject.FindProperty("m_Avatar.m_Human.data.m_LegStretch");

            return(pLegStretch.floatValue);
        }
Пример #56
0
        public bool GetHasTDoF(Avatar avatar)
        {
            if (avatar == null)
            {
                return(false);
            }
            var serializedObject = new UnityEditor.SerializedObject(avatar);
            var pHasTDoF         = serializedObject.FindProperty("m_Avatar.m_Human.data.m_HasTDoF");

            return(pHasTDoF.boolValue);
        }
Пример #57
0
        protected override void DrawFoldouts(UnityEditor.SerializedObject m_Object, AIBehaviors fsm)
        {
            base.DrawFoldouts(m_Object, fsm);

            if (DrawFoldout("cooldownFoldout", "Cooldown Properties:"))
            {
                DrawCooldownProperties(m_Object, fsm);
            }

            EditorGUILayout.Separator();
        }
Пример #58
0
        public float GetLowerLegTwist(Avatar avatar)
        {
            if (avatar == null)
            {
                return(0f);
            }
            var serializedObject = new UnityEditor.SerializedObject(avatar);
            var p = serializedObject.FindProperty("m_Avatar.m_Human.data.m_LegTwist");

            return(p.floatValue);
        }
Пример #59
0
        public float GetFeetSpacing(Avatar avatar)
        {
            if (avatar == null)
            {
                return(0f);
            }
            var serializedObject = new UnityEditor.SerializedObject(avatar);
            var p = serializedObject.FindProperty("m_Avatar.m_Human.data.m_FeetSpacing");

            return(p.floatValue);
        }
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        var user = ScriptableObject.CreateInstance <UserSO>();

        user.user = new UserDummy();
        var realUser = property.serializedObject.targetObject as UIStateManager;

        if (realUser)
        {
            try
            {
                if (Application.isPlaying)
                {
                    using (var userSelector = UISelectorFactory.createSelector <UnityUser>(SessionStateContext <UnityUser, LinkPermission> .current, nameof(ISessionStateDataProvider <UnityUser, LinkPermission> .user)))
                    {
                        user.user.AccessToken = userSelector.GetValue().AccessToken;
                        user.user.DisplayName = userSelector.GetValue().DisplayName;
                        user.user.UserId      = userSelector.GetValue().UserId;
                        m_valid = true;
                    }
                }
            }
            catch (Exception)
            {
                m_valid = false;
            }
        }

        SerializedObject serializedObject = new UnityEditor.SerializedObject(user);

        SerializedProperty serializedPropertyUser = serializedObject.FindProperty("user");

        EditorGUI.BeginProperty(position, label, property);

        EditorGUI.LabelField(new Rect(position.x, position.y, position.width, 16), label);

        if (m_valid)
        {
            var tokenRect  = new Rect(position.x, position.y + 18, position.width, 16);
            var nameRect   = new Rect(position.x, position.y + 36, position.width, 16);
            var userIdRect = new Rect(position.x, position.y + 54, position.width, 16);

            EditorGUI.indentLevel++;

            EditorGUI.PropertyField(tokenRect, serializedPropertyUser.FindPropertyRelative("AccessToken"));
            EditorGUI.PropertyField(nameRect, serializedPropertyUser.FindPropertyRelative("DisplayName"));
            EditorGUI.PropertyField(userIdRect, serializedPropertyUser.FindPropertyRelative("UserId"));

            EditorGUI.indentLevel--;
        }
        EditorGUI.EndProperty();

        ScriptableObject.DestroyImmediate(user);
    }