private void ShowDefaultTextures()
        {
            if (this.propertyNames.Count != 0)
            {
                EditorGUILayout.LabelField("Default Maps", EditorStyles.boldLabel, new GUILayoutOption[0]);
                for (int i = 0; i < this.propertyNames.Count; i++)
                {
                    Type    type;
                    Texture texture  = this.textures[i];
                    Texture texture2 = null;
                    EditorGUI.BeginChangeCheck();
                    switch (this.dimensions[i])
                    {
                    case ShaderUtil.ShaderPropertyTexDim.TexDim2D:
                        type = typeof(Texture);
                        break;

                    case ShaderUtil.ShaderPropertyTexDim.TexDim3D:
                        type = typeof(Texture3D);
                        break;

                    case ShaderUtil.ShaderPropertyTexDim.TexDimCUBE:
                        type = typeof(Cubemap);
                        break;

                    case ShaderUtil.ShaderPropertyTexDim.TexDimAny:
                        type = typeof(Texture);
                        break;

                    default:
                        type = null;
                        break;
                    }
                    if (type != null)
                    {
                        string t = !string.IsNullOrEmpty(this.displayNames[i]) ? this.displayNames[i] : ObjectNames.NicifyVariableName(this.propertyNames[i]);
                        texture2 = EditorGUILayout.MiniThumbnailObjectField(GUIContent.Temp(t), texture, type, null, new GUILayoutOption[0]) as Texture;
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        this.textures[i] = texture2;
                    }
                }
            }
        }
