GetIterator() public method

Get the first serialized property.

public GetIterator ( ) : UnityEditor.SerializedProperty
return UnityEditor.SerializedProperty
Exemplo n.º 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));
						}
					}
				}
			}
		}
	}
Exemplo n.º 2
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);
    }
Exemplo n.º 3
0
    /// <summary>
    /// 指定アセットにMissingのプロパティがあれば、それをmissingListに追加する
    /// </summary>
    /// <param name="path">Path.</param>
    private static void SearchMissing(string path)
    {
        // 指定パスのアセットを全て取得
        IEnumerable<UnityEngine.Object> assets = AssetDatabase.LoadAllAssetsAtPath (path);

        // 各アセットについて、Missingのプロパティがあるかチェック
        foreach (UnityEngine.Object obj in assets) {
            if (obj == null) {
                continue;
            }
            if (obj.name == "Deprecated EditorExtensionImpl") {
                continue;
            }

            // SerializedObjectを通してアセットのプロパティを取得する
            SerializedObject sobj = new SerializedObject (obj);
            SerializedProperty property = sobj.GetIterator ();

            while (property.Next (true)) {
                // プロパティの種類がオブジェクト(アセット)への参照で、
                // その参照がnullなのにもかかわらず、参照先インスタンスIDが0でないものはMissing状態!
                if (property.propertyType == SerializedPropertyType.ObjectReference &&
                    property.objectReferenceValue == null &&
                    property.objectReferenceInstanceIDValue != 0) {

                    // Missing状態のプロパティリストに追加する
                    missingList.Add (new AssetParameterData () {
                        obj = obj,
                        path = path,
                        property = property
                    });
                }
            }
        }
    }
Exemplo n.º 4
0
    public override void GatherProperties(PlayableDirector director, IPropertyCollector driver)
    {
#if false
#if UNITY_EDITOR
        Light trackBinding = director.GetGenericBinding(this) as Light;
        if (trackBinding == null)
        {
            return;
        }

        var serializedObject = new UnityEditor.SerializedObject(trackBinding);
        var iterator         = serializedObject.GetIterator();
        while (iterator.NextVisible(true))
        {
            if (iterator.hasVisibleChildren)
            {
                continue;
            }

            driver.AddFromName <Light>(trackBinding.gameObject, iterator.propertyPath);
        }
#endif
#endif
        base.GatherProperties(director, driver);
    }
Exemplo n.º 5
0
	static void createLayer(){
		SerializedObject SerializedObjectTagManager = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset")[0]);
		SerializedProperty it = SerializedObjectTagManager.GetIterator();

		bool showChildren = true;

#if UNITY_5

		while(it.NextVisible (showChildren)){
			Debug.Log(it.displayName);


			if(it.displayName == "Element 8"){
//				it.stringValue = "ShadowLayer";
			}

		}



#else
		while(it.NextVisible (showChildren)){
			
			if(it.name == "User Layer 8"){
//				it.stringValue = "ShadowLayer";
			}
			
		}
		//mmmm
#endif

		SerializedObjectTagManager.ApplyModifiedProperties();

	}
	public static string[] LogPropertis(SerializedObject serObj, string startPropertyName, bool enterChildren)
	{
		if (serObj == null)
			return null;

		string				log = "";
		SerializedProperty	sp;
		bool				bFirst = true;

		if (startPropertyName != null && startPropertyName != "")
			sp = serObj.FindProperty(startPropertyName);
		else sp = serObj.GetIterator();

		while (true)
		{
			object value = GetPropertyValue(sp);
			log += string.Format("{0}{3}{4}{5}   {1,-30}        {2, 20} {6}\r\n", sp.depth, NgConvert.GetTabSpace(sp.depth+1) + sp.name, (value == null ? "null" : value.ToString()), sp.editable, sp.isExpanded, sp.isArray, sp.propertyPath);

			if (sp.Next(bFirst) == false)
				break;
			bFirst = enterChildren;
		}

		{
			log = "=====================================================================\r\n" + log;
			log = log + "=====================================================================\r\n";
			Debug.Log(log);
		}
		return null;
	}
Exemplo n.º 7
0
	void App(GameObject src, GameObject dst)
	{
		dst.transform.localPosition=src.transform.localPosition;
		Component comp=src.GetComponent<MeshFilter>();
		Component dst_comp = dst.AddComponent(comp.GetType());
 
			SerializedObject src_ser_obj = new SerializedObject(comp);
			SerializedObject dst_ser_obj = new SerializedObject(dst_comp);
			src_ser_obj.Update();
			dst_ser_obj.Update();
			SerializedProperty ser_prop = src_ser_obj.GetIterator();
			bool enterChildren = true;
			while (ser_prop.Next(enterChildren)) {
				enterChildren = true;
				string path = ser_prop.propertyPath;
 
				bool skip = false;
				foreach (string blacklisted_path in propertyBlacklist) {
					if (path.EndsWith(blacklisted_path)) {
						skip = true;
						break;
					}
				}
				if (skip) {
					enterChildren = false;
					continue;
				}
 
				//Debug.Log(path);
				SerializedProperty dst_ser_prop = dst_ser_obj.FindProperty(path);
				AssignSerializedProperty(ser_prop, dst_ser_prop);
			}
 
			dst_ser_obj.ApplyModifiedProperties();
	}
		public static void DrawInspector(Editor wcEditor, System.Type baseType, List<string> ignoreClasses = null) {

			var so = new SerializedObject(wcEditor.targets);
			var target = wcEditor.target;
			
			so.Update();

			var baseTypes = new List<System.Type>();
			var baseTargetType = target.GetType();
			baseTypes.Add(baseTargetType);
			while (baseType != baseTargetType) {

				baseTargetType = baseTargetType.BaseType;
				baseTypes.Add(baseTargetType);

			}
			baseTypes.Reverse();

			SerializedProperty prop = so.GetIterator();
			var result = prop.NextVisible(true);

			EditorGUILayout.PropertyField(prop, false);

			if (result == true) {

				var currentType = EditorUtilitiesEx.FindTypeByProperty(baseTypes, prop);
				EditorGUILayout.BeginVertical();
				{

					while (prop.NextVisible(false) == true) {
						
						var cType = EditorUtilitiesEx.FindTypeByProperty(baseTypes, prop);
						if (cType != currentType) {
							
							currentType = cType;

							var name = cType.Name;
							if (ignoreClasses != null && ignoreClasses.Contains(name) == true) continue;

							EditorUtilitiesEx.DrawSplitter(name);

						}

						EditorGUILayout.PropertyField(prop, true);

					}

					prop.Reset();

				}
				EditorGUILayout.EndVertical();

			}

			so.ApplyModifiedProperties();

		}
Exemplo n.º 9
0
        internal static SerializedProperty[] GetSerializedProperties(this Object go) {
            var so = new SerializedObject(go);
            so.Update();
            var result = new List<SerializedProperty>();

            var iterator = so.GetIterator();
            while (iterator.NextVisible(true)) result.Add(iterator.Copy());
            return result.ToArray();
        }
Exemplo n.º 10
0
	private IEnumerable<SerializedProperty> GetProperties(SerializedObject obj)
	{
		var iterator = obj.GetIterator();
		var enterChildren = true;
		while (iterator.NextVisible(enterChildren))
		{
			enterChildren = false;
			yield return iterator;
		}
	}
Exemplo n.º 11
0
 /// <summary>
 /// Debugs the log all properties for serialized property.
 /// </summary>
 /// <param name='aSerializedObject'>
 /// A serializedproperty.
 /// </param>
 public static void DebugLogAllPropertiesForSerializedProperty(SerializedObject aSerializedObject)
 {
     Debug.Log ("EditorWindowUtility.DebugLogAllPropertiesForSerializedProperty()");
     var property = aSerializedObject.GetIterator();
     var first = true;
     while(property.NextVisible(first))
     {
          first = false;
          Debug.Log("	" + property.name + " = " + property);
     }
 }
