Пример #1
0
        public override void OnPaintInspectorGUI()
        {
            m_SerializedObject.UpdateIfRequiredOrScript();
            prefabBrush.index = EditorGUILayout.IntField("Index", prefabBrush.index);

            EditorGUILayout.PropertyField(m_Prefabs, true);
            m_SerializedObject.ApplyModifiedPropertiesWithoutUndo();
        }
Пример #2
0
        public override void OnPaintInspectorGUI()
        {
            m_SerializedObject.UpdateIfRequiredOrScript();
            prefabBrush.currentBrush = (TileType)EditorGUILayout.EnumPopup("Brush Type", prefabBrush.currentBrush);

            EditorGUILayout.PropertyField(m_Prefabs, true);
            m_SerializedObject.ApplyModifiedPropertiesWithoutUndo();
        }
Пример #3
0
 public void Sort()
 {
     UnityEditor.SerializedObject serializedObject = new UnityEditor.SerializedObject(this);
     data.Sort(new ReferenceCollectorDataComparer());
     UnityEditor.EditorUtility.SetDirty(this);
     serializedObject.ApplyModifiedProperties();
     serializedObject.UpdateIfRequiredOrScript();
 }
Пример #4
0
        public override void OnPaintInspectorGUI()
        {
            m_SerializedObject.UpdateIfRequiredOrScript();
            prefabBrush.m_PerlinScale = EditorGUILayout.Slider("Perlin Scale", prefabBrush.m_PerlinScale, 0.001f, 0.999f);
            prefabBrush.m_Z           = EditorGUILayout.IntField("Position Z", prefabBrush.m_Z);

            EditorGUILayout.PropertyField(m_Prefabs, true);
            m_SerializedObject.ApplyModifiedPropertiesWithoutUndo();
        }
Пример #5
0
        public override void OnPaintInspectorGUI()
        {
            m_SerializedObject.UpdateIfRequiredOrScript();
            cellBrush.m_PerlinScale = EditorGUILayout.Slider("Perlin Scale", cellBrush.m_PerlinScale, 0.001f, 0.999f);
            cellBrush.m_Z           = EditorGUILayout.IntField("Position Z", cellBrush.m_Z);
            cellBrush.allowOverlap  = EditorGUILayout.Toggle("Allow Overlap", cellBrush.allowOverlap);

            m_SerializedObject.ApplyModifiedPropertiesWithoutUndo();
        }
        public override void OnPaintInspectorGUI()
        {
            m_SerializedObject.UpdateIfRequiredOrScript();
            prefabBrush.m_Index = EditorGUILayout.IntSlider("Index to spawn", prefabBrush.m_Index, 0, prefabBrush.m_Prefabs.Length - 1);
            prefabBrush.m_Z     = EditorGUILayout.IntField("Position Z", prefabBrush.m_Z);

            EditorGUILayout.PropertyField(m_Prefabs, true);
            m_SerializedObject.ApplyModifiedPropertiesWithoutUndo();
        }
Пример #7
0
        public override void OnPaintInspectorGUI()
        {
            m_SerializedObject.UpdateIfRequiredOrScript();
//			prefabBrush.m_PerlinScale = EditorGUILayout.Slider("Perlin Scale", prefabBrush.m_PerlinScale, 0.001f, 0.999f);
            prefabBrush.m_Z        = EditorGUILayout.IntField("Position Z", prefabBrush.m_Z);
            prefabBrush.m_Amount   = (EditorGUILayout.IntSlider("Amount", prefabBrush.m_Amount, 5, 500) / 5) * 5;
            prefabBrush.m_ItemType = (ItemType)EditorGUILayout.EnumPopup("ItemType", prefabBrush.m_ItemType);

            EditorGUILayout.PropertyField(m_Prefabs, true);
            m_SerializedObject.ApplyModifiedPropertiesWithoutUndo();
        }
 public void UpdateProperties()
 {
     // Check the system was not destroyed such as by an Undo operation.
     if (m_ParticleSystemSerializedObject.targetObject != null)
     {
         m_ParticleSystemSerializedObject.UpdateIfRequiredOrScript();
     }
     if (m_RendererSerializedObject != null && m_RendererSerializedObject.targetObject != null)
     {
         m_RendererSerializedObject.UpdateIfRequiredOrScript();
     }
 }