示例#2
0
        protected BoneState GetBoneState(int i, out string error)
        {
            // ISSUE: object of a compiler-generated type is created
            // ISSUE: variable of a compiler-generated type
            AvatarMappingEditor.\u003CGetBoneState\u003Ec__AnonStorey9D stateCAnonStorey9D = new AvatarMappingEditor.\u003CGetBoneState\u003Ec__AnonStorey9D();
            error = string.Empty;
            // ISSUE: reference to a compiler-generated field
            stateCAnonStorey9D.bone = this.m_Bones[i];
            // ISSUE: reference to a compiler-generated field
            if ((UnityEngine.Object)stateCAnonStorey9D.bone.bone == (UnityEngine.Object)null)
            {
                return(BoneState.None);
            }
            AvatarSetupTool.BoneWrapper bone = this.m_Bones[AvatarSetupTool.GetFirstHumanBoneAncestor(this.m_Bones, i)];
            // ISSUE: reference to a compiler-generated field
            if (i == 0 && (UnityEngine.Object)stateCAnonStorey9D.bone.bone.parent == (UnityEngine.Object)null)
            {
                // ISSUE: reference to a compiler-generated field
                error = stateCAnonStorey9D.bone.messageName + " cannot be the root transform";
                return(BoneState.InvalidHierarchy);
            }
            // ISSUE: reference to a compiler-generated field
            if ((UnityEngine.Object)bone.bone != (UnityEngine.Object)null && !stateCAnonStorey9D.bone.bone.IsChildOf(bone.bone))
            {
                // ISSUE: reference to a compiler-generated field
                error = stateCAnonStorey9D.bone.messageName + " is not a child of " + bone.messageName + ".";
                return(BoneState.InvalidHierarchy);
            }
            // ISSUE: reference to a compiler-generated field
            // ISSUE: reference to a compiler-generated field
            if (i != 23 && (UnityEngine.Object)bone.bone != (UnityEngine.Object)null && (UnityEngine.Object)bone.bone != (UnityEngine.Object)stateCAnonStorey9D.bone.bone && (double)(stateCAnonStorey9D.bone.bone.position - bone.bone.position).sqrMagnitude < (double)Mathf.Epsilon)
            {
                // ISSUE: reference to a compiler-generated field
                error = stateCAnonStorey9D.bone.messageName + " has bone length of zero.";
                return(BoneState.BoneLenghtIsZero);
            }
            // ISSUE: reference to a compiler-generated method
            if (((IEnumerable <AvatarSetupTool.BoneWrapper>) this.m_Bones).Where <AvatarSetupTool.BoneWrapper>(new Func <AvatarSetupTool.BoneWrapper, bool>(stateCAnonStorey9D.\u003C\u003Em__1CA)).Count <AvatarSetupTool.BoneWrapper>() <= 1)
            {
                return(BoneState.Valid);
            }
            // ISSUE: reference to a compiler-generated field
            error = stateCAnonStorey9D.bone.messageName + " is also assigned to ";
            bool flag = true;

            for (int index = 0; index < this.m_Bones.Length; ++index)
            {
                if (i != index && (UnityEngine.Object) this.m_Bones[i].bone == (UnityEngine.Object) this.m_Bones[index].bone)
                {
                    if (flag)
                    {
                        flag = false;
                    }
                    else
                    {
                        error = error + ", ";
                    }
                    error = error + ObjectNames.NicifyVariableName(this.m_Bones[index].humanBoneName);
                }
            }
            error = error + ".";
            return(BoneState.Duplicate);
        }
        internal bool DrawInspector(Rect contentRect)
        {
            if (GameObjectInspector.s_styles == null)
            {
                GameObjectInspector.s_styles = new GameObjectInspector.Styles();
            }
            base.serializedObject.Update();
            GameObject gameObject = this.target as GameObject;

            EditorGUIUtility.labelWidth = 52f;
            bool enabled = GUI.enabled;

            GUI.enabled = true;
            GUI.Label(new Rect(contentRect.x, contentRect.y, contentRect.width, contentRect.height + 3f), GUIContent.none, EditorStyles.inspectorBig);
            GUI.enabled = enabled;
            float      width      = contentRect.width;
            float      y          = contentRect.y;
            GUIContent gUIContent = null;
            PrefabType prefabType = PrefabType.None;

            if (this.m_AllOfSamePrefabType)
            {
                prefabType = PrefabUtility.GetPrefabType(gameObject);
                switch (prefabType)
                {
                case PrefabType.None:
                    gUIContent = GameObjectInspector.s_styles.goIcon;
                    break;

                case PrefabType.Prefab:
                case PrefabType.PrefabInstance:
                case PrefabType.DisconnectedPrefabInstance:
                    gUIContent = GameObjectInspector.s_styles.prefabIcon;
                    break;

                case PrefabType.ModelPrefab:
                case PrefabType.ModelPrefabInstance:
                case PrefabType.DisconnectedModelPrefabInstance:
                    gUIContent = GameObjectInspector.s_styles.modelIcon;
                    break;

                case PrefabType.MissingPrefabInstance:
                    gUIContent = GameObjectInspector.s_styles.prefabIcon;
                    break;
                }
            }
            else
            {
                gUIContent = GameObjectInspector.s_styles.typelessIcon;
            }
            EditorGUI.ObjectIconDropDown(new Rect(3f, 4f + y, 24f, 24f), base.targets, true, gUIContent.image as Texture2D, this.m_Icon);
            EditorGUI.BeginDisabledGroup(prefabType == PrefabType.ModelPrefab);
            EditorGUI.PropertyField(new Rect(34f, 4f + y, 14f, 14f), this.m_IsActive, GUIContent.none);
            float num    = GameObjectInspector.s_styles.staticFieldToggleWidth + 15f;
            float width2 = width - 52f - num - 5f;

            EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = this.m_Name.hasMultipleDifferentValues;
            string name = EditorGUI.DelayedTextField(new Rect(52f, 4f + y + 1f, width2, 16f), gameObject.name, null, EditorStyles.textField);

            EditorGUI.showMixedValue = false;
            if (EditorGUI.EndChangeCheck())
            {
                UnityEngine.Object[] targets = base.targets;
                for (int i = 0; i < targets.Length; i++)
                {
                    UnityEngine.Object @object = targets[i];
                    ObjectNames.SetNameSmart(@object as GameObject, name);
                }
            }
            Rect rect = new Rect(width - num, 4f + y, GameObjectInspector.s_styles.staticFieldToggleWidth, 16f);

            EditorGUI.BeginProperty(rect, GUIContent.none, this.m_StaticEditorFlags);
            EditorGUI.BeginChangeCheck();
            Rect position = rect;

            EditorGUI.showMixedValue |= GameObjectInspector.ShowMixedStaticEditorFlags((StaticEditorFlags)this.m_StaticEditorFlags.intValue);
            Event     current = Event.current;
            EventType type    = current.type;
            bool      flag    = current.type == EventType.MouseDown && current.button != 0;

            if (flag)
            {
                current.type = EventType.Ignore;
            }
            bool flagValue = EditorGUI.ToggleLeft(position, "Static", gameObject.isStatic);

            if (flag)
            {
                current.type = type;
            }
            EditorGUI.showMixedValue = false;
            if (EditorGUI.EndChangeCheck())
            {
                SceneModeUtility.SetStaticFlags(base.targets, -1, flagValue);
                base.serializedObject.SetIsDifferentCacheDirty();
            }
            EditorGUI.EndProperty();
            EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = this.m_StaticEditorFlags.hasMultipleDifferentValues;
            int  changedFlags;
            bool flagValue2;

            EditorGUI.EnumMaskField(new Rect(rect.x + GameObjectInspector.s_styles.staticFieldToggleWidth, rect.y, 10f, 14f), GameObjectUtility.GetStaticEditorFlags(gameObject), GameObjectInspector.s_styles.staticDropdown, out changedFlags, out flagValue2);
            EditorGUI.showMixedValue = false;
            if (EditorGUI.EndChangeCheck())
            {
                SceneModeUtility.SetStaticFlags(base.targets, changedFlags, flagValue2);
                base.serializedObject.SetIsDifferentCacheDirty();
            }
            float num2 = 4f;
            float num3 = 4f;

            EditorGUIUtility.fieldWidth = (width - num2 - 52f - GameObjectInspector.s_styles.layerFieldWidth - num3) / 2f;
            string tag = null;

            try
            {
                tag = gameObject.tag;
            }
            catch (Exception)
            {
                tag = "Undefined";
            }
            EditorGUIUtility.labelWidth = GameObjectInspector.s_styles.tagFieldWidth;
            Rect rect2 = new Rect(52f - EditorGUIUtility.labelWidth, 24f + y, EditorGUIUtility.labelWidth + EditorGUIUtility.fieldWidth, 16f);

            EditorGUI.BeginProperty(rect2, GUIContent.none, this.m_Tag);
            EditorGUI.BeginChangeCheck();
            string text = EditorGUI.TagField(rect2, EditorGUIUtility.TempContent("Tag"), tag);

            if (EditorGUI.EndChangeCheck())
            {
                this.m_Tag.stringValue = text;
                Undo.RecordObjects(base.targets, "Change Tag of " + this.targetTitle);
                UnityEngine.Object[] targets2 = base.targets;
                for (int j = 0; j < targets2.Length; j++)
                {
                    UnityEngine.Object object2 = targets2[j];
                    (object2 as GameObject).tag = text;
                }
            }
            EditorGUI.EndProperty();
            EditorGUIUtility.labelWidth = GameObjectInspector.s_styles.layerFieldWidth;
            rect2 = new Rect(52f + EditorGUIUtility.fieldWidth + num2, 24f + y, EditorGUIUtility.labelWidth + EditorGUIUtility.fieldWidth, 16f);
            EditorGUI.BeginProperty(rect2, GUIContent.none, this.m_Layer);
            EditorGUI.BeginChangeCheck();
            int num4 = EditorGUI.LayerField(rect2, EditorGUIUtility.TempContent("Layer"), gameObject.layer);

            if (EditorGUI.EndChangeCheck())
            {
                GameObjectUtility.ShouldIncludeChildren shouldIncludeChildren = GameObjectUtility.DisplayUpdateChildrenDialogIfNeeded(base.targets.OfType <GameObject>(), "Change Layer", "Do you want to set layer to " + InternalEditorUtility.GetLayerName(num4) + " for all child objects as well?");
                if (shouldIncludeChildren != GameObjectUtility.ShouldIncludeChildren.Cancel)
                {
                    this.m_Layer.intValue = num4;
                    this.SetLayer(num4, shouldIncludeChildren == GameObjectUtility.ShouldIncludeChildren.IncludeChildren);
                }
            }
            EditorGUI.EndProperty();
            if (this.m_HasInstance && !EditorApplication.isPlayingOrWillChangePlaymode)
            {
                float      num5        = (width - 52f - 5f) / 3f;
                Rect       position2   = new Rect(52f + num5 * 0f, 44f + y, num5, 15f);
                Rect       position3   = new Rect(52f + num5 * 1f, 44f + y, num5, 15f);
                Rect       position4   = new Rect(52f + num5 * 2f, 44f + y, num5, 15f);
                Rect       position5   = new Rect(52f, 44f + y, num5 * 3f, 15f);
                GUIContent gUIContent2 = (base.targets.Length <= 1) ? GameObjectInspector.s_styles.goTypeLabel[(int)prefabType] : GameObjectInspector.s_styles.goTypeLabelMultiple;
                if (gUIContent2 != null)
                {
                    float x = GUI.skin.label.CalcSize(gUIContent2).x;
                    if (prefabType == PrefabType.DisconnectedModelPrefabInstance || prefabType == PrefabType.MissingPrefabInstance || prefabType == PrefabType.DisconnectedPrefabInstance)
                    {
                        GUI.contentColor = GUI.skin.GetStyle("CN StatusWarn").normal.textColor;
                        if (prefabType == PrefabType.MissingPrefabInstance)
                        {
                            GUI.Label(new Rect(52f, 44f + y, width - 52f - 5f, 18f), gUIContent2, EditorStyles.whiteLabel);
                        }
                        else
                        {
                            GUI.Label(new Rect(52f - x - 5f, 44f + y, width - 52f - 5f, 18f), gUIContent2, EditorStyles.whiteLabel);
                        }
                        GUI.contentColor = Color.white;
                    }
                    else
                    {
                        Rect position6 = new Rect(52f - x - 5f, 44f + y, x, 18f);
                        GUI.Label(position6, gUIContent2);
                    }
                }
                if (base.targets.Length > 1)
                {
                    GUI.Label(position5, "Instance Management Disabled", GameObjectInspector.s_styles.instanceManagementInfo);
                }
                else
                {
                    if (prefabType != PrefabType.MissingPrefabInstance && GUI.Button(position2, "Select", "MiniButtonLeft"))
                    {
                        Selection.activeObject = PrefabUtility.GetPrefabParent(this.target);
                        EditorGUIUtility.PingObject(Selection.activeObject);
                    }
                    if ((prefabType == PrefabType.DisconnectedModelPrefabInstance || prefabType == PrefabType.DisconnectedPrefabInstance) && GUI.Button(position3, "Revert", "MiniButtonMid"))
                    {
                        Undo.RegisterFullObjectHierarchyUndo(gameObject, "Revert to prefab");
                        PrefabUtility.ReconnectToLastPrefab(gameObject);
                        PrefabUtility.RevertPrefabInstance(gameObject);
                        this.CalculatePrefabStatus();
                        Undo.RegisterCreatedObjectUndo(gameObject, "Reconnect prefab");
                        GUIUtility.ExitGUI();
                    }
                    bool enabled2 = GUI.enabled;
                    GUI.enabled = (GUI.enabled && !AnimationMode.InAnimationMode());
                    if ((prefabType == PrefabType.ModelPrefabInstance || prefabType == PrefabType.PrefabInstance) && GUI.Button(position3, "Revert", "MiniButtonMid"))
                    {
                        Undo.RegisterFullObjectHierarchyUndo(gameObject, "Revert Prefab Instance");
                        PrefabUtility.RevertPrefabInstance(gameObject);
                        this.CalculatePrefabStatus();
                        GUIUtility.ExitGUI();
                    }
                    if (prefabType == PrefabType.PrefabInstance || prefabType == PrefabType.DisconnectedPrefabInstance)
                    {
                        GameObject gameObject2 = PrefabUtility.FindValidUploadPrefabInstanceRoot(gameObject);
                        GUI.enabled = (gameObject2 != null && !AnimationMode.InAnimationMode());
                        if (GUI.Button(position4, "Apply", "MiniButtonRight"))
                        {
                            UnityEngine.Object prefabParent = PrefabUtility.GetPrefabParent(gameObject2);
                            string             assetPath    = AssetDatabase.GetAssetPath(prefabParent);
                            bool flag2 = Provider.PromptAndCheckoutIfNeeded(new string[]
                            {
                                assetPath
                            }, "The version control requires you to checkout the prefab before applying changes.");
                            if (flag2)
                            {
                                PrefabUtility.ReplacePrefab(gameObject2, prefabParent, ReplacePrefabOptions.ConnectToPrefab);
                                this.CalculatePrefabStatus();
                                GUIUtility.ExitGUI();
                            }
                        }
                    }
                    GUI.enabled = enabled2;
                    if ((prefabType == PrefabType.DisconnectedModelPrefabInstance || prefabType == PrefabType.ModelPrefabInstance) && GUI.Button(position4, "Open", "MiniButtonRight"))
                    {
                        AssetDatabase.OpenAsset(PrefabUtility.GetPrefabParent(this.target));
                        GUIUtility.ExitGUI();
                    }
                }
            }
            EditorGUI.EndDisabledGroup();
            base.serializedObject.ApplyModifiedProperties();
            return(true);
        }