Exemplo n.º 12
0
    public static void copySerialized(SerializedObject source, SerializedObject dest)
    {
        SerializedProperty serializedPropertyCurrent;

                serializedPropertyCurrent = source.GetIterator ();

                while (serializedPropertyCurrent.Next(true)) {

                        dest.CopyFromSerializedProperty (serializedPropertyCurrent);
                }

                dest.ApplyModifiedProperties ();
    }
            private void CopyProperties(SerializedObject source, Object dest, params SerializedPropertyType[] excludeTypes)
            {
                var newSerializedObject = new SerializedObject(dest);
                var prop = source.GetIterator();
                while (prop.NextVisible(true))
                {
                    if (!excludeTypes.Contains(prop.propertyType))
                    {
                        newSerializedObject.CopyFromSerializedProperty(prop);
                    }
                }

                newSerializedObject.ApplyModifiedProperties();
            }
Exemplo n.º 14
0
    public void DrawWindowGUI(int i)
    {
        EditorGUI.BeginChangeCheck();
        SerializedObject serializedObject = new SerializedObject(this);
        serializedObject.Update();
        SerializedProperty iterator = serializedObject.GetIterator();
        for (bool flag = true; iterator.NextVisible(flag); flag = false)
        {
            EditorGUILayout.PropertyField(iterator, true, new GUILayoutOption[0]);
        }
        serializedObject.ApplyModifiedProperties();
        EditorGUI.EndChangeCheck();

        GUI.DragWindow(new Rect(0, 0, 10000, 20));
    }
Exemplo n.º 15
0
	void OnGUI()
	{
		GUI.Label(new Rect( 10, 10, 50, 25 ), "Ratio");
		scaleTextValue = GUI.TextField(new Rect( 50, 10, 50, 25 ), scaleTextValue);
		
		float scale = 1.0f;
		float.TryParse(scaleTextValue, out scale);
		
		if( GUI.Button(new Rect(10, 40, 70, 30), "Scale PS") )
		{
			foreach( Object obj in Selection.objects )
			{
				GameObject gameObj = obj as GameObject;
				if( gameObj != null )
				{
					ScalePS(gameObj, scale);
				}				
			}
		}
		
		if( GUI.Button(new Rect(80, 40, 70, 30), "Serz log") )
		{
			foreach( Object obj in Selection.objects )
			{
				GameObject gameObj = obj as GameObject;
				if( gameObj.particleSystem != null )
				{
					SerializedObject so = new SerializedObject(gameObj.particleSystem);
					SerializedProperty it = so.GetIterator();
					while (it.Next(true))
						Debug.Log (it.propertyPath);
						
					break;
				}
				
				LineRenderer lineRenderer = gameObj.GetComponent<LineRenderer>();
				if( lineRenderer != null )
				{
					SerializedObject so = new SerializedObject(lineRenderer);
					SerializedProperty it = so.GetIterator();
					while (it.Next(true))
						Debug.Log (it.propertyPath);
					
					break;
				}
			}
		}
	}
        public static bool DrawDefaultInspectorExcept(SerializedObject serializedObject, params string[] propsNotToDraw)
        {
            if (serializedObject == null) throw new System.ArgumentNullException("serializedObject");

            EditorGUI.BeginChangeCheck();
            var iterator = serializedObject.GetIterator();
            for (bool enterChildren = true; iterator.NextVisible(enterChildren); enterChildren = false)
            {
                if (propsNotToDraw == null || !propsNotToDraw.Contains(iterator.name))
                {
                    //EditorGUILayout.PropertyField(iterator, true);
                    SPEditorGUILayout.PropertyField(iterator, true);
                }
            }
            return EditorGUI.EndChangeCheck();
        }
Exemplo n.º 17
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            drawPrefixLabel = false;
            totalHeight = 0;

            Begin(position, property, label);

            position.height = EditorGUI.GetPropertyHeight(property, label, true);
            EditorGUI.PropertyField(position, property);
            totalHeight += position.height;
            position.y += position.height;

            if (property.objectReferenceValue != null) {
                serialized = new SerializedObject(property.objectReferenceValue);
                iterator = serialized.GetIterator();
                iterator.NextVisible(true);

                EditorGUI.indentLevel += 1;
                int currentIndent = EditorGUI.indentLevel;

                while (true) {
                    position.height = EditorGUI.GetPropertyHeight(iterator, iterator.displayName.ToGUIContent(), false);

                    totalHeight += position.height;

                    EditorGUI.indentLevel = currentIndent + iterator.depth;
                    EditorGUI.PropertyField(position, iterator);

                    position.y += position.height;

                    if (!iterator.NextVisible(iterator.isExpanded)) {
                        break;
                    }
                }

                EditorGUI.indentLevel = currentIndent;
                EditorGUI.indentLevel -= 1;

                serialized.ApplyModifiedProperties();
            }

            End();
        }
Exemplo n.º 18
0
    private SerializedObject GeneratePropetiesFields(SerializedProperty a_property, Rect a_position, GUIContent a_label)
    {
        SerializedObject serializedObj = new UnityEditor.SerializedObject(a_property.objectReferenceValue);


        SerializedProperty property = serializedObj.GetIterator();


        while (property.NextVisible(true))
        {
            Rect rect = GetNextRect(a_position, property, a_label);

            EditorGUI.PropertyField(rect, property, true);
        }


        serializedObj.ApplyModifiedProperties();

        return(serializedObj);
    }
Exemplo n.º 19
0
    // Setup the layer name
    static void SetUpLayer(string instanceID, Rect selectionRect)
    {
        // Serialize TagManager asset
        SerializedObject so = new SerializedObject (AssetDatabase.LoadAllAssetsAtPath ("ProjectSettings/TagManager.asset")[0]);

        // Get the iterator
        SerializedProperty it = so.GetIterator ();

        // For each property
        while (it.NextVisible(true)) {

            // We want to set up the layer N°31
            if (it.name == "User Layer 31"){
                it.stringValue = "Cosmos";
            }
        }

        // Save change
        so.ApplyModifiedProperties();
    }
Exemplo n.º 20
0
    public override void GatherProperties(PlayableDirector director, IPropertyCollector driver)
    {
#if UNITY_EDITOR
        var comp = director.GetGenericBinding(this) as Transform;
        if (comp == null)
        {
            return;
        }
        var so   = new UnityEditor.SerializedObject(comp);
        var iter = so.GetIterator();
        while (iter.NextVisible(true))
        {
            if (iter.hasVisibleChildren)
            {
                continue;
            }
            driver.AddFromName <Transform>(comp.gameObject, iter.propertyPath);
        }
#endif
        base.GatherProperties(director, driver);
    }
Exemplo n.º 21
0
    //
    // Replace any references to files in Source with Target (same filenames etc)
    //
    public void ReplaceText(Object obj)
    {
        SerializedObject so = new SerializedObject(obj);
        var sp = so.GetIterator();

        while (sp.Next(true))
        {
            if (sp.propertyType == SerializedPropertyType.String)
            {
                var str = sp.stringValue;
                //if (str.Contains(strFind, ignoreCase ? System.Globalization.CompareOptions.IgnoreCase : System.Globalization.CompareOptions.None))
                if (Regex.IsMatch(str, strFind, ignoreCase ? RegexOptions.IgnoreCase : RegexOptions.None))
                {
                    //sp.stringValue = str.Replace(strFind, strReplace, ignoreCase ? System.StringComparison.CurrentCultureIgnoreCase : System.StringComparison.CurrentCulture);
                    sp.stringValue = Regex.Replace(str, strFind, strReplace, ignoreCase ? RegexOptions.IgnoreCase : RegexOptions.None);
                }
            }
        }

        so.ApplyModifiedProperties();
    }