Пример #9
0
    public void Clear()
    {
        UnityEditor.SerializedObject serializedObject = new UnityEditor.SerializedObject(this);
        //根据PropertyPath读取prefab文件中的数据
        //如果不知道具体的格式,可以直接右键用文本编辑器打开,搜索data就能找到
        var dataProperty = serializedObject.FindProperty("data");

        dataProperty.ClearArray();
        UnityEditor.EditorUtility.SetDirty(this);
        serializedObject.ApplyModifiedProperties();
        serializedObject.UpdateIfRequiredOrScript();
    }
Пример #10
0
        public override void OnPaintInspectorGUI()
        {
            serializedObject.Update();
            _serializedObject.UpdateIfRequiredOrScript();

            EditorGUILayout.PropertyField(_event, true);

            if (GUILayout.Button("要素更新"))
            {
                ElementEnumUpdate();
            }

            _serializedObject.ApplyModifiedPropertiesWithoutUndo();
            serializedObject.ApplyModifiedProperties();
        }
Пример #11
0
        public override void OnPaintInspectorGUI()
        {
            OnInspectorGUI();

            serializedObject.Update();
            _serializedObject.UpdateIfRequiredOrScript();

            _enumList.DoLayoutList();

            if (GUILayout.Button("要素更新"))
            {
                ElementEnumUpdate();
            }

            _serializedObject.ApplyModifiedPropertiesWithoutUndo();
            serializedObject.ApplyModifiedProperties();
        }
Пример #12
0
        public override void OnPaintInspectorGUI()
        {
            m_SerializedObject.UpdateIfRequiredOrScript();

            prefabBrush.index      = EditorGUILayout.IntPopup("Selected Prefab", prefabBrush.index, options.ToArray(), optionsIndex.ToArray()); //Selectable prefab to paint
            prefabBrush.m_Rotation = EditorGUILayout.IntSlider("Rotation", prefabBrush.m_Rotation, 0, 359);                                     // Selectable rotation of our prefab

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();

            prefabBrush.m_Z           = EditorGUILayout.IntField("Position Z", prefabBrush.m_Z);
            prefabBrush.m_PerlinScale = EditorGUILayout.Slider("Perlin Scale", prefabBrush.m_PerlinScale, 0.001f, 0.999f);



            EditorGUILayout.PropertyField(m_Prefabs, true);
            m_SerializedObject.ApplyModifiedPropertiesWithoutUndo();
        }
Пример #13
0
        internal static bool DoDrawDefaultInspector(SerializedObject obj)
        {
            EditorGUI.BeginChangeCheck();
            obj.UpdateIfRequiredOrScript();

            // Loop through properties and create one field (including children) for each top level property.
            SerializedProperty property = obj.GetIterator();
            bool expanded = true;
            while (property.NextVisible(expanded))
            {
                using (new EditorGUI.DisabledScope("m_Script" == property.propertyPath))
                {
                    EditorGUILayout.PropertyField(property, true);
                }
                expanded = false;
            }

            obj.ApplyModifiedProperties();
            return EditorGUI.EndChangeCheck();
        }
Пример #14
0
    //删除元素,知识点与上面的添加相似
    public void Remove(string key)
    {
        UnityEditor.SerializedObject   serializedObject = new UnityEditor.SerializedObject(this);
        UnityEditor.SerializedProperty dataProperty     = serializedObject.FindProperty("data");
        int i;

        for (i = 0; i < data.Count; i++)
        {
            if (data[i].key == key)
            {
                break;
            }
        }
        if (i != data.Count)
        {
            dataProperty.DeleteArrayElementAtIndex(i);
        }
        UnityEditor.EditorUtility.SetDirty(this);
        serializedObject.ApplyModifiedProperties();
        serializedObject.UpdateIfRequiredOrScript();
    }