示例#4
0
 private string GetStrippedAndNiceBoneName(Transform bone)
 {
     string[] strings = bone.name.Split(':');
     return(ObjectNames.NicifyVariableName(strings[strings.Length - 1]));
 }
示例#5
0
        protected void DisplayFoldout()
        {
            Dictionary <Transform, bool> modelBones = this.modelBones;

            EditorGUIUtility.SetIconSize(Vector2.one * 16f);
            EditorGUILayout.BeginHorizontal();
            GUI.color = Color.grey;
            GUILayout.Label(AvatarMappingEditor.styles.dotFrameDotted.image, new GUILayoutOption[1]
            {
                GUILayout.ExpandWidth(false)
            });
            GUI.color = Color.white;
            GUILayout.Label("Optional Bone", new GUILayoutOption[1]
            {
                GUILayout.ExpandWidth(true)
            });
            EditorGUILayout.EndHorizontal();
            for (int index1 = 1; index1 < this.m_BodyPartToggle.Length; ++index1)
            {
                if (this.m_BodyPartToggle[index1])
                {
                    if (AvatarMappingEditor.s_DirtySelection && !this.m_BodyPartFoldout[index1])
                    {
                        for (int index2 = 0; index2 < this.m_BodyPartHumanBone[index1].Length; ++index2)
                        {
                            int num = this.m_BodyPartHumanBone[index1][index2];
                            if (AvatarMappingEditor.s_SelectedBoneIndex == num)
                            {
                                this.m_BodyPartFoldout[index1] = true;
                            }
                        }
                    }
                    this.m_BodyPartFoldout[index1] = GUILayout.Toggle(this.m_BodyPartFoldout[index1], AvatarMappingEditor.styles.BodyPartMapping[index1], EditorStyles.foldout, new GUILayoutOption[0]);
                    ++EditorGUI.indentLevel;
                    if (this.m_BodyPartFoldout[index1])
                    {
                        for (int index2 = 0; index2 < this.m_BodyPartHumanBone[index1].Length; ++index2)
                        {
                            int boneIndex = this.m_BodyPartHumanBone[index1][index2];
                            if (boneIndex != -1)
                            {
                                AvatarSetupTool.BoneWrapper bone = this.m_Bones[boneIndex];
                                string name = bone.humanBoneName;
                                if (index1 == 5 || index1 == 6 || index1 == 8)
                                {
                                    name = name.Replace("Right", string.Empty);
                                }
                                if (index1 == 3 || index1 == 4 || index1 == 7)
                                {
                                    name = name.Replace("Left", string.Empty);
                                }
                                string text        = ObjectNames.NicifyVariableName(name);
                                Rect   controlRect = EditorGUILayout.GetControlRect();
                                Rect   selectRect  = controlRect;
                                selectRect.width -= 15f;
                                bone.HandleClickSelection(selectRect, boneIndex);
                                bone.BoneDotGUI(new Rect(controlRect.x + EditorGUI.indent, controlRect.y - 1f, 19f, 19f), boneIndex, false, false, this.serializedObject, this);
                                controlRect.xMin += 19f;
                                Transform key = EditorGUI.ObjectField(controlRect, new GUIContent(text), (UnityEngine.Object)bone.bone, typeof(Transform), true) as Transform;
                                if ((UnityEngine.Object)key != (UnityEngine.Object)bone.bone)
                                {
                                    Undo.RegisterCompleteObjectUndo((UnityEngine.Object) this, "Avatar mapping modified");
                                    bone.bone = key;
                                    bone.Serialize(this.serializedObject);
                                    if ((UnityEngine.Object)key != (UnityEngine.Object)null && !modelBones.ContainsKey(key))
                                    {
                                        modelBones[key] = true;
                                    }
                                }
                                if (!string.IsNullOrEmpty(bone.error))
                                {
                                    GUILayout.BeginHorizontal();
                                    GUILayout.Space((float)((double)EditorGUI.indent + 19.0 + 4.0));
                                    GUILayout.Label(bone.error, AvatarMappingEditor.s_Styles.errorLabel, new GUILayoutOption[0]);
                                    GUILayout.EndHorizontal();
                                }
                            }
                        }
                    }
                    --EditorGUI.indentLevel;
                }
            }
            AvatarMappingEditor.s_DirtySelection = false;
            EditorGUIUtility.SetIconSize(Vector2.zero);
        }
        protected BoneState GetBoneState(int i, out string error)
        {
            error = string.Empty;
            AvatarSetupTool.BoneWrapper bone = this.m_Bones[i];
            BoneState result;

            if (bone.bone == null)
            {
                result = BoneState.None;
            }
            else
            {
                AvatarSetupTool.BoneWrapper boneWrapper = this.m_Bones[AvatarSetupTool.GetFirstHumanBoneAncestor(this.m_Bones, i)];
                if (i == 0 && bone.bone.parent == null)
                {
                    error  = bone.messageName + " cannot be the root transform";
                    result = BoneState.InvalidHierarchy;
                }
                else if (boneWrapper.bone != null && !bone.bone.IsChildOf(boneWrapper.bone))
                {
                    error  = bone.messageName + " is not a child of " + boneWrapper.messageName + ".";
                    result = BoneState.InvalidHierarchy;
                }
                else if (i != 23 && boneWrapper.bone != null && boneWrapper.bone != bone.bone && (bone.bone.position - boneWrapper.bone.position).sqrMagnitude < Mathf.Epsilon)
                {
                    error  = bone.messageName + " has bone length of zero.";
                    result = BoneState.BoneLenghtIsZero;
                }
                else
                {
                    IEnumerable <AvatarSetupTool.BoneWrapper> source = from f in this.m_Bones
                                                                       where f.bone == bone.bone
                                                                       select f;
                    if (source.Count <AvatarSetupTool.BoneWrapper>() > 1)
                    {
                        error = bone.messageName + " is also assigned to ";
                        bool flag = true;
                        for (int j = 0; j < this.m_Bones.Length; j++)
                        {
                            if (i != j && this.m_Bones[i].bone == this.m_Bones[j].bone)
                            {
                                if (flag)
                                {
                                    flag = false;
                                }
                                else
                                {
                                    error += ", ";
                                }
                                error += ObjectNames.NicifyVariableName(this.m_Bones[j].humanBoneName);
                            }
                        }
                        error += ".";
                        result = BoneState.Duplicate;
                    }
                    else
                    {
                        result = BoneState.Valid;
                    }
                }
            }
            return(result);
        }
        // Returns true if input gameobject or any of its descendants have modifications, otherwise returns false.
        bool AddTreeViewItemRecursive(TreeViewItem parentItem, GameObject gameObject, Dictionary <int, PrefabOverrides> prefabOverrideMap, IdSequence idSequence)
        {
            var gameObjectItem = new PrefabOverridesTreeViewItem
                                 (
                idSequence.get(),
                parentItem.depth + 1,
                gameObject.name
                                 );

            gameObjectItem.obj = gameObject;
            // We don't know yet if this item should be added to the parent.
            bool shouldAddGameObjectItemToParent = false;

            PrefabOverrides objectModifications;

            prefabOverrideMap.TryGetValue(gameObject.GetInstanceID(), out objectModifications);
            if (objectModifications != null)
            {
                // Added GameObject - note that this earlies out!
                AddedGameObject addedGameObjectData = objectModifications.addedGameObjects.Find(x => x.instanceGameObject == gameObject);
                if (addedGameObjectData != null)
                {
                    gameObjectItem.singleModification = addedGameObjectData;
                    gameObjectItem.type = ItemType.ADDED_OBJECT;

                    parentItem.AddChild(gameObjectItem);
                    return(true);
                }
                else
                {
                    // Modified GameObject
                    ObjectOverride modifiedGameObjectData = objectModifications.objectOverrides.Find(x => x.instanceObject == gameObject);
                    if (modifiedGameObjectData != null)
                    {
                        gameObjectItem.singleModification = modifiedGameObjectData;
                        gameObjectItem.type             = ItemType.PREFAB_OBJECT;
                        shouldAddGameObjectItemToParent = true;
                    }
                }

                // Added components and component modifications
                foreach (var component in gameObject.GetComponents(typeof(Component)))
                {
                    var componentItem = new PrefabOverridesTreeViewItem
                                        (
                        idSequence.get(),
                        gameObjectItem.depth + 1,
                        ObjectNames.GetInspectorTitle(component)
                                        );
                    componentItem.obj = component;

                    AddedComponent addedComponentData = objectModifications.addedComponents.Find(x => x.instanceComponent == component);
                    if (addedComponentData != null)
                    {
                        componentItem.singleModification = addedComponentData;
                        componentItem.type = ItemType.ADDED_OBJECT;
                        gameObjectItem.AddChild(componentItem);
                        shouldAddGameObjectItemToParent = true;
                    }
                    else
                    {
                        ObjectOverride modifiedObjectData = objectModifications.objectOverrides.Find(x => x.instanceObject == component);
                        if (modifiedObjectData != null)
                        {
                            componentItem.singleModification = modifiedObjectData;
                            componentItem.type = ItemType.PREFAB_OBJECT;
                            gameObjectItem.AddChild(componentItem);
                            shouldAddGameObjectItemToParent = true;
                        }
                    }
                }

                // Removed components
                foreach (var removedComponent in objectModifications.removedComponents)
                {
                    var removedComponentItem = new PrefabOverridesTreeViewItem
                                               (
                        idSequence.get(),
                        gameObjectItem.depth + 1,
                        ObjectNames.GetInspectorTitle(removedComponent.assetComponent)
                                               );
                    removedComponentItem.obj = removedComponent.assetComponent;
                    removedComponentItem.singleModification = removedComponent;
                    removedComponentItem.type = ItemType.REMOVED_OBJECT;
                    gameObjectItem.AddChild(removedComponentItem);
                    shouldAddGameObjectItemToParent = true;
                }
            }

            // Recurse into children
            foreach (Transform childTransform in gameObject.transform)
            {
                var childGameObject = childTransform.gameObject;
                shouldAddGameObjectItemToParent |= AddTreeViewItemRecursive(gameObjectItem, childGameObject, prefabOverrideMap, idSequence);
            }

            if (shouldAddGameObjectItemToParent)
            {
                parentItem.AddChild(gameObjectItem);
                return(true);
            }

            return(false);
        }
        protected void DisplayFoldout()
        {
            Dictionary <Transform, bool> modelBones = base.modelBones;

            EditorGUIUtility.SetIconSize(Vector2.one * 16f);
            EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUI.color = Color.grey;
            GUILayout.Label(AvatarMappingEditor.styles.dotFrameDotted.image, new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(false)
            });
            GUI.color = Color.white;
            GUILayout.Label("Optional Bone", new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(true)
            });
            EditorGUILayout.EndHorizontal();
            for (int i = 1; i < this.m_BodyPartToggle.Length; i++)
            {
                if (this.m_BodyPartToggle[i])
                {
                    if (AvatarMappingEditor.s_DirtySelection && !this.m_BodyPartFoldout[i])
                    {
                        for (int j = 0; j < this.m_BodyPartHumanBone[i].Length; j++)
                        {
                            int num = this.m_BodyPartHumanBone[i][j];
                            if (AvatarMappingEditor.s_SelectedBoneIndex == num)
                            {
                                this.m_BodyPartFoldout[i] = true;
                            }
                        }
                    }
                    this.m_BodyPartFoldout[i] = GUILayout.Toggle(this.m_BodyPartFoldout[i], AvatarMappingEditor.styles.BodyPartMapping[i], EditorStyles.foldout, new GUILayoutOption[0]);
                    EditorGUI.indentLevel++;
                    if (this.m_BodyPartFoldout[i])
                    {
                        for (int k = 0; k < this.m_BodyPartHumanBone[i].Length; k++)
                        {
                            int num2 = this.m_BodyPartHumanBone[i][k];
                            if (num2 != -1)
                            {
                                AvatarSetupTool.BoneWrapper boneWrapper = this.m_Bones[num2];
                                string text = boneWrapper.humanBoneName;
                                if (i == 5 || i == 6 || i == 8)
                                {
                                    text = text.Replace("Right", "");
                                }
                                if (i == 3 || i == 4 || i == 7)
                                {
                                    text = text.Replace("Left", "");
                                }
                                text = ObjectNames.NicifyVariableName(text);
                                Rect controlRect = EditorGUILayout.GetControlRect(new GUILayoutOption[0]);
                                Rect selectRect  = controlRect;
                                selectRect.width -= 15f;
                                boneWrapper.HandleClickSelection(selectRect, num2);
                                boneWrapper.BoneDotGUI(new Rect(controlRect.x + EditorGUI.indent, controlRect.y - 1f, 19f, 19f), num2, false, false, base.serializedObject, this);
                                controlRect.xMin += 19f;
                                Transform transform = EditorGUI.ObjectField(controlRect, new GUIContent(text), boneWrapper.bone, typeof(Transform), true) as Transform;
                                if (transform != boneWrapper.bone)
                                {
                                    Undo.RegisterCompleteObjectUndo(this, "Avatar mapping modified");
                                    boneWrapper.bone = transform;
                                    boneWrapper.Serialize(base.serializedObject);
                                    if (transform != null && !modelBones.ContainsKey(transform))
                                    {
                                        modelBones[transform] = true;
                                    }
                                }
                                if (!string.IsNullOrEmpty(boneWrapper.error))
                                {
                                    GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                                    GUILayout.Space(EditorGUI.indent + 19f + 4f);
                                    GUILayout.Label(boneWrapper.error, AvatarMappingEditor.s_Styles.errorLabel, new GUILayoutOption[0]);
                                    GUILayout.EndHorizontal();
                                }
                            }
                        }
                    }
                    EditorGUI.indentLevel--;
                }
            }
            AvatarMappingEditor.s_DirtySelection = false;
            EditorGUIUtility.SetIconSize(Vector2.zero);
        }