Exemplo n.º 22
0
    //
    // Replace any references to files in Source with Target (same filenames etc)
    //
    public static void JoinReferences(string strSource, string strTarget, Object obj)
    {
        SerializedObject so = new SerializedObject(obj);
        var sp = so.GetIterator();

        while (sp.Next(true))
        {
            if (sp.propertyType != SerializedPropertyType.ObjectReference) continue;
            if (sp.objectReferenceValue == null) continue;

            var oldPath = AssetDatabase.GetAssetPath(sp.objectReferenceValue);
            if (!oldPath.StartsWith(strSource, System.StringComparison.InvariantCultureIgnoreCase)) continue;

            var newPath = oldPath.Replace(strSource, strTarget);
            var newObj = AssetDatabase.LoadAssetAtPath(newPath, sp.objectReferenceValue.GetType());
            if (newObj == null) continue;

            sp.objectReferenceValue = newObj;
        }

        so.ApplyModifiedProperties();
    }
    public override void OnInspectorGUI()
    {
        var ContextMenuPlugin = ((ContextMenuPluginHost)target).ContextMenuPlugin as ContextMenuPlugin;

        if (ContextMenuPlugin == null)
        {
            DrawDefaultInspector();
        }
        else
        {
            // Creating a serialized object, that will be used to update changes in the original class.
            var SerializedObject = new SerializedObject(ContextMenuPlugin);
            SerializedObject.Update();

            SerializedProperty Iterator = SerializedObject.GetIterator();
            for (bool EnterChildren = true; Iterator.NextVisible(EnterChildren); EnterChildren = false)
                EditorGUILayout.PropertyField(Iterator, true, new GUILayoutOption[0]);
            SerializedObject.ApplyModifiedProperties();
        }

        SceneView.RepaintAll();
    }
    public override void GatherProperties(PlayableDirector director, IPropertyCollector driver)
    {
#if UNITY_EDITOR
        //get the track binding for this track, if any
        BlendShapeController trackBinding = director.GetGenericBinding(this) as BlendShapeController;
        _mTrackBinding = trackBinding;
        if (trackBinding == null)
        {
            return;
        }
        var serializedObject = new UnityEditor.SerializedObject(trackBinding);
        var iterator         = serializedObject.GetIterator();
        while (iterator.NextVisible(true))
        {
            if (iterator.hasVisibleChildren)
            {
                continue;
            }
            driver.AddFromName <BlendShapeController>(trackBinding.gameObject, iterator.propertyPath);
        }
#endif
        base.GatherProperties(director, driver);
    }
        /// <summary>
        /// Adds the copy of a Component to a GameObject.
        /// </summary>
        /// <param name="go">The GameObject that will get the new Component</param>
        /// <param name="original">The original component to copy</param>
        /// <returns>The reference to the newly added Component copy</returns>
        public static Component AddComponent(this GameObject go, Component original)
        {
            var c = go.AddComponent(original.GetType());

            var originalSerialized = new SerializedObject(original).GetIterator();
            var nso = new SerializedObject(c);
            var newSerialized = nso.GetIterator();

            if(originalSerialized.Next(true))
            {
                newSerialized.Next(true);

                while(originalSerialized.NextVisible(true))
                {
                    newSerialized.NextVisible(true);
                    newSerialized.SetValue(originalSerialized.GetValue());
                }
            }

            nso.ApplyModifiedProperties();

            return c;
        }
Exemplo n.º 26
0
        internal static void DisplayObjectContextMenu(Rect position, Object[] context, int contextUserData)
        {
            // Don't show context menu if we're inside the side-by-side diff comparison.
            if (EditorGUIUtility.comparisonViewMode != EditorGUIUtility.ComparisonViewMode.None)
            {
                return;
            }

            Vector2 temp = GUIUtility.GUIToScreenPoint(new Vector2(position.x, position.y));

            position.x = temp.x;
            position.y = temp.y;

            GenericMenu pm = new GenericMenu();

            if (context != null && context.Length == 1 && context[0] is Component)
            {
                Object    targetObject    = context[0];
                Component targetComponent = (Component)targetObject;

                // Do nothing if component is not on a prefab instance.
                if (PrefabUtility.GetCorrespondingConnectedObjectFromSource(targetComponent.gameObject) == null)
                {
                }
                // Handle added component.
                else if (PrefabUtility.GetCorrespondingObjectFromSource(targetObject) == null && targetComponent != null)
                {
                    GameObject instanceGo = targetComponent.gameObject;
                    PrefabUtility.HandleApplyRevertMenuItems(
                        "Added Component",
                        instanceGo,
                        (menuItemContent, sourceGo) =>
                    {
                        TargetChoiceHandler.ObjectInstanceAndSourcePathInfo info = new TargetChoiceHandler.ObjectInstanceAndSourcePathInfo();
                        info.instanceObject   = targetComponent;
                        info.assetPath        = AssetDatabase.GetAssetPath(sourceGo);
                        GameObject rootObject = PrefabUtility.GetRootGameObject(sourceGo);
                        if (!PrefabUtility.IsPartOfPrefabThatCanBeAppliedTo(rootObject) || EditorUtility.IsPersistent(instanceGo))
                        {
                            pm.AddDisabledItem(menuItemContent);
                        }
                        else
                        {
                            pm.AddItem(menuItemContent, false, TargetChoiceHandler.ApplyPrefabAddedComponent, info);
                        }
                    },
                        (menuItemContent) =>
                    {
                        pm.AddItem(menuItemContent, false, TargetChoiceHandler.RevertPrefabAddedComponent, targetComponent);
                    }
                        );
                }
                else
                {
                    bool hasPrefabOverride = false;
                    using (var so = new SerializedObject(targetObject))
                    {
                        SerializedProperty property = so.GetIterator();
                        while (property.Next(property.hasChildren))
                        {
                            if (property.isInstantiatedPrefab && property.prefabOverride && !property.isDefaultOverride)
                            {
                                hasPrefabOverride = true;
                                break;
                            }
                        }
                    }

                    // Handle modified component.
                    if (hasPrefabOverride)
                    {
                        bool defaultOverrides =
                            PrefabUtility.IsObjectOverrideAllDefaultOverridesComparedToAnySource(targetObject);

                        PrefabUtility.HandleApplyRevertMenuItems(
                            "Modified Component",
                            targetObject,
                            (menuItemContent, sourceObject) =>
                        {
                            TargetChoiceHandler.ObjectInstanceAndSourcePathInfo info = new TargetChoiceHandler.ObjectInstanceAndSourcePathInfo();
                            info.instanceObject   = targetObject;
                            info.assetPath        = AssetDatabase.GetAssetPath(sourceObject);
                            GameObject rootObject = PrefabUtility.GetRootGameObject(sourceObject);
                            if (!PrefabUtility.IsPartOfPrefabThatCanBeAppliedTo(rootObject) || EditorUtility.IsPersistent(targetObject))
                            {
                                pm.AddDisabledItem(menuItemContent);
                            }
                            else
                            {
                                pm.AddItem(menuItemContent, false, TargetChoiceHandler.ApplyPrefabObjectOverride, info);
                            }
                        },
                            (menuItemContent) =>
                        {
                            pm.AddItem(menuItemContent, false, TargetChoiceHandler.RevertPrefabObjectOverride, targetObject);
                        },
                            defaultOverrides
                            );
                    }
                }
            }

            pm.ObjectContextDropDown(position, context, contextUserData);

            ResetMouseDown();
        }
