Exemplo n.º 1
0
    void OnEnable()
    {
        this.exposedPropertiesEditor = new PEExposedPropertiesEditor(this.targets.OfType <PEPrefabScript>().ToArray());
        rootNode = new PETreeNode(false)
        {
            content = new GUIContent("Modifications")
        };
        rootNode.children.Add(new PETreeNode());

        Action <bool> d = obj =>
        {
            if (obj)
            {
                prefabScript.BuildModifications();

                UpdateTree();
                prefabScript.OnBuildModifications += UpdateTree;
            }
            else
            {
                prefabScript.OnBuildModifications -= UpdateTree;
            }
        };

        rootNode.OnExpandChanged += d;
    }
Exemplo n.º 2
0
    PETreeNode Add(SerializedProperty property, PETreeNode parent)
    {
        var node = new PETreeNode.PropertyNode {
            UserData = property
        };

        parent.children.Add(node);
        return(node);
    }
Exemplo n.º 3
0
    void UpdateTree()
    {
        serializedObject.Update();

        rootNode = new PETreeNode(rootNode.Expanded)
        {
            content = new GUIContent("Modifications")
        };
        Add(prefabScript.gameObject, rootNode);
    }
Exemplo n.º 4
0
        public override TreeViewNodeFilterResult GetFilterResult(PETreeNode node)
        {
            var  visibleFlags = VisibleMembersFlags.PE | VisibleMembersFlags.Hex;
            bool isMatch      = (flags & VisibleMembersFlags.PE) != 0;

            if ((flags & visibleFlags) == 0)
            {
                return(new TreeViewNodeFilterResult(FilterResult.Hidden, isMatch));
            }
            if (isMatch)
            {
                return(new TreeViewNodeFilterResult(FilterResult.Match, isMatch));
            }
            return(new TreeViewNodeFilterResult(FilterResult.Recurse, isMatch));
        }
Exemplo n.º 5
0
    PETreeNode Add(Component component, PETreeNode parent, bool includeChildren = true)
    {
        var isNewComponent = prefabScript.Modifications.NonPrefabComponents.Any(c => c.child == component) &&
                             !(component is PEPrefabScript);

        if (!isNewComponent && !includeChildren)
        {
            return(null);
        }
        var isExpanded = expandedDict[component];
        var node       = new PETreeNode(isExpanded)
        {
            content  = new GUIContent(component.GetType().Name, EditorGUIUtility.ObjectContent(component, component.GetType()).image),
            UserData = component
        };

        node.OnExpandChanged += expanded => expandedDict[component] = expanded;

        if (isNewComponent)
        {
            node.content.text += " (New)";
            node.color         = Color.yellow;
        }
        else
        {
            var propertiesOverrides = GetProperties(component).ToArray();

            if (propertiesOverrides.Length == 0)
            {
                return(null);
            }

            foreach (var property in propertiesOverrides)
            {
                Add(property, node);
            }
        }

        parent.children.Add(node);
        return(node);
    }
Exemplo n.º 6
0
    PETreeNode Add(Component component, PETreeNode parent)
    {
        var node = new PETreeNode {
            content  = new GUIContent(component.GetType().Name, EditorGUIUtility.ObjectContent(component, component.GetType()).image),
            UserData = component
        };

        if (prefabScript.Modifications.NonPrefabComponents.Any(c => c.child == component) && !(component is PEPrefabScript))
        {
            node.content.text += " (New)";
            node.color         = Color.yellow;
        }

        foreach (var property in GetProperties(component))
        {
            Add(property, node);
        }

        parent.children.Add(node);
        return(node);
    }
Exemplo n.º 7
0
 public virtual TreeViewNodeFilterResult GetFilterResult(PETreeNode node)
 {
     return(filter.GetFilterResult(node));
 }
Exemplo n.º 8
0
	PETreeNode Add(Component component, PETreeNode parent)
	{
		var node = new PETreeNode {
			content = new GUIContent(component.GetType().Name, EditorGUIUtility.ObjectContent(component, component.GetType()).image),
			UserData = component
		};

		if (prefabScript.Modifications.NonPrefabComponents.Any(c => c.child == component) && !(component is PEPrefabScript))
		{
			node.content.text += " (New)";
			node.color = Color.yellow;
		}

		foreach (var property in GetProperties(component))
		{
			Add(property, node);
		}

		parent.children.Add(node);
		return node;
	}
Exemplo n.º 9
0
	PETreeNode Add(SerializedProperty property, PETreeNode parent)
	{
		var node = new PETreeNode.PropertyNode { UserData = property };
		parent.children.Add(node);
		return node;
	}
Exemplo n.º 10
0
	void UpdateTree()
	{
		serializedObject.Update();

		rootNode = new PETreeNode(rootNode.Expanded) { content = new GUIContent("Modifications") };
		Add(prefabScript.gameObject, rootNode);
	}
Exemplo n.º 11
0
	void OnEnable()
	{
		this.exposedPropertiesEditor = new PEExposedPropertiesEditor(this.targets.OfType<PEPrefabScript>().ToArray());
		rootNode = new PETreeNode(false) { content = new GUIContent("Modifications") };
		rootNode.children.Add(new PETreeNode());
		System.Action<bool> d;
		d = obj =>
		{
			if (obj)
			{
				UpdateTree();
				prefabScript.OnBuildModifications += UpdateTree;
			}
		};
		rootNode.OnExpandChanged += d;
	}