Пример #15
0
    //添加新的元素
    public void Add(string key, Object obj)
    {
        UnityEditor.SerializedObject serializedObject = new UnityEditor.SerializedObject(this);
        //根据PropertyPath读取数据
        //如果不知道具体的格式,可以右键用文本编辑器打开一个prefab文件(如Bundles/UI目录中的几个)
        //因为这几个prefab挂载了ReferenceCollector,所以搜索data就能找到存储的数据
        UnityEditor.SerializedProperty dataProperty = serializedObject.FindProperty("data");
        int i;

        //遍历data,看添加的数据是否存在相同key
        for (i = 0; i < data.Count; i++)
        {
            if (data[i].key == key)
            {
                break;
            }
        }
        //不等于data.Count意为已经存在于data List中,直接赋值即可
        if (i != data.Count)
        {
            //根据i的值获取dataProperty,也就是data中的对应ReferenceCollectorData,不过在这里,是对Property进行的读取,有点类似json或者xml的节点
            UnityEditor.SerializedProperty element = dataProperty.GetArrayElementAtIndex(i);
            //对对应节点进行赋值,值为gameobject相对应的fileID
            //fileID独一无二,单对单关系,其他挂载在这个gameobject上的script或组件会保存相对应的fileID
            element.FindPropertyRelative("gameObject").objectReferenceValue = obj;
        }
        else
        {
            //等于则说明key在data中无对应元素,所以得向其插入新的元素
            dataProperty.InsertArrayElementAtIndex(i);
            UnityEditor.SerializedProperty element = dataProperty.GetArrayElementAtIndex(i);
            element.FindPropertyRelative("key").stringValue = key;
            element.FindPropertyRelative("gameObject").objectReferenceValue = obj;
        }
        //应用与更新
        UnityEditor.EditorUtility.SetDirty(this);
        serializedObject.ApplyModifiedProperties();
        serializedObject.UpdateIfRequiredOrScript();
    }
Пример #16
0
 public bool Update()
 {
     return(m_Object != null?m_SerializedObject.UpdateIfRequiredOrScript() : false);
 }