Exemplo n.º 27
0
        public override bool OnGUI()
        {
            bool dirty = false;

            bool b = GUILayout.Toggle(mFreeform, "Freeform");
            if (b != mFreeform)
            {
                if (b)
                {
                    mCurrentShape.Spline.ShowGizmos = true;
                    mCurrentShape.Delete();
                    mCurrentShape = null;
                    mFreeform = b;
                    
                }
                else if (EditorUtility.DisplayDialog("Warning", "The current shape will be irreversible replaced. Are you sure?", "Ok", "Cancel"))
                {
                    mFreeform = b;
                    mCurrentShape = (CurvyShape2D)Resource.gameObject.AddComponent(CurvyShape.GetShapeType(mMenuNames[mSelection]));
                    mCurrentShape.Spline.ShowGizmos = false;
                }
            }
            if (!mFreeform)
            {
                int sel = EditorGUILayout.Popup(mSelection, mMenuNames);
                if (sel != mSelection)
                {
                    mSelection = sel;
                    dirty = true;
                    if (mCurrentShape)
                        mCurrentShape.Delete();
                    mCurrentShape = (CurvyShape2D)Resource.gameObject.AddComponent(CurvyShape.GetShapeType(mMenuNames[mSelection]));
                }
                if (mCurrentShape)
                {

                    var so = new SerializedObject(mCurrentShape);

                    var prop = so.GetIterator();

                    bool enterChildren = true;

                    while (prop.NextVisible(enterChildren))
                    {
                        switch (prop.name)
                        {
                            case "m_Script":
                            case "InspectorFoldout":
                            case "m_Plane":
                                //case "m_Persistent":
                                break;
                            default:
                                EditorGUILayout.PropertyField(prop);
                                break;
                        }
                        enterChildren = false;
                    }
                    dirty = so.ApplyModifiedProperties();
                }
            }
            
            return dirty;   
        }
        internal bool GetOptimizedGUIBlockImplementation(bool isDirty, bool isVisible, out OptimizedGUIBlock block, out float height)
        {
            if (isDirty && m_OptimizedBlock != null)
            {
                m_OptimizedBlock.Dispose();
                m_OptimizedBlock = null;
            }

            if (!isVisible)
            {
                if (m_OptimizedBlock == null)
                {
                    m_OptimizedBlock = new OptimizedGUIBlock();
                }
                block  = m_OptimizedBlock;
                height = 0;
                return(true);
            }

            if (m_SerializedObject == null)
            {
                m_SerializedObject = new SerializedObject(targets, m_Context);
            }
            else
            {
                m_SerializedObject.Update();
            }
            m_SerializedObject.inspectorMode = m_InspectorMode;

            SerializedProperty property = m_SerializedObject.GetIterator();

            height = EditorGUI.kControlVerticalSpacing;
            bool expand = true;

            while (property.NextVisible(expand))
            {
                if (!EditorGUI.CanCacheInspectorGUI(property))
                {
                    if (m_OptimizedBlock != null)
                    {
                        m_OptimizedBlock.Dispose();
                    }
                    block = m_OptimizedBlock = null;
                    return(false);
                }

                height += EditorGUI.GetPropertyHeight(property, null, true) + EditorGUI.kControlVerticalSpacing;
                expand  = false;
            }

            if (height == EditorGUI.kControlVerticalSpacing)
            {
                height = 0;
            }

            if (m_OptimizedBlock == null)
            {
                m_OptimizedBlock = new OptimizedGUIBlock();
            }
            block = m_OptimizedBlock;
            return(true);
        }
Exemplo n.º 29
0
	//Copy Selected Modules
	private void CopyModules(ParticleSystem source, ParticleSystem dest)
	{
		if(source == null)
		{
			Debug.LogWarning("CartoonFX Easy Editor: Select a source Particle System to copy properties from first!");
			return;
		}
		
		SerializedObject psSource = new SerializedObject(source);
		SerializedObject psDest = new SerializedObject(dest);
		
		//Inial Module
		if(b_modules[0])
		{
			psDest.FindProperty("prewarm").boolValue = psSource.FindProperty("prewarm").boolValue;
			psDest.FindProperty("lengthInSec").floatValue = psSource.FindProperty("lengthInSec").floatValue;
			psDest.FindProperty("moveWithTransform").boolValue = psSource.FindProperty("moveWithTransform").boolValue;
			
			GenericModuleCopy(psSource.FindProperty("InitialModule"), psDest.FindProperty("InitialModule"));
			
			dest.startDelay = source.startDelay;
			dest.loop = source.loop;
			dest.playOnAwake = source.playOnAwake;
			dest.playbackSpeed = source.playbackSpeed;

            var em = dest.emission;
			em.rate = source.emission.rate;
			dest.startSpeed = source.startSpeed;
			dest.startSize = source.startSize;
			dest.startColor = source.startColor;
			dest.startRotation = source.startRotation;
			dest.startLifetime = source.startLifetime;
			dest.gravityModifier = source.gravityModifier;
		}
		
		//Emission
		if(b_modules[1])	GenericModuleCopy(psSource.FindProperty("EmissionModule"), psDest.FindProperty("EmissionModule"));
		
		//Shape
		if(b_modules[2])	GenericModuleCopy(psSource.FindProperty("ShapeModule"), psDest.FindProperty("ShapeModule"));
		
		//Velocity
		if(b_modules[3])	GenericModuleCopy(psSource.FindProperty("VelocityModule"), psDest.FindProperty("VelocityModule"));
		
		//Velocity Clamp
		if(b_modules[4])	GenericModuleCopy(psSource.FindProperty("ClampVelocityModule"), psDest.FindProperty("ClampVelocityModule"));
		
		//Force
		if(b_modules[5])	GenericModuleCopy(psSource.FindProperty("ForceModule"), psDest.FindProperty("ForceModule"));
		
		//Color
		if(b_modules[6])	GenericModuleCopy(psSource.FindProperty("ColorModule"), psDest.FindProperty("ColorModule"));
		
		//Color Speed
		if(b_modules[7])	GenericModuleCopy(psSource.FindProperty("ColorBySpeedModule"), psDest.FindProperty("ColorBySpeedModule"));
		
		//Size
		if(b_modules[8])	GenericModuleCopy(psSource.FindProperty("SizeModule"), psDest.FindProperty("SizeModule"));
		
		//Size Speed
		if(b_modules[9])	GenericModuleCopy(psSource.FindProperty("SizeBySpeedModule"), psDest.FindProperty("SizeBySpeedModule"));
		
		//Rotation
		if(b_modules[10])	GenericModuleCopy(psSource.FindProperty("RotationModule"), psDest.FindProperty("RotationModule"));
		
		//Rotation Speed
		if(b_modules[11])	GenericModuleCopy(psSource.FindProperty("RotationBySpeedModule"), psDest.FindProperty("RotationBySpeedModule"));
		
		//Collision
		if(b_modules[12])	GenericModuleCopy(psSource.FindProperty("CollisionModule"), psDest.FindProperty("CollisionModule"));
		
		//Sub Emitters
		if(b_modules[13])	SubModuleCopy(psSource, psDest);
		
		//Texture Animation
		if(b_modules[14])	GenericModuleCopy(psSource.FindProperty("UVModule"), psDest.FindProperty("UVModule"));
		
		//Renderer
		if(b_modules[15])
		{
			ParticleSystemRenderer rendSource = source.GetComponent<ParticleSystemRenderer>();
			ParticleSystemRenderer rendDest = dest.GetComponent<ParticleSystemRenderer>();
			
			psSource = new SerializedObject(rendSource);
			psDest = new SerializedObject(rendDest);
			
			SerializedProperty ss = psSource.GetIterator();
			ss.Next(true);
			
			SerializedProperty sd = psDest.GetIterator();
			sd.Next(true);
			
			GenericModuleCopy(ss, sd, false);
		}
	}
Exemplo n.º 30
0
		void DrawProperties(Object obj)
		{
			var so = new SerializedObject(obj);
			if (obj is GameObject)
			{
				DrawProperty(so.FindProperty("m_IsActive"), EditorGUI.indentLevel, false);
			}
			else if (!pickObject)
			{
				var ident = EditorGUI.indentLevel;
				var p = so.GetIterator();
				bool withChildren;
				System.Func<bool, bool> nextFunction = (enterChildren) => (showHiddenProperties ? p.Next(enterChildren) : p.NextVisible(enterChildren));
				while (nextFunction(withChildren = CheckChild(p)))
				{
					DrawProperty(p, ident, !withChildren);
				}
			}
		}
 private void GetSelectedStyleProperty(out SerializedObject serializedObject, out SerializedProperty styleProperty)
 {
   GUISkin guiSkin = (GUISkin) null;
   GUISkin current = GUISkin.current;
   GUIStyle style = current.FindStyle(this.m_Instruction.usedGUIStyle.name);
   if (style != null && style == this.m_Instruction.usedGUIStyle)
     guiSkin = current;
   styleProperty = (SerializedProperty) null;
   if ((UnityEngine.Object) guiSkin != (UnityEngine.Object) null)
   {
     serializedObject = new SerializedObject((UnityEngine.Object) guiSkin);
     SerializedProperty iterator = serializedObject.GetIterator();
     bool enterChildren = true;
     while (iterator.NextVisible(enterChildren))
     {
       if (iterator.type == "GUIStyle")
       {
         enterChildren = false;
         if (iterator.FindPropertyRelative("m_Name").stringValue == this.m_Instruction.usedGUIStyle.name)
         {
           styleProperty = iterator;
           return;
         }
       }
       else
         enterChildren = true;
     }
     Debug.Log((object) string.Format("Showing editable Style from GUISkin: {0}, IsPersistant: {1}", (object) guiSkin.name, (object) EditorUtility.IsPersistent((UnityEngine.Object) guiSkin)));
   }
   serializedObject = new SerializedObject((UnityEngine.Object) this.m_CachedinstructionInfo.styleContainer);
   styleProperty = serializedObject.FindProperty("inspectedStyle");
 }