示例#9
0
 public string GetString(Transform tr)
 {
     return(AnimationSelection.GetPath(tr) + "/:" + ObjectNames.GetInspectorTitle(this.obj));
 }
示例#10
0
 static Styles()
 {
     LightProbeProxyVolumeEditor.Styles.richTextMiniLabel    = new GUIStyle(EditorStyles.miniLabel);
     LightProbeProxyVolumeEditor.Styles.volumeResolutionText = EditorGUIUtility.TextContent("Proxy Volume Resolution|Specifies the resolution of the 3D grid of interpolated light probes. Higher resolution/density means better lighting but the CPU cost will increase.");
     LightProbeProxyVolumeEditor.Styles.resolutionXText      = new GUIContent("X");
     LightProbeProxyVolumeEditor.Styles.resolutionYText      = new GUIContent("Y");
     LightProbeProxyVolumeEditor.Styles.resolutionZText      = new GUIContent("Z");
     LightProbeProxyVolumeEditor.Styles.sizeText             = EditorGUIUtility.TextContent("Size");
     LightProbeProxyVolumeEditor.Styles.bbSettingsText       = EditorGUIUtility.TextContent("Bounding Box Settings");
     LightProbeProxyVolumeEditor.Styles.originText           = EditorGUIUtility.TextContent("Origin");
     LightProbeProxyVolumeEditor.Styles.bbModeText           = EditorGUIUtility.TextContent("Bounding Box Mode|The mode in which the bounding box is computed. A 3D grid of interpolated light probes will be generated inside this bounding box.\n\nAutomatic Local - the local-space bounding box of the Renderer is used.\n\nAutomatic Global - a bounding box is computed which encloses the current Renderer and all the Renderers down the hierarchy that have the Light Probes property set to Use Proxy Volume. The bounding box will be world-space aligned.\n\nCustom - a custom bounding box is used. The bounding box is specified in the local-space of the game object.");
     LightProbeProxyVolumeEditor.Styles.resModeText          = EditorGUIUtility.TextContent("Resolution Mode|The mode in which the resolution of the 3D grid of interpolated light probes is specified:\n\nAutomatic - the resolution on each axis is computed using a user-specified number of interpolated light probes per unit area(Density).\n\nCustom - the user can specify a different resolution on each axis.");
     LightProbeProxyVolumeEditor.Styles.probePositionText    = EditorGUIUtility.TextContent("Probe Position Mode|The mode in which the interpolated probe positions are generated.\n\nCellCorner - divide the volume in cells and generate interpolated probe positions in the corner/edge of the cells.\n\nCellCenter - divide the volume in cells and generate interpolated probe positions in the center of the cells.");
     LightProbeProxyVolumeEditor.Styles.refreshModeText      = EditorGUIUtility.TextContent("Refresh Mode");
     LightProbeProxyVolumeEditor.Styles.bbMode = (from x in (from x in Enum.GetNames(typeof(LightProbeProxyVolume.BoundingBoxMode))
                                                             select ObjectNames.NicifyVariableName(x)).ToArray <string>()
                                                  select new GUIContent(x)).ToArray <GUIContent>();
     LightProbeProxyVolumeEditor.Styles.resMode = (from x in (from x in Enum.GetNames(typeof(LightProbeProxyVolume.ResolutionMode))
                                                              select ObjectNames.NicifyVariableName(x)).ToArray <string>()
                                                   select new GUIContent(x)).ToArray <GUIContent>();
     LightProbeProxyVolumeEditor.Styles.probePositionMode = (from x in (from x in Enum.GetNames(typeof(LightProbeProxyVolume.ProbePositionMode))
                                                                        select ObjectNames.NicifyVariableName(x)).ToArray <string>()
                                                             select new GUIContent(x)).ToArray <GUIContent>();
     LightProbeProxyVolumeEditor.Styles.refreshMode = (from x in (from x in Enum.GetNames(typeof(LightProbeProxyVolume.RefreshMode))
                                                                  select ObjectNames.NicifyVariableName(x)).ToArray <string>()
                                                       select new GUIContent(x)).ToArray <GUIContent>();
     LightProbeProxyVolumeEditor.Styles.resProbesPerUnit               = EditorGUIUtility.TextContent("Density|Density in probes per world unit.");
     LightProbeProxyVolumeEditor.Styles.componentUnusedNote            = EditorGUIUtility.TextContent("In order to use the component on this game object, the Light Probes property should be set to 'Use Proxy Volume' in Renderer and baked lightmaps should be disabled.");
     LightProbeProxyVolumeEditor.Styles.noRendererNode                 = EditorGUIUtility.TextContent("The component is unused by this game object because there is no Renderer component attached.");
     LightProbeProxyVolumeEditor.Styles.noLightProbes                  = EditorGUIUtility.TextContent("The scene doesn't contain any light probes. Add light probes using Light Probe Group components (menu: Component->Rendering->Light Probe Group).");
     LightProbeProxyVolumeEditor.Styles.componentUnsuportedOnTreesNote = EditorGUIUtility.TextContent("Tree rendering doesn't support Light Probe Proxy Volume components.");
     LightProbeProxyVolumeEditor.Styles.volTextureSizesValues          = new int[]
     {
         1,
         2,
         4,
         8,
         16,
         32
     };
     LightProbeProxyVolumeEditor.Styles.volTextureSizes = (from n in LightProbeProxyVolumeEditor.Styles.volTextureSizesValues
                                                           select new GUIContent(n.ToString())).ToArray <GUIContent>();
     LightProbeProxyVolumeEditor.Styles.toolContents = new GUIContent[]
     {
         PrimitiveBoundsHandle.editModeButton,
         EditorGUIUtility.IconContent("MoveTool", "|Move the selected objects.")
     };
     LightProbeProxyVolumeEditor.Styles.sceneViewEditModes = new EditMode.SceneViewEditMode[]
     {
         EditMode.SceneViewEditMode.LightProbeProxyVolumeBox,
         EditMode.SceneViewEditMode.LightProbeProxyVolumeOrigin
     };
     LightProbeProxyVolumeEditor.Styles.baseSceneEditingToolText = "<color=grey>Light Probe Proxy Volume Scene Editing Mode:</color> ";
     LightProbeProxyVolumeEditor.Styles.toolNames = new GUIContent[]
     {
         new GUIContent(LightProbeProxyVolumeEditor.Styles.baseSceneEditingToolText + "Box Bounds", ""),
         new GUIContent(LightProbeProxyVolumeEditor.Styles.baseSceneEditingToolText + "Box Origin", "")
     };
     LightProbeProxyVolumeEditor.Styles.richTextMiniLabel.richText = true;
 }
 private void ShowDefaultTextures()
 {
     if (this.propertyNames.Count != 0)
     {
         EditorGUILayout.LabelField("Default Maps", EditorStyles.boldLabel, new GUILayoutOption[0]);
         for (int i = 0; i < this.propertyNames.Count; i++)
         {
             Texture obj   = this.textures[i];
             Texture value = null;
             EditorGUI.BeginChangeCheck();
             Type textureTypeFromDimension = MaterialEditor.GetTextureTypeFromDimension(this.dimensions[i]);
             if (textureTypeFromDimension != null)
             {
                 string t = (!string.IsNullOrEmpty(this.displayNames[i])) ? this.displayNames[i] : ObjectNames.NicifyVariableName(this.propertyNames[i]);
                 value = (EditorGUILayout.MiniThumbnailObjectField(GUIContent.Temp(t), obj, textureTypeFromDimension, new GUILayoutOption[0]) as Texture);
             }
             if (EditorGUI.EndChangeCheck())
             {
                 this.textures[i] = value;
             }
         }
     }
 }