Пример #17
0
        private void DrawGUI()
        {
            if (m_RenderSettings == null || m_RenderSettings.targetObject != RenderSettings.GetRenderSettings())
            {
                InitSettings();
            }

            m_RenderSettings.UpdateIfRequiredOrScript();

            Material skyboxMaterial = m_SkyboxMaterial.objectReferenceValue as Material;

            m_bShowEnvironment = EditorGUILayout.FoldoutTitlebar(m_bShowEnvironment, Styles.env_top, true);

            if (m_bShowEnvironment)
            {
                EditorGUI.indentLevel++;

                EditorGUILayout.PropertyField(m_SkyboxMaterial, Styles.env_skybox_mat);
                if (skyboxMaterial && !EditorMaterialUtility.IsBackgroundMaterial(skyboxMaterial))
                {
                    EditorGUILayout.HelpBox(Styles.skyboxWarning.text, MessageType.Warning);
                }

                EditorGUILayout.PropertyField(m_Sun, Styles.env_skybox_sun);
                EditorGUILayout.Space();

                EditorGUILayout.LabelField(Styles.env_amb_top);
                EditorGUI.indentLevel++;

                EditorGUILayout.IntPopup(m_AmbientSource, Styles.kFullAmbientSource, Styles.kFullAmbientSourceValues, Styles.env_amb_src);
                switch ((AmbientMode)m_AmbientSource.intValue)
                {
                case AmbientMode.Trilight:
                {
                    EditorGUI.BeginChangeCheck();
                    Color newValueUp   = EditorGUILayout.ColorField(Styles.ambientUp, m_AmbientSkyColor.colorValue, true, false, true);
                    Color newValueMid  = EditorGUILayout.ColorField(Styles.ambientMid, m_AmbientEquatorColor.colorValue, true, false, true);
                    Color newValueDown = EditorGUILayout.ColorField(Styles.ambientDown, m_AmbientGroundColor.colorValue, true, false, true);
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_AmbientSkyColor.colorValue     = newValueUp;
                        m_AmbientEquatorColor.colorValue = newValueMid;
                        m_AmbientGroundColor.colorValue  = newValueDown;
                    }
                }
                break;

                case AmbientMode.Flat:
                {
                    EditorGUI.BeginChangeCheck();
                    Color newValue = EditorGUILayout.ColorField(Styles.ambient, m_AmbientSkyColor.colorValue, true, false, true);
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_AmbientSkyColor.colorValue = newValue;
                    }
                }
                break;

                case AmbientMode.Skybox:
                    if (skyboxMaterial == null)
                    {
                        EditorGUI.BeginChangeCheck();
                        Color newValue = EditorGUILayout.ColorField(Styles.ambient, m_AmbientSkyColor.colorValue, true, false, true);
                        if (EditorGUI.EndChangeCheck())
                        {
                            m_AmbientSkyColor.colorValue = newValue;
                        }
                    }
                    else
                    {
                        // Ambient intensity - maximum is kEmissiveRGBMMax
                        EditorGUILayout.Slider(m_AmbientIntensity, 0.0F, 8.0F, Styles.env_amb_int);
                    }
                    break;
                }

                // ambient GI - realtime / baked
                bool realtimeGISupported = SupportedRenderingFeatures.IsLightmapBakeTypeSupported(LightmapBakeType.Realtime);
                bool bakedGISupported    = SupportedRenderingFeatures.IsLightmapBakeTypeSupported(LightmapBakeType.Baked);

                if ((m_EnabledBakedGI.boolValue || m_EnabledRealtimeGI.boolValue) && (bakedGISupported || realtimeGISupported))
                {
                    int[] modeVals = { 0, 1 };

                    if (m_EnabledBakedGI.boolValue && m_EnabledRealtimeGI.boolValue)
                    {
                        // if the user has selected the only state that is supported, then gray it out
                        using (new EditorGUI.DisabledScope(((m_AmbientLightingMode.intValue == 0) && realtimeGISupported && !bakedGISupported) || ((m_AmbientLightingMode.intValue == 1) && bakedGISupported && !realtimeGISupported)))
                        {
                            EditorGUILayout.IntPopup(m_AmbientLightingMode, Styles.AmbientLightingModes, modeVals, Styles.AmbientLightingMode);
                        }

                        // if they have selected a state that isnt supported, show dialog, and still make the box editable
                        if (((m_AmbientLightingMode.intValue == 0) && !realtimeGISupported) ||
                            ((m_AmbientLightingMode.intValue == 1) && !bakedGISupported))
                        {
                            EditorGUILayout.HelpBox("The following mode is not supported and will fallback on " + (((m_AmbientLightingMode.intValue == 0) && !realtimeGISupported) ? "Baked" : "Realtime"), MessageType.Warning);
                        }
                    }
                    // Show "Baked" if precomputed GI is disabled and "Realtime" if baked GI is disabled (but we don't wanna show the box if the whole mode is not supported.)
                    else if ((m_EnabledBakedGI.boolValue && bakedGISupported) || (m_EnabledRealtimeGI.boolValue && realtimeGISupported))
                    {
                        using (new EditorGUI.DisabledScope(true))
                        {
                            EditorGUILayout.IntPopup(Styles.AmbientLightingMode, m_EnabledBakedGI.boolValue ? 1 : 0, Styles.AmbientLightingModes, modeVals);
                        }
                    }
                }

                EditorGUI.indentLevel--;
                EditorGUILayout.Space();

                EditorGUILayout.LabelField(Styles.env_refl_top);
                EditorGUI.indentLevel++;

                EditorGUILayout.PropertyField(m_DefaultReflectionMode, Styles.env_refl_src);

                DefaultReflectionMode defReflectionMode = (DefaultReflectionMode)m_DefaultReflectionMode.intValue;
                switch (defReflectionMode)
                {
                case DefaultReflectionMode.FromSkybox:
                {
                    int[]        reflectionResolutionValuesArray = null;
                    GUIContent[] reflectionResolutionTextArray   = null;
                    ReflectionProbeEditor.GetResolutionArray(ref reflectionResolutionValuesArray, ref reflectionResolutionTextArray);
                    EditorGUILayout.IntPopup(m_DefaultReflectionResolution, reflectionResolutionTextArray, reflectionResolutionValuesArray, Styles.env_refl_res, GUILayout.MinWidth(40));
                }
                break;

                case DefaultReflectionMode.Custom:
                    EditorGUILayout.PropertyField(m_CustomReflection, Styles.customReflection);
                    break;
                }

                EditorGUILayout.PropertyField(m_ReflectionCompression, Styles.env_refl_cmp);
                EditorGUILayout.Slider(m_ReflectionIntensity, 0.0F, 1.0F, Styles.env_refl_int);
                EditorGUILayout.IntSlider(m_ReflectionBounces, 1, 5, Styles.env_refl_bnc);

                EditorGUI.indentLevel--;

                EditorGUI.indentLevel--;
                EditorGUILayout.Space();
            }

            m_RenderSettings.ApplyModifiedProperties();
        }