Exemplo n.º 32
0
    public static UnityEventBase GetEvent(Component component, SerializedProperty eventProperty)
    {
        string eventName = eventProperty.stringValue;

        if (string.IsNullOrEmpty(eventName)) return null;

        var type = component.GetType();
        var evField = type.GetField(eventName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
        if (evField != null && IsEventType(evField.FieldType))
        {
            return evField.GetValue(component) as UnityEventBase;
        }

        var evProp = type.GetProperty(eventName, typeof (UnityEventBase));
        if (evProp != null)
        {
            return evProp.GetValue(component, null) as UnityEventBase;
        }

        var scomp = new SerializedObject(component);
        var it = scomp.GetIterator();
        //necessary to actually iterate over the properties of it.
        it.Next(true);
        var sep = FirstOrDefault(it, p => p.displayName == eventName);

        if (sep == null)
        {
            Debug.LogErrorFormat("Could not get event {0} on {1}", eventName, type);
            return null;
        }

        evField = type.GetField(sep.name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
        if (evField != null)
        {
            //need to update this, otherwise the things won't be able to bind
            eventProperty.stringValue = sep.name;

            return evField.GetValue(component) as UnityEventBase;
        }

        Debug.LogErrorFormat("Could not get event {0} on {1}", eventName, type);

        return null;
    }
    /**
     * Returns a formatted string with all properties in serialized object.
     */
    static string SerializedObjectToString(SerializedObject serializedObject)
    {
        System.Text.StringBuilder sb = new System.Text.StringBuilder();

        if(serializedObject == null)
        {
            sb.Append("NULL");
            return sb.ToString();
        }

        SerializedProperty iterator = serializedObject.GetIterator();

        iterator.Next(true);

        while( iterator.Next(true) )
        {
            string tabs = "";
            for(int i = 0; i < iterator.depth; i++) tabs += "\t";

            sb.AppendLine(tabs + iterator.name + (iterator.propertyType == SerializedPropertyType.ObjectReference && iterator.type.Contains("Component") && iterator.objectReferenceValue == null ? " -> NULL" : "") );

            tabs += "  - ";

            sb.AppendLine(tabs + "Type: (" + iterator.type + " / " + iterator.propertyType + " / " + " / " + iterator.name + ")");
            sb.AppendLine(tabs + iterator.propertyPath);
            sb.AppendLine(tabs + "Value: " + SerializedPropertyValue(iterator));
        }

        return sb.ToString();
    }
Exemplo n.º 34
0
	public static void GetProperties(List<SerializedProperty> myProps, SerializedObject obj) {
		SerializedProperty iterator = obj.GetIterator();
		bool enterChildren = true;
		while(iterator.NextVisible(enterChildren)) {
			myProps.Add(iterator.Copy());
			enterChildren = false;
		}
	}
Exemplo n.º 35
0
        public void Run(string nodeId, string labelToNext, Dictionary <string, List <InternalAssetData> > groupedSources, List <string> alreadyCached, Action <string, string, Dictionary <string, List <InternalAssetData> >, List <string> > Output)
        {
            var usedCache = new List <string>();

            var outputDict = new Dictionary <string, List <InternalAssetData> >();


            // caution if import setting file is exists already or not.
            var samplingDirectoryPath = FileController.PathCombine(AssetBundleGraphSettings.MODIFIER_SAMPLING_PLACE, nodeId);

            var sampleAssetPath = string.Empty;

            ValidateModifierSample(samplingDirectoryPath,
                                   (string noSampleFolder) => {
                Debug.LogWarning("modifierSetting:" + noSampleFolder);
            },
                                   (string noSampleFile) => {
                throw new Exception("modifierSetting error:" + noSampleFile);
            },
                                   (string samplePath) => {
                Debug.Log("using modifier setting:" + samplePath);
                sampleAssetPath = samplePath;
            },
                                   (string tooManysample) => {
                throw new Exception("modifierSetting error:" + tooManysample);
            }
                                   );

            if (groupedSources.Keys.Count == 0)
            {
                return;
            }

            var the1stGroupKey = groupedSources.Keys.ToList()[0];


            // shrink group to 1 group.
            if (1 < groupedSources.Keys.Count)
            {
                Debug.LogWarning("modifierSetting shrinking group to \"" + the1stGroupKey + "\" forcely.");
            }

            var inputSources = new List <InternalAssetData>();

            foreach (var groupKey in groupedSources.Keys)
            {
                inputSources.AddRange(groupedSources[groupKey]);
            }

            var importSetOveredAssetsAndUpdatedFlagDict = new Dictionary <InternalAssetData, bool>();

            /*
             *      check file & setting.
             *      if need, apply modifierSetting to file.
             */
            {
                var samplingAssetImporter = AssetImporter.GetAtPath(sampleAssetPath);
                var effector = new InternalSamplingImportEffector(samplingAssetImporter);
                {
                    foreach (var inputSource in inputSources)
                    {
                        var importer = AssetImporter.GetAtPath(inputSource.importedPath);

                        /*
                         *      compare type of import setting effector.
                         */
                        var importerTypeStr = importer.GetType().ToString();

                        if (importerTypeStr != samplingAssetImporter.GetType().ToString())
                        {
                            // mismatched target will be ignored. but already imported.
                            importSetOveredAssetsAndUpdatedFlagDict[inputSource] = false;
                            continue;
                        }
                        importSetOveredAssetsAndUpdatedFlagDict[inputSource] = false;

                        /*
                         *      kind of importer is matched.
                         *      check setting then apply setting or no changed.
                         */
                        switch (importerTypeStr)
                        {
                        case "UnityEditor.AssetImporter": {                                // materials and others... assets which are generated in Unity.
                            var assetType = inputSource.assetType.ToString();
                            switch (assetType)
                            {
                            case "UnityEngine.Material": {
                                // 判別はできるんだけど、このあとどうしたもんか。ロードしなきゃいけない + loadしてもなんかグローバルなプロパティだけ比較とかそういうのかなあ、、

                                // var materialInstance = AssetDatabase.LoadAssetAtPath(inputSource.importedPath, inputSource.assetType) as Material;// 型を指定してロードしないといけないので、ここのコードのようにswitchに落としたほうが良さそう。
                                // var s = materialInstance.globalIlluminationFlags;// グローバルなプロパティ、リフレクションで列挙できそうではあるけど、、、

                                break;
                            }

                            default: {
                                Debug.LogError("unsupported type. assetType:" + assetType);
                                break;
                            }
                            }

                            /*
                             *      試しにserializeして云々してみる
                             */
                            var assetInstance    = AssetDatabase.LoadAssetAtPath(inputSource.importedPath, inputSource.assetType) as Material;                                 // ここの型が露出しちゃうのやばい
                            var serializedObject = new UnityEditor.SerializedObject(assetInstance);

                            var itr = serializedObject.GetIterator();
                            itr.NextVisible(true);
                            // Debug.LogError("0 itr:" + itr.propertyPath + " displayName:" + itr.displayName + " name:" + itr.name + " type:" + itr.type);

                            // while (itr.NextVisible(true)) {
                            //  Debug.LogError("~ itr:" + itr.propertyPath + " displayName:" + itr.displayName + " name:" + itr.name + " type:" + itr.type);
                            // }

                            /*
                             *      このへんのログはこんな感じになる。
                             *
                             * 0 itr:m_Shader displayName:Shader name:m_Shader type:PPtr<Shader>
                             * ~ itr:m_ShaderKeywords displayName:Shader Keywords name:m_ShaderKeywords type:string
                             * ~ itr:m_LightmapFlags displayName:Lightmap Flags name:m_LightmapFlags type:uint
                             * ~ itr:m_CustomRenderQueue displayName:Custom Render Queue name:m_CustomRenderQueue type:int
                             * ~ itr:stringTagMap displayName:String Tag Map name:stringTagMap type:map
                             * ~ itr:stringTagMap.Array.size displayName:Size name:size type:ArraySize
                             * ~ itr:m_SavedProperties displayName:Saved Properties name:m_SavedProperties type:UnityPropertySheet
                             * ~ itr:m_SavedProperties.m_TexEnvs displayName:Tex Envs name:m_TexEnvs type:map
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.size displayName:Size name:size type:ArraySize
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[0] displayName:Element 0 name:data type:pair
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[0].first displayName:First name:first type:FastPropertyName
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[0].first.name displayName:Name name:name type:string
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[0].second displayName:Second name:second type:UnityTexEnv
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[0].second.m_Texture displayName:Texture name:m_Texture type:PPtr<Texture>
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[0].second.m_Scale displayName:Scale name:m_Scale type:Vector2
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[0].second.m_Scale.x displayName:X name:x type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[0].second.m_Scale.y displayName:Y name:y type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[0].second.m_Offset displayName:Offset name:m_Offset type:Vector2
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[0].second.m_Offset.x displayName:X name:x type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[0].second.m_Offset.y displayName:Y name:y type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[1] displayName:Element 1 name:data type:pair
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[1].first displayName:First name:first type:FastPropertyName
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[1].first.name displayName:Name name:name type:string
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[1].second displayName:Second name:second type:UnityTexEnv
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[1].second.m_Texture displayName:Texture name:m_Texture type:PPtr<Texture>
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[1].second.m_Scale displayName:Scale name:m_Scale type:Vector2
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[1].second.m_Scale.x displayName:X name:x type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[1].second.m_Scale.y displayName:Y name:y type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[1].second.m_Offset displayName:Offset name:m_Offset type:Vector2
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[1].second.m_Offset.x displayName:X name:x type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[1].second.m_Offset.y displayName:Y name:y type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[2] displayName:Element 2 name:data type:pair
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[2].first displayName:First name:first type:FastPropertyName
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[2].first.name displayName:Name name:name type:string
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[2].second displayName:Second name:second type:UnityTexEnv
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[2].second.m_Texture displayName:Texture name:m_Texture type:PPtr<Texture>
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[2].second.m_Scale displayName:Scale name:m_Scale type:Vector2
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[2].second.m_Scale.x displayName:X name:x type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[2].second.m_Scale.y displayName:Y name:y type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[2].second.m_Offset displayName:Offset name:m_Offset type:Vector2
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[2].second.m_Offset.x displayName:X name:x type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[2].second.m_Offset.y displayName:Y name:y type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[3] displayName:Element 3 name:data type:pair
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[3].first displayName:First name:first type:FastPropertyName
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[3].first.name displayName:Name name:name type:string
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[3].second displayName:Second name:second type:UnityTexEnv
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[3].second.m_Texture displayName:Texture name:m_Texture type:PPtr<Texture>
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[3].second.m_Scale displayName:Scale name:m_Scale type:Vector2
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[3].second.m_Scale.x displayName:X name:x type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[3].second.m_Scale.y displayName:Y name:y type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[3].second.m_Offset displayName:Offset name:m_Offset type:Vector2
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[3].second.m_Offset.x displayName:X name:x type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[3].second.m_Offset.y displayName:Y name:y type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[4] displayName:Element 4 name:data type:pair
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[4].first displayName:First name:first type:FastPropertyName
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[4].first.name displayName:Name name:name type:string
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[4].second displayName:Second name:second type:UnityTexEnv
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[4].second.m_Texture displayName:Texture name:m_Texture type:PPtr<Texture>
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[4].second.m_Scale displayName:Scale name:m_Scale type:Vector2
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[4].second.m_Scale.x displayName:X name:x type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[4].second.m_Scale.y displayName:Y name:y type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[4].second.m_Offset displayName:Offset name:m_Offset type:Vector2
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[4].second.m_Offset.x displayName:X name:x type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[4].second.m_Offset.y displayName:Y name:y type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[5] displayName:Element 5 name:data type:pair
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[5].first displayName:First name:first type:FastPropertyName
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[5].first.name displayName:Name name:name type:string
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[5].second displayName:Second name:second type:UnityTexEnv
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[5].second.m_Texture displayName:Texture name:m_Texture type:PPtr<Texture>
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[5].second.m_Scale displayName:Scale name:m_Scale type:Vector2
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[5].second.m_Scale.x displayName:X name:x type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[5].second.m_Scale.y displayName:Y name:y type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[5].second.m_Offset displayName:Offset name:m_Offset type:Vector2
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[5].second.m_Offset.x displayName:X name:x type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[5].second.m_Offset.y displayName:Y name:y type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[6] displayName:Element 6 name:data type:pair
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[6].first displayName:First name:first type:FastPropertyName
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[6].first.name displayName:Name name:name type:string
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[6].second displayName:Second name:second type:UnityTexEnv
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[6].second.m_Texture displayName:Texture name:m_Texture type:PPtr<Texture>
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[6].second.m_Scale displayName:Scale name:m_Scale type:Vector2
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[6].second.m_Scale.x displayName:X name:x type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[6].second.m_Scale.y displayName:Y name:y type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[6].second.m_Offset displayName:Offset name:m_Offset type:Vector2
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[6].second.m_Offset.x displayName:X name:x type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[6].second.m_Offset.y displayName:Y name:y type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[7] displayName:Element 7 name:data type:pair
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[7].first displayName:First name:first type:FastPropertyName
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[7].first.name displayName:Name name:name type:string
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[7].second displayName:Second name:second type:UnityTexEnv
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[7].second.m_Texture displayName:Texture name:m_Texture type:PPtr<Texture>
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[7].second.m_Scale displayName:Scale name:m_Scale type:Vector2
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[7].second.m_Scale.x displayName:X name:x type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[7].second.m_Scale.y displayName:Y name:y type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[7].second.m_Offset displayName:Offset name:m_Offset type:Vector2
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[7].second.m_Offset.x displayName:X name:x type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[7].second.m_Offset.y displayName:Y name:y type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[8] displayName:Element 8 name:data type:pair
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[8].first displayName:First name:first type:FastPropertyName
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[8].first.name displayName:Name name:name type:string
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[8].second displayName:Second name:second type:UnityTexEnv
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[8].second.m_Texture displayName:Texture name:m_Texture type:PPtr<Texture>
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[8].second.m_Scale displayName:Scale name:m_Scale type:Vector2
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[8].second.m_Scale.x displayName:X name:x type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[8].second.m_Scale.y displayName:Y name:y type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[8].second.m_Offset displayName:Offset name:m_Offset type:Vector2
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[8].second.m_Offset.x displayName:X name:x type:float
                             * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[8].second.m_Offset.y displayName:Y name:y type:float
                             * ~ itr:m_SavedProperties.m_Floats displayName:Floats name:m_Floats type:map
                             * ~ itr:m_SavedProperties.m_Floats.Array.size displayName:Size name:size type:ArraySize
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[0] displayName:Element 0 name:data type:pair
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[0].first displayName:First name:first type:FastPropertyName
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[0].first.name displayName:Name name:name type:string
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[0].second displayName:Second name:second type:float
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[1] displayName:Element 1 name:data type:pair
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[1].first displayName:First name:first type:FastPropertyName
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[1].first.name displayName:Name name:name type:string
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[1].second displayName:Second name:second type:float
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[2] displayName:Element 2 name:data type:pair
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[2].first displayName:First name:first type:FastPropertyName
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[2].first.name displayName:Name name:name type:string
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[2].second displayName:Second name:second type:float
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[3] displayName:Element 3 name:data type:pair
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[3].first displayName:First name:first type:FastPropertyName
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[3].first.name displayName:Name name:name type:string
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[3].second displayName:Second name:second type:float
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[4] displayName:Element 4 name:data type:pair
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[4].first displayName:First name:first type:FastPropertyName
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[4].first.name displayName:Name name:name type:string
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[4].second displayName:Second name:second type:float
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[5] displayName:Element 5 name:data type:pair
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[5].first displayName:First name:first type:FastPropertyName
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[5].first.name displayName:Name name:name type:string
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[5].second displayName:Second name:second type:float
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[6] displayName:Element 6 name:data type:pair
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[6].first displayName:First name:first type:FastPropertyName
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[6].first.name displayName:Name name:name type:string
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[6].second displayName:Second name:second type:float
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[7] displayName:Element 7 name:data type:pair
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[7].first displayName:First name:first type:FastPropertyName
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[7].first.name displayName:Name name:name type:string
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[7].second displayName:Second name:second type:float
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[8] displayName:Element 8 name:data type:pair
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[8].first displayName:First name:first type:FastPropertyName
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[8].first.name displayName:Name name:name type:string
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[8].second displayName:Second name:second type:float
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[9] displayName:Element 9 name:data type:pair
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[9].first displayName:First name:first type:FastPropertyName
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[9].first.name displayName:Name name:name type:string
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[9].second displayName:Second name:second type:float
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[10] displayName:Element 10 name:data type:pair
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[10].first displayName:First name:first type:FastPropertyName
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[10].first.name displayName:Name name:name type:string
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[10].second displayName:Second name:second type:float
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[11] displayName:Element 11 name:data type:pair
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[11].first displayName:First name:first type:FastPropertyName
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[11].first.name displayName:Name name:name type:string
                             * ~ itr:m_SavedProperties.m_Floats.Array.data[11].second displayName:Second name:second type:float
                             * ~ itr:m_SavedProperties.m_Colors displayName:Colors name:m_Colors type:map
                             * ~ itr:m_SavedProperties.m_Colors.Array.size displayName:Size name:size type:ArraySize
                             * ~ itr:m_SavedProperties.m_Colors.Array.data[0] displayName:Element 0 name:data type:pair
                             * ~ itr:m_SavedProperties.m_Colors.Array.data[0].first displayName:First name:first type:FastPropertyName
                             * ~ itr:m_SavedProperties.m_Colors.Array.data[0].first.name displayName:Name name:name type:string
                             * ~ itr:m_SavedProperties.m_Colors.Array.data[0].second displayName:Second name:second type:Color
                             * ~ itr:m_SavedProperties.m_Colors.Array.data[1] displayName:Element 1 name:data type:pair
                             * ~ itr:m_SavedProperties.m_Colors.Array.data[1].first displayName:First name:first type:FastPropertyName
                             * ~ itr:m_SavedProperties.m_Colors.Array.data[1].first.name displayName:Name name:name type:string
                             * ~ itr:m_SavedProperties.m_Colors.Array.data[1].second displayName:Second name:second type:Color
                             *
                             */



                            // もしサンプルとの差があれば、この素材には変更があったものとして、関連するPrefabの作成時にprefabのキャッシュを消すとかする。
                            // if (!same) {
                            //  effector.ForceOnPreprocessTexture(texImporter);
                            //  importSetOveredAssetsAndUpdatedFlagDict[inputSource] = true;
                            // }

                            // とりあえず決め打ちで、変化があったものとしてみなす。デバッグ中。
                            Debug.LogError("modifierは、現状「通過した素材の設定が変更されてるかどうか把握できない」ので、常に新規扱いになっている。そのため、このファイルと、このファイルを使ったpredab生成が常に新作になり、キャッシュが効かないようになっている。");
                            importSetOveredAssetsAndUpdatedFlagDict[inputSource] = true;
                            break;
                        }

                        default: {
                            throw new Exception("unhandled modifier type:" + importerTypeStr);
                        }
                        }
                    }
                }
            }


            /*
             *      inputSetting sequence is over.
             */

            var outputSources = new List <InternalAssetData>();


            foreach (var inputAsset in inputSources)
            {
                var updated = importSetOveredAssetsAndUpdatedFlagDict[inputAsset];
                if (!updated)
                {
                    // already set completed.
                    var newInternalAssetData = InternalAssetData.InternalAssetDataGeneratedByImporterOrModifierOrPrefabricator(
                        inputAsset.importedPath,
                        AssetDatabase.AssetPathToGUID(inputAsset.importedPath),
                        AssetBundleGraphInternalFunctions.GetAssetType(inputAsset.importedPath),
                        false,                        // not changed.
                        false
                        );
                    outputSources.Add(newInternalAssetData);
                }
                else
                {
                    // updated asset.
                    var newInternalAssetData = InternalAssetData.InternalAssetDataGeneratedByImporterOrModifierOrPrefabricator(
                        inputAsset.importedPath,
                        AssetDatabase.AssetPathToGUID(inputAsset.importedPath),
                        AssetBundleGraphInternalFunctions.GetAssetType(inputAsset.importedPath),
                        true,                        // changed.
                        false
                        );
                    outputSources.Add(newInternalAssetData);
                }
            }

            outputDict[the1stGroupKey] = outputSources;

            Output(nodeId, labelToNext, outputDict, usedCache);
        }
Exemplo n.º 36
0
    /// <summary>
    /// Draws the rule inspector.
    /// </summary>
    /// <param name='obj'>
    /// Object - the serialized object
    /// </param>
    private void DrawRuleInspector(Object obj)
    {
        SerializedObject serObj = new SerializedObject(obj);

        //rule row - enable/disable rule foldout + reset button
        Rect ruleTopRect = EditorGUILayout.BeginHorizontal();
        {
            Rect imageRect = new Rect(ruleTopRect);
            imageRect.width = 20;
            imageRect.x=35;
            Texture2D icon = (Texture2D) Resources.Load(((BaseRule)obj).GetIconPath());
            if (icon != null)
            {
                EditorGUI.DrawPreviewTexture(imageRect,(Texture2D) Resources.Load(((BaseRule)obj).GetIconPath()));
            }
            ((BaseRule)obj).IsEnabled = EditorGUILayout.Toggle(((BaseRule)obj).Enabled ,GUILayout.Width(30));

            GUIContent placeHolderContent = new GUIContent("", ((BaseRule)obj).GetRuleDescription());
            string[] ver = UnityEditorInternal.InternalEditorUtility.GetFullUnityVersion().Substring(0,5).Replace('.',' ').Split(' ');
            if (int.Parse(ver[0]) == 4 && int.Parse(ver[1]) <=2)
            {
                EditorGUILayout.LabelField(placeHolderContent, GUILayout.Width(25));
            }
            else
            {
                EditorGUILayout.LabelField(placeHolderContent, GUILayout.Width(0));
            }

            ((BaseRule)obj).FoldoutOpen = GUIUtils.Foldout(((BaseRule)obj).FoldoutOpen, new GUIContent(((BaseRule)obj).FriendlyName, ((BaseRule)obj).GetRuleDescription()));

        }
        EditorGUILayout.EndHorizontal();
        SetRulesContextMenu(ruleTopRect,(BaseRule)obj);

        if ( ((BaseRule)obj).FoldoutOpen )
        {
            EditorGUI.indentLevel++;
            EditorGUI.indentLevel++;
            EditorGUI.indentLevel++;

           	if(serObj != null)
            {
               	SerializedProperty prop = serObj.GetIterator();

                prop.NextVisible(true );
               	do
                {
                    if(prop.name != "m_Script" && prop.name != "Enabled")
                    {
                        EditorGUILayout.PropertyField(prop,true);
                    }
                } while (prop.NextVisible(false ));
                prop.Reset();
           	}
            else
            {
                EditorGUILayout.PrefixLabel("Rule Null ");
            }
            EditorGUI.indentLevel--;
            EditorGUI.indentLevel--;
            EditorGUI.indentLevel--;
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(serObj.targetObject);
        }

        //save changes to serialized object
        serObj.ApplyModifiedProperties();
    }
Exemplo n.º 37
0
    private void DisplayCondition(Rect a_position, SerializedProperty a_property, GUIContent a_label)
    {
        List <string>      allConditionCommandTypeStrings = new List <string>();
        List <System.Type> allConditionCommandType        = typeof(ConditionCommand).Assembly.GetTypes().Where(type => type.IsSubclassOf(typeof(ConditionCommand))).ToList();

        foreach (System.Type type in allConditionCommandType)
        {
            allConditionCommandTypeStrings.Add(type.Name);
        }


        //Create PopUp To choice Class
        EditorGUI.BeginChangeCheck();

        int newIndex = 0;

        SerializedProperty commandProperty = CreatePopUp(a_property, "m_conditionCommand", allConditionCommandTypeStrings, (o) => { return(o.objectReferenceValue != null ? o.objectReferenceValue.GetType().Name : null); }, out newIndex);

        if (EditorGUI.EndChangeCheck())
        {
            commandProperty.objectReferenceValue = ScriptableObject.CreateInstance(allConditionCommandType[newIndex]);
        }


        //If Class choosen,display fields and methods popUp
        if (commandProperty.objectReferenceValue != null)
        {
            EditorGUI.indentLevel += 2;

            SerializedObject commandObject = new UnityEditor.SerializedObject(commandProperty.objectReferenceValue);
            GeneratePropetiesFields(commandObject);

            List <string> methodsNames = new List <string>();
            MethodInfo[]  methodInfos  = allConditionCommandType[newIndex].GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);

            for (int j = 0; j < methodInfos.Length; ++j)
            {
                methodsNames.Add(methodInfos[j].Name);
            }

            EditorGUI.BeginChangeCheck();

            SerializedProperty methodProperty = CreatePopUp(commandObject, "m_method", methodsNames, (o) => { return(o.stringValue); }, out newIndex);

            if (EditorGUI.EndChangeCheck())
            {
                methodProperty.stringValue = methodsNames[newIndex];
                commandObject.ApplyModifiedProperties();
            }



            //Parametters of the method
            if (newIndex >= 0)
            {
                EditorGUI.indentLevel += 2;

                MethodInfo method = methodInfos[newIndex];

                for (int i = 0; i < method.GetParameters().Length; i++)
                {
                    ParameterInfo parametter = method.GetParameters()[i];

                    SerializedProperty paramProperty = commandObject.GetIterator();

                    while (paramProperty.Next(true))
                    {
                        if (paramProperty.name == parametter.Name)
                        {
                            CreatePropertyField(paramProperty);
                            break;
                        }
                    }
                }
            }

            commandObject.ApplyModifiedProperties();
        }
    }
Exemplo n.º 38
0
 bool DrawModule(string propertyName, string label, Type baseType)
 {
     SerializedProperty module = serializedObject.FindProperty(propertyName);
     if (module == null) { EditorGUILayout.HelpBox("Script property misconfiguration", MessageType.Error); return false; }
     GUILayout.Label(label, EditorStyles.boldLabel);
     if (module.objectReferenceValue != null)
     {
         bool ret = true;
         var so = new SerializedObject(module.objectReferenceValue);
         GUI.backgroundColor = Color.grey;
         GUILayout.BeginVertical(EditorStyles.helpBox);
         GUI.backgroundColor = Color.white;
         GUILayout.BeginHorizontal(EditorStyles.helpBox);
         GUILayout.Label(so.targetObject.GetType().Name);
         ret &= !GUILayout.Button("x", GUILayout.Width(20));
         GUILayout.EndHorizontal();
         string desc = GetModuleDescription(so.targetObject.GetType());
         if (desc != string.Empty)
         {
             EditorGUILayout.HelpBox(desc, MessageType.None);
         }
         SerializedProperty sp = so.GetIterator();
         sp.NextVisible(true);
         if (sp != null)
         {
             while (sp.NextVisible(false))
             {
                 if (sp.isArray & sp.propertyType != SerializedPropertyType.String)
                 {
                     GUILayout.Label(sp.displayName, GUILayout.ExpandWidth(true));
                     GUILayout.BeginHorizontal();
                     GUILayout.Space(12);
                     sp.isExpanded = EditorGUILayout.Foldout(sp.isExpanded, "");
                     GUILayout.EndHorizontal();
                     if (sp.isExpanded)
                     {
                         for (int i = 0; i < sp.arraySize; i++)
                         {
                             bool deleteEntry = false;
                             GUILayout.BeginHorizontal();
                             EditorGUILayout.PropertyField(sp.GetArrayElementAtIndex(i));
                             deleteEntry |= GUILayout.Button("x", EditorStyles.miniButton);
                             GUILayout.EndHorizontal();
                             if (deleteEntry)
                             {
                                 sp.DeleteArrayElementAtIndex(i);
                                 break;
                             }
                         }
                     }
                     if (GUILayout.Button("Add"))
                     {
                         sp.InsertArrayElementAtIndex(sp.arraySize);
                     }
                 }
                 else
                 {
                     GUILayout.BeginHorizontal();
                     GUILayout.Label(sp.displayName, GUILayout.ExpandWidth(true));
                     EditorGUILayout.PropertyField(sp, GUIContent.none);
                     GUILayout.EndHorizontal();
                 }
             }
         }
         GUILayout.EndVertical();
         so.ApplyModifiedProperties();
         if (ret == false)
         {
             DestroyImmediate(module.objectReferenceValue);
         }
     }
     else
     {
         List<ModuleInfo> modules;
         if (cachedModuleTypes.TryGetValue(baseType, out modules))
         {
             string[] names = new string[modules.Count + 1];
             names[0] = "Select";
             for (int i = 0; i < modules.Count; i++)
             {
                 names[i+1] = modules[i].typeName;
             }
             int selected = EditorGUILayout.Popup(0, names);
             if (selected > 0)
             {
                 module.objectReferenceValue = CreateInstance(modules[selected - 1].type);
                 module.serializedObject.ApplyModifiedProperties();
             }
         }
     }
     return module.objectReferenceValue != null;
 }
Exemplo n.º 39
0
    private void DrawSearch()
    {

        search = EditorGUILayout.TextField("search", search);
        EditorGUIUtility.LookLikeInspector();
        var ago = Selection.activeGameObject;
        var ao = Selection.activeObject;
        if (search.Length > 0 && types.Contains(ao.GetType()) && ao != null && !(ago != null && ago.camera != null))
        {
            IEnumerable<Object> array = new Object[] { ao };
            if (ago != null)
            {
                array = array.Union(ago.GetComponents<Component>());
                if (ago.renderer != null)
                    array = array.Union(new[] { ago.renderer.sharedMaterial });
            }
            foreach (var m in array)
            {

                SerializedObject so = new SerializedObject(m);
                SerializedProperty pr = so.GetIterator();

                pr.NextVisible(true);
                do
                {
                    if (pr.propertyPath.ToLower().Contains(search.ToLower())
                        || (pr.propertyType == SerializedPropertyType.String && pr.stringValue.ToLower().Contains(search.ToLower()))
                        || (pr.propertyType == SerializedPropertyType.Enum && pr.enumNames.Length >= 0 && pr.enumNames[pr.enumValueIndex].ToLower().Contains(search.ToLower()))
                        && pr.editable)
                        EditorGUILayout.PropertyField(pr);

                    if (so.ApplyModifiedProperties())
                    {
                        //Debug.Log(pr.name);
                        SetMultiSelect(m, pr);
                    }
                }
                while (pr.NextVisible(true));
            }
        }
    }