示例#12
0
        // This is the preview area at the bottom of the screen
        void PreviewArea()
        {
            GUI.Box(new Rect(0, m_TopSize, position.width, m_PreviewSize), "", m_Styles.previewBackground);

            if (m_ListArea.GetSelection().Length == 0)
            {
                return;
            }

            EditorWrapper p = null;
            UnityObject   selectedObject = GetCurrentObject();

            if (m_PreviewSize < kPreviewExpandedAreaHeight)
            {
                // Get info string
                string s;
                if (selectedObject != null)
                {
                    p = m_EditorCache[selectedObject];
                    string typeName = ObjectNames.NicifyVariableName(selectedObject.GetType().Name);
                    if (p != null)
                    {
                        s = p.name + " (" + typeName + ")";
                    }
                    else
                    {
                        s = selectedObject.name + " (" + typeName + ")";
                    }

                    s += "      " + AssetDatabase.GetAssetPath(selectedObject);
                }
                else
                {
                    s = "None";
                }

                LinePreview(s, selectedObject, p);
            }
            else
            {
                if (m_EditorCache == null)
                {
                    m_EditorCache = new EditorCache(EditorFeatures.PreviewGUI);
                }

                // Get info string
                string s;
                if (selectedObject != null)
                {
                    p = m_EditorCache[selectedObject];
                    string typeName = ObjectNames.NicifyVariableName(selectedObject.GetType().Name);
                    if (p != null)
                    {
                        s = p.GetInfoString();
                        if (s != "")
                        {
                            s = p.name + "\n" + typeName + "\n" + s;
                        }
                        else
                        {
                            s = p.name + "\n" + typeName;
                        }
                    }
                    else
                    {
                        s = selectedObject.name + "\n" + typeName;
                    }

                    s += "\n" + AssetDatabase.GetAssetPath(selectedObject);
                }
                else
                {
                    s = "None";
                }

                // Make previews
                if (m_ShowWidePreview.faded != 0.0f)
                {
                    GUI.color = new Color(1, 1, 1, m_ShowWidePreview.faded);
                    WidePreview(m_PreviewSize, s, selectedObject, p);
                }
                if (m_ShowOverlapPreview.faded != 0.0f)
                {
                    GUI.color = new Color(1, 1, 1, m_ShowOverlapPreview.faded);
                    OverlapPreview(m_PreviewSize, s, selectedObject, p);
                }
                GUI.color = Color.white;
                m_EditorCache.CleanupUntouchedEditors();
            }
        }