Exemplo n.º 12
0
	PETreeNode Add(GameObject go, PETreeNode parent, bool includeChildren = true)
	{
		var node = new PETreeNode { content = new GUIContent(go.name, PEResources.icon), UserData = go };
		parent.children.Add(node);

		var pi = go.GetComponent<PEPrefabScript>();
		if (pi)
		{
			if (PrefabUtility.FindPrefabRoot(pi.gameObject) == pi.Prefab || PrefabUtility.GetPrefabParent(pi.gameObject) == pi.Prefab)
			{
				node.color = Color.green;
				node.content.text += " (Root)";
			}
			else
			{
				node.color = Color.yellow;
				node.content.text += " (Nested)";
			}
		}
		if (prefabScript.Modifications.TransformParentChanges.Any(npo => npo.child == go.transform))
		{
			node.color = Color.cyan;
			node.content.text += " (Parent Changed)";
		}

		if (prefabScript.Modifications.NonPrefabObjects.Any(c => c.child == go.transform))
		{
			node.color = Color.yellow;
			node.content.text += " (New)";
		}

		if (!includeChildren)
			return node;

		foreach (var property in GetProperties(go))
		{
			Add(property, node);
		}

		foreach (Component component in go.GetComponents<Component>())
		{
			var nd = Add(component, node);
			if (nd.children.Count == 0 && nd.color == Color.white)
				node.children.Remove(nd);
		}

		foreach (Transform transform in go.transform)
		{
			var nd = Add(transform.gameObject, node);
			if (nd.children.Count == 0 && nd.color == Color.white)
				node.children.Remove(nd);
		}

		foreach (var obj in GetRemovedObjects(go, prefabScript))
		{
			var component = obj as Component;
			if (component != null)
			{
				var nd = Add(component, node);
				nd.color = Color.red;
				nd.content.text += " (Removed)";
			}

			var gameObject = obj as GameObject;
			if (gameObject != null)
			{
				var nd = Add(gameObject, node, false);
				nd.color = Color.red;
				nd.content.text += " (Removed)";
			}
		}
		
		return node;
	}
Exemplo n.º 13
0
    PETreeNode Add(GameObject go, PETreeNode parent, bool includeChildren = true)
    {
        var node = new PETreeNode {
            content = new GUIContent(go.name, PEResources.icon), UserData = go
        };

        parent.children.Add(node);

        var pi = go.GetComponent <PEPrefabScript>();

        if (pi)
        {
            if (PrefabUtility.FindPrefabRoot(pi.gameObject) == pi.Prefab || PrefabUtility.GetPrefabParent(pi.gameObject) == pi.Prefab)
            {
                node.color         = Color.green;
                node.content.text += " (Root)";
            }
            else
            {
                node.color         = Color.yellow;
                node.content.text += " (Nested)";
            }
        }
        if (prefabScript.Modifications.TransformParentChanges.Any(npo => npo.child == go.transform))
        {
            node.color         = Color.cyan;
            node.content.text += " (Parent Changed)";
        }

        if (prefabScript.Modifications.NonPrefabObjects.Any(c => c.child == go.transform))
        {
            node.color         = Color.yellow;
            node.content.text += " (New)";
        }

        if (!includeChildren)
        {
            return(node);
        }

        foreach (var property in GetProperties(go))
        {
            Add(property, node);
        }

        foreach (Component component in go.GetComponents <Component>())
        {
            var nd = Add(component, node);
            if (nd.children.Count == 0 && nd.color == Color.white)
            {
                node.children.Remove(nd);
            }
        }

        foreach (Transform transform in go.transform)
        {
            var nd = Add(transform.gameObject, node);
            if (nd.children.Count == 0 && nd.color == Color.white)
            {
                node.children.Remove(nd);
            }
        }

        foreach (var obj in GetRemovedObjects(go, prefabScript))
        {
            var component = obj as Component;
            if (component != null)
            {
                var nd = Add(component, node);
                nd.color         = Color.red;
                nd.content.text += " (Removed)";
            }

            var gameObject = obj as GameObject;
            if (gameObject != null)
            {
                var nd = Add(gameObject, node, false);
                nd.color         = Color.red;
                nd.content.text += " (Removed)";
            }
        }

        return(node);
    }
Exemplo n.º 14
0
 public virtual TreeViewNodeFilterResult GetFilterResult(PETreeNode node)
 {
     return(new TreeViewNodeFilterResult());
 }
 public virtual TreeViewNodeFilterResult GetFilterResult(PETreeNode node)
 {
     return(new TreeViewNodeFilterResult(FilterResult.Hidden, false));
 }
Exemplo n.º 16
0
	PETreeNode Add(Component component, PETreeNode parent, bool includeChildren = true)
	{
		var isNewComponent = prefabScript.Modifications.NonPrefabComponents.Any(c => c.child == component) &&
							 !(component is PEPrefabScript);

		if (!isNewComponent && !includeChildren)
			return null;
		var isExpanded = expandedDict[component];
		var node = new PETreeNode(isExpanded)
		{
			content = new GUIContent(component.GetType().Name, EditorGUIUtility.ObjectContent(component, component.GetType()).image),
			UserData = component
		};
		node.OnExpandChanged += expanded => expandedDict[component] = expanded;

		if (isNewComponent)
		{
			node.content.text += " (New)";
			node.color = Color.yellow;
		}
		else
		{
			var propertiesOverrides = GetProperties(component).ToArray();

			if (propertiesOverrides.Length == 0)
				return null;

			foreach (var property in propertiesOverrides)
			{
				Add(property, node);
			}
		}

		parent.children.Add(node);
		return node;
	}