NicifyVariableName() приватный Метод

private NicifyVariableName ( string name ) : string
name string
Результат string
Пример #1
0
        static MonoCreateAssetItem[] ExtractCreateAssetMenuItems(Assembly assembly)
        {
            var result = new List <MonoCreateAssetItem>();

            foreach (var type in EditorAssemblies.GetAllTypesWithAttribute <CreateAssetMenuAttribute>())
            {
                var attr = type.GetCustomAttributes(typeof(CreateAssetMenuAttribute), false).FirstOrDefault() as CreateAssetMenuAttribute;
                if (attr == null)
                {
                    continue;
                }

                if (!type.IsSubclassOf(typeof(ScriptableObject)))
                {
                    Debug.LogWarningFormat("CreateAssetMenu attribute on {0} will be ignored as {0} is not derived from ScriptableObject.", type.FullName);
                    continue;
                }

                string menuItemName = (string.IsNullOrEmpty(attr.menuName)) ? ObjectNames.NicifyVariableName(type.Name) : attr.menuName;
                string fileName     = (string.IsNullOrEmpty(attr.fileName)) ? ("New " + ObjectNames.NicifyVariableName(type.Name) + ".asset") : attr.fileName;
                if (!System.IO.Path.HasExtension(fileName))
                {
                    fileName = fileName + ".asset";
                }

                var item = new MonoCreateAssetItem
                {
                    menuItem = menuItemName,
                    fileName = fileName,
                    order    = attr.order,
                    type     = type
                };
                result.Add(item);
            }

            return(result.ToArray());
        }
        private void ShowDefaultTextures()
        {
            if (this.propertyNames.Count == 0)
            {
                return;
            }
            EditorGUILayout.LabelField("Default Maps", EditorStyles.boldLabel, new GUILayoutOption[0]);
            for (int index = 0; index < this.propertyNames.Count; ++index)
            {
                Texture texture1 = this.textures[index];
                Texture texture2 = (Texture)null;
                EditorGUI.BeginChangeCheck();
                System.Type objType;
                switch (this.dimensions[index])
                {
                case ShaderUtil.ShaderPropertyTexDim.TexDim2D:
                    objType = typeof(Texture);
                    break;

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

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

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

                default:
                    objType = (System.Type)null;
                    break;
                }
                if (objType != null)
                {
                    texture2 = EditorGUILayout.MiniThumbnailObjectField(GUIContent.Temp(!string.IsNullOrEmpty(this.displayNames[index]) ? this.displayNames[index] : ObjectNames.NicifyVariableName(this.propertyNames[index])), (UnityEngine.Object)texture1, objType, (EditorGUI.ObjectFieldValidator)null) as Texture;
                }
                if (EditorGUI.EndChangeCheck())
                {
                    this.textures[index] = texture2;
                }
            }
        }
        public static bool SetStaticFlags(Object[] targetObjects, int changedFlags, bool flagValue)
        {
            bool allFlagsAreChanged = (changedFlags == ~0);
            var  msgChangedFlags    = changedFlags;

            if (msgChangedFlags < 0 && !allFlagsAreChanged)
            {
                //In order to have a list of human readable list of changed flags,
                //we need to filter out bits that does not correspont to any option.
                int allPossibleValues = 0;
                var values            = Enum.GetValues(typeof(StaticEditorFlags));
                foreach (var value in values)
                {
                    allPossibleValues |= (int)value;
                }

                msgChangedFlags = msgChangedFlags & allPossibleValues;
            }
            StaticEditorFlags flag = allFlagsAreChanged ?
                                     (StaticEditorFlags)0 :
                                     (StaticEditorFlags)Enum.Parse(typeof(StaticEditorFlags), msgChangedFlags.ToString());


            // Should we include child objects?
            GameObjectUtility.ShouldIncludeChildren includeChildren = GameObjectUtility.DisplayUpdateChildrenDialogIfNeeded(targetObjects.OfType <GameObject>(), "Change Static Flags",
                                                                                                                            allFlagsAreChanged ?
                                                                                                                            "Do you want to " + (flagValue ? "enable" : "disable") + " the static flags for all the child objects as well?" :
                                                                                                                            "Do you want to " + (flagValue ? "enable" : "disable") + " the " + ObjectNames.NicifyVariableName(flag.ToString()) + " flag for all the child objects as well?");

            if (includeChildren == GameObjectUtility.ShouldIncludeChildren.Cancel)
            {
                EditorGUIUtility.ExitGUI();
                return(false);
            }
            var objects = GetObjects(targetObjects, includeChildren == GameObjectUtility.ShouldIncludeChildren.IncludeChildren);

            Undo.RecordObjects(objects, "Change Static Flags");

            // Calculate new flags value separately for each object so other flags are not affected.
            foreach (GameObject go in objects)
            {
                int goFlags = (int)GameObjectUtility.GetStaticEditorFlags(go);
                goFlags = flagValue ?
                          goFlags | changedFlags :
                          goFlags & ~changedFlags;
                GameObjectUtility.SetStaticEditorFlags(go, (StaticEditorFlags)goFlags);
            }

            return(true);
        }
Пример #4
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), "", 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();
            }
        }
Пример #5
0
 private string GetStrippedAndNiceBoneName(Transform bone)
 {
     string[] strings = bone.name.Split(':');
     return(ObjectNames.NicifyVariableName(strings[strings.Length - 1]));
 }
Пример #6
0
        public override string ToString()
        {
            m_Text           = m_ScriptPrescription.m_Template;
            m_Writer         = new StringWriter();
            m_Writer.NewLine = "\n";

            // Make sure all line endings are Unix (Mac OS X) format
            m_Text = Regex.Replace(m_Text, @"\r\n?", delegate(Match m) { return("\n"); });

            // Class Name
            m_Text = m_Text.Replace("$ClassName", ClassName);
            m_Text = m_Text.Replace("$NicifiedClassName", ObjectNames.NicifyVariableName(ClassName));

            // Namespace
            if (!string.IsNullOrEmpty(m_ScriptPrescription.m_Namespace) && m_Text.Contains("$Namespace"))
            {
                int index = m_Text.IndexOf("$Namespace") + "$Namespace".Length;

                for (; index < m_Text.Length; ++index)
                {
                    if (m_Text[index] == '\n')
                    {
                        m_Text = m_Text.Insert(index + 1, "\t");
                        index += 1;
                    }
                }

                string endString = "}";
                if (m_Text[m_Text.Length - 1] != '\n')
                {
                    endString = endString.Insert(0, "\n");
                }
                m_Text += endString;
            }
            m_Text = m_Text.Replace("$NamespaceStart", m_ScriptPrescription.m_Namespace);

            // Other replacements
            foreach (KeyValuePair <string, string> kvp in m_ScriptPrescription.m_StringReplacements)
            {
                m_Text = m_Text.Replace(kvp.Key, kvp.Value);
            }

            // Functions
            // Find $Functions keyword including leading tabs
            Match match = Regex.Match(m_Text, @"(\t*)\$Functions");

            if (match.Success)
            {
                // Set indent level to number of tabs before $Functions keyword
                IndentLevel = match.Groups[1].Value.Length;
                bool hasFunctions = false;
                if (m_ScriptPrescription.m_Functions != null)
                {
                    foreach (var function in m_ScriptPrescription.m_Functions.Where(f => f.include))
                    {
                        WriteFunction(function);
                        WriteBlankLine();
                        hasFunctions = true;
                    }

                    // Replace $Functions keyword plus newline with generated functions text
                    if (hasFunctions)
                    {
                        m_Text = m_Text.Replace(match.Value + "\n", m_Writer.ToString());
                    }
                }

                if (!hasFunctions)
                {
                    /*if (m_ScriptPrescription.m_Lang == Language.Boo && !m_Text.Contains ("def"))
                     *      // Replace $Functions keyword with "pass" if no functions in Boo
                     *      m_Text = m_Text.Replace (match.Value, m_Indentation + "pass");
                     * else*/
                    // Otherwise just remove $Functions keyword plus newline
                    m_Text = m_Text.Replace(match.Value + "\n", string.Empty);
                }
            }

            // Put curly vraces on new line if specified in editor prefs
            if (EditorPrefs.GetBool("CurlyBracesOnNewLine"))
            {
                PutCurveBracesOnNewLine();
            }

            m_Text = m_Text.Replace("$Header", "");
            m_Text = m_Text.Replace("$NamespaceStart", "");
            m_Text = m_Text.Replace("$NamespaceEnd", "");
            m_Text = m_Text.Replace("$Header", "");

            // Return the text of the script
            return(m_Text);
        }
Пример #7
0
 protected virtual void OnSceneGUI()
 {
     if (base.editingCollider)
     {
         Collider2D collider2D = (Collider2D)base.target;
         if (!Mathf.Approximately(collider2D.transform.lossyScale.sqrMagnitude, 0f))
         {
             using (new Handles.DrawingScope(Matrix4x4.TRS(collider2D.transform.position, this.GetHandleRotation(), Vector3.one)))
             {
                 Matrix4x4 localToWorldMatrix = collider2D.transform.localToWorldMatrix;
                 this.boundsHandle.center = this.ProjectOntoWorldPlane(Handles.inverseMatrix * (localToWorldMatrix * collider2D.offset));
                 this.CopyColliderSizeToHandle();
                 this.boundsHandle.SetColor((!collider2D.enabled) ? Handles.s_ColliderHandleColorDisabled : Handles.s_ColliderHandleColor);
                 EditorGUI.BeginChangeCheck();
                 this.boundsHandle.DrawHandle();
                 if (EditorGUI.EndChangeCheck())
                 {
                     Undo.RecordObject(collider2D, string.Format("Modify {0}", ObjectNames.NicifyVariableName(base.target.GetType().Name)));
                     if (this.CopyHandleSizeToCollider())
                     {
                         collider2D.offset = localToWorldMatrix.inverse * this.ProjectOntoColliderPlane(Handles.matrix * this.boundsHandle.center, localToWorldMatrix);
                     }
                 }
             }
         }
     }
 }
Пример #8
0
        public override string ToString()
        {
            text           = scriptPrescription.template;
            writer         = new StringWriter();
            writer.NewLine = "\n";

            // Make sure all line endings are Unix (Mac OS X) format
            text = Regex.Replace(text, @"\r\n?", "\n");

            // Class Name
            text = text.Replace("$ClassName", ClassName);
            //text = text.Replace("$Namespace", Namespace);
            text = text.Replace("$NicifiedClassName", ObjectNames.NicifyVariableName(ClassName));

            // Other replacements
            foreach (var keyAndValue in scriptPrescription.stringReplacements)
            {
                text = text.Replace(keyAndValue.Key, keyAndValue.Value);
            }

            if (!addUsedImplictly)
            {
                text = text.Replace(", UsedImplicitly", "");
            }

            if (!curlyBracesOnNewLine)
            {
                text = text.Replace("\n{", " {");
                text = text.Replace("\n\t{", " {");
                text = text.Replace("\n\t\t{", " {");
            }

            if (!addComments)
            {
                for (int commentStart = text.IndexOf("//"); commentStart != -1; commentStart = text.IndexOf("//", commentStart))
                {
                    int lineStart = text.LastIndexOf('\n', commentStart - 1);

                    bool onlyWhitespaceBeforeComment = true;
                    if (lineStart != -1)
                    {
                        for (int n = lineStart + 1; n < commentStart; n++)
                        {
                            if (!text[n].IsWhiteSpace())
                            {
                                onlyWhitespaceBeforeComment = false;
                                break;
                            }
                        }
                    }

                    int commentEnd = text.IndexOf('\n', commentStart + 2);
                    if (commentEnd == -1)
                    {
                        commentEnd = text.Length;
                    }

                    if (onlyWhitespaceBeforeComment)
                    {
                        commentStart = lineStart == -1 ? 0 : lineStart;                         //here!
                    }

                                        #if DEV_MODE
                    UnityEngine.Debug.Log("commentStart=" + commentStart + ", commentEnd=" + commentEnd + ", onlyWhitespaceBeforeComment=" + onlyWhitespaceBeforeComment + ", text:\n" + text);
                                        #endif

                    text = text.Substring(0, commentStart) + text.Substring(commentEnd);
                }
            }
            else if (!addCommentsAsSummary)
            {
                text = text.Replace("\t/// <summary>\n", "");
                text = text.Replace("\t/// </summary>\n", "");
                text = text.Replace("\t/// ", "\t// ");
            }

            // Functions
            // Find $Functions keyword including leading tabs
            var match = Regex.Match(text, @"(\t*)\$Functions");
            if (match.Success)
            {
                // Set indent level to number of tabs before $Functions keyword
                IndentLevel = match.Groups[1].Value.Length;
                bool hasFunctions = false;
                if (scriptPrescription.functions != null)
                {
                    var includedFunctions = scriptPrescription.functions.Where(f => f.include).ToArray();
                    for (int n = 0, lastIndex = includedFunctions.Length - 1; n <= lastIndex; n++)
                    {
                        var function = includedFunctions[n];
                        WriteFunction(function);

                        if (n != lastIndex)
                        {
                            WriteBlankLine();
                        }
                        hasFunctions = true;
                    }

                    // Replace $Functions keyword plus newline with generated functions text
                    if (hasFunctions)
                    {
                        text = text.Replace(match.Value + "\n", writer.ToString());
                    }
                }

                if (!hasFunctions)
                {
                    text = text.Replace(match.Value + "\n", string.Empty);
                }
            }

            if (scriptPrescription.nameSpace.Length > 0)
            {
                var lines = text.Split(ArrayExtensions.TempCharArray('\n'), StringSplitOptions.None);
                for (int n = lines.Length - 1; n >= 0; n--)
                {
                    lines[n] = string.Concat("\t", lines[n]);
                }

                text = string.Join(newLine, lines);
                text = string.Concat("namespace ", scriptPrescription.nameSpace, curlyBracesOnNewLine ? newLine : " ", "{", newLine, text, newLine, "}");
            }

            //add used namespaces to the beginning of the code
            int namespacesCount = scriptPrescription.usingNamespaces.Length;
            if (namespacesCount > 0)
            {
                text = string.Concat(newLine, text);

                for (int n = namespacesCount - 1; n >= 0; n--)
                {
                    text = string.Concat("using ", scriptPrescription.usingNamespaces[n], ";", newLine, text);
                }
            }

            return(text);
        }
Пример #9
0
        public static bool SetStaticFlags(UnityEngine.Object[] targetObjects, int changedFlags, bool flagValue)
        {
            bool flag = changedFlags == -1;
            StaticEditorFlags flags = !flag ? ((StaticEditorFlags)((int)Enum.Parse(typeof(StaticEditorFlags), changedFlags.ToString()))) : ((StaticEditorFlags)0);

            GameObjectUtility.ShouldIncludeChildren children = GameObjectUtility.DisplayUpdateChildrenDialogIfNeeded(targetObjects.OfType <GameObject>(), "Change Static Flags", !flag ? ("Do you want to " + (!flagValue ? "disable" : "enable") + " the " + ObjectNames.NicifyVariableName(flags.ToString()) + " flag for all the child objects as well?") : ("Do you want to " + (!flagValue ? "disable" : "enable") + " the static flags for all the child objects as well?"));
            if (children == GameObjectUtility.ShouldIncludeChildren.Cancel)
            {
                GUIUtility.ExitGUI();
                return(false);
            }
            GameObject[] objects = GetObjects(targetObjects, children == GameObjectUtility.ShouldIncludeChildren.IncludeChildren);
            Undo.RecordObjects(objects, "Change Static Flags");
            foreach (GameObject obj2 in objects)
            {
                int staticEditorFlags = (int)GameObjectUtility.GetStaticEditorFlags(obj2);
                staticEditorFlags = !flagValue ? (staticEditorFlags & ~changedFlags) : (staticEditorFlags | changedFlags);
                GameObjectUtility.SetStaticEditorFlags(obj2, (StaticEditorFlags)staticEditorFlags);
            }
            return(true);
        }
Пример #10
0
        private static AttributeHelper.MonoCreateAssetItem[] ExtractCreateAssetMenuItems(Assembly assembly)
        {
            List <AttributeHelper.MonoCreateAssetItem> list = new List <AttributeHelper.MonoCreateAssetItem>();

            foreach (Type current in EditorAssemblies.GetAllTypesWithAttribute <CreateAssetMenuAttribute>())
            {
                CreateAssetMenuAttribute createAssetMenuAttribute = current.GetCustomAttributes(typeof(CreateAssetMenuAttribute), false).FirstOrDefault <object>() as CreateAssetMenuAttribute;
                if (createAssetMenuAttribute != null)
                {
                    if (!current.IsSubclassOf(typeof(ScriptableObject)))
                    {
                        UnityEngine.Debug.LogWarningFormat("CreateAssetMenu attribute on {0} will be ignored as {0} is not derived from ScriptableObject.", new object[]
                        {
                            current.FullName
                        });
                    }
                    else
                    {
                        string menuItem = (!string.IsNullOrEmpty(createAssetMenuAttribute.menuName)) ? createAssetMenuAttribute.menuName : ObjectNames.NicifyVariableName(current.Name);
                        string text     = (!string.IsNullOrEmpty(createAssetMenuAttribute.fileName)) ? createAssetMenuAttribute.fileName : ("New " + ObjectNames.NicifyVariableName(current.Name) + ".asset");
                        if (!Path.HasExtension(text))
                        {
                            text += ".asset";
                        }
                        AttributeHelper.MonoCreateAssetItem item = new AttributeHelper.MonoCreateAssetItem
                        {
                            menuItem = menuItem,
                            fileName = text,
                            order    = createAssetMenuAttribute.order,
                            type     = current
                        };
                        list.Add(item);
                    }
                }
            }
            return(list.ToArray());
        }
Пример #11
0
        private void ShowFieldInfo(Type type, MonoImporter importer, List <string> names, List <UnityEngine.Object> objects, ref bool didModify)
        {
            if (MonoScriptImporterInspector.IsTypeCompatible(type))
            {
                this.ShowFieldInfo(type.BaseType, importer, names, objects, ref didModify);
                FieldInfo[] fields = type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                FieldInfo[] array  = fields;
                int         i      = 0;
                while (i < array.Length)
                {
                    FieldInfo fieldInfo = array[i];
                    if (fieldInfo.IsPublic)
                    {
                        goto IL_70;
                    }
                    object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(SerializeField), true);
                    if (customAttributes != null && customAttributes.Length != 0)
                    {
                        goto IL_70;
                    }
IL_F8:
                    i++;
                    continue;
IL_70:
                    if (fieldInfo.FieldType.IsSubclassOf(typeof(UnityEngine.Object)) || fieldInfo.FieldType == typeof(UnityEngine.Object))
                    {
                        UnityEngine.Object defaultReference = importer.GetDefaultReference(fieldInfo.Name);
                        UnityEngine.Object @object          = EditorGUILayout.ObjectField(ObjectNames.NicifyVariableName(fieldInfo.Name), defaultReference, fieldInfo.FieldType, false, new GUILayoutOption[0]);
                        names.Add(fieldInfo.Name);
                        objects.Add(@object);
                        if (defaultReference != @object)
                        {
                            didModify = true;
                        }
                    }
                    goto IL_F8;
                }
            }
        }
        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;
                    }
                }
            }
        }
Пример #13
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);
        }
Пример #14
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);
        }
Пример #15
0
 private string GetStrippedAndNiceBoneName(Transform bone)
 {
     char[]   separator = new char[] { ':' };
     string[] strArray  = bone.name.Split(separator);
     return(ObjectNames.NicifyVariableName(strArray[strArray.Length - 1]));
 }
Пример #16
0
 protected virtual void OnSceneGUI()
 {
     if (base.editingCollider)
     {
         BoxCollider2D boxCollider2D = (BoxCollider2D)base.target;
         if (!Mathf.Approximately(boxCollider2D.transform.lossyScale.sqrMagnitude, 0f))
         {
             Matrix4x4 matrix4x = boxCollider2D.transform.localToWorldMatrix;
             matrix4x.SetRow(0, Vector4.Scale(matrix4x.GetRow(0), new Vector4(1f, 1f, 0f, 1f)));
             matrix4x.SetRow(1, Vector4.Scale(matrix4x.GetRow(1), new Vector4(1f, 1f, 0f, 1f)));
             matrix4x.SetRow(2, new Vector4(0f, 0f, 1f, boxCollider2D.transform.position.z));
             if (boxCollider2D.usedByComposite && boxCollider2D.composite != null)
             {
                 Vector3 pos = boxCollider2D.composite.transform.rotation * boxCollider2D.composite.offset;
                 pos.z    = 0f;
                 matrix4x = Matrix4x4.TRS(pos, Quaternion.identity, Vector3.one) * matrix4x;
             }
             using (new Handles.DrawingScope(matrix4x))
             {
                 this.m_BoundsHandle.center = boxCollider2D.offset;
                 this.m_BoundsHandle.size   = boxCollider2D.size;
                 this.m_BoundsHandle.SetColor((!boxCollider2D.enabled) ? Handles.s_ColliderHandleColorDisabled : Handles.s_ColliderHandleColor);
                 EditorGUI.BeginChangeCheck();
                 this.m_BoundsHandle.DrawHandle();
                 if (EditorGUI.EndChangeCheck())
                 {
                     Undo.RecordObject(boxCollider2D, string.Format("Modify {0}", ObjectNames.NicifyVariableName(base.target.GetType().Name)));
                     Vector2 size = boxCollider2D.size;
                     boxCollider2D.size = this.m_BoundsHandle.size;
                     if (boxCollider2D.size != size)
                     {
                         boxCollider2D.offset = this.m_BoundsHandle.center;
                     }
                 }
             }
         }
     }
 }
Пример #17
0
 public static string MangleVariableName(string name)
 {
     return(ObjectNames.NicifyVariableName(name));
 }
 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[]
     {
         EditorGUIUtility.IconContent("EditCollider"),
         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 static void DoEditRegularParameters(AnimationEvent[] events, Type selectedParameter)
        {
            AnimationEvent firstEvent = events[0];

            if (selectedParameter == typeof(AnimationEvent) || selectedParameter == typeof(float))
            {
                bool singleParamValue = Array.TrueForAll(events, evt => evt.floatParameter == firstEvent.floatParameter);

                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = !singleParamValue;
                float newValue = EditorGUILayout.FloatField("Float", firstEvent.floatParameter);
                EditorGUI.showMixedValue = false;

                if (EditorGUI.EndChangeCheck())
                {
                    foreach (var evt in events)
                    {
                        evt.floatParameter = newValue;
                    }
                }
            }

            if (selectedParameter == typeof(AnimationEvent) || selectedParameter == typeof(int) || selectedParameter.IsEnum)
            {
                bool singleParamValue = Array.TrueForAll(events, evt => evt.intParameter == firstEvent.intParameter);

                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = !singleParamValue;
                int newValue = 0;
                if (selectedParameter.IsEnum)
                {
                    newValue = EnumPopup("Enum", selectedParameter, firstEvent.intParameter);
                }
                else
                {
                    newValue = EditorGUILayout.IntField("Int", firstEvent.intParameter);
                }
                EditorGUI.showMixedValue = false;

                if (EditorGUI.EndChangeCheck())
                {
                    foreach (var evt in events)
                    {
                        evt.intParameter = newValue;
                    }
                }
            }

            if (selectedParameter == typeof(AnimationEvent) || selectedParameter == typeof(string))
            {
                bool singleParamValue = Array.TrueForAll(events, evt => evt.stringParameter == firstEvent.stringParameter);

                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = !singleParamValue;
                string newValue = EditorGUILayout.TextField("String", firstEvent.stringParameter);
                EditorGUI.showMixedValue = false;

                if (EditorGUI.EndChangeCheck())
                {
                    foreach (var evt in events)
                    {
                        evt.stringParameter = newValue;
                    }
                }
            }

            if (selectedParameter == typeof(AnimationEvent) || selectedParameter.IsSubclassOf(typeof(UnityEngine.Object)) || selectedParameter == typeof(UnityEngine.Object))
            {
                bool singleParamValue = Array.TrueForAll(events, evt => evt.objectReferenceParameter == firstEvent.objectReferenceParameter);

                EditorGUI.BeginChangeCheck();
                Type type = typeof(UnityEngine.Object);
                if (selectedParameter != typeof(AnimationEvent))
                {
                    type = selectedParameter;
                }

                EditorGUI.showMixedValue = !singleParamValue;
                bool   allowSceneObjects = false;
                Object newValue          = EditorGUILayout.ObjectField(ObjectNames.NicifyVariableName(type.Name), firstEvent.objectReferenceParameter, type, allowSceneObjects);
                EditorGUI.showMixedValue = false;

                if (EditorGUI.EndChangeCheck())
                {
                    foreach (var evt in events)
                    {
                        evt.objectReferenceParameter = newValue;
                    }
                }
            }
        }
Пример #20
0
        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;
                                Rect rect = new Rect(controlRect.x + EditorGUI.indent, controlRect.y - 1f, 19f, 19f);
                                boneWrapper.BoneDotGUI(rect, selectRect, num2, true, false, true, 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);
        }
Пример #21
0
 private void PreviewArea()
 {
     GUI.Box(new Rect(0f, this.m_TopSize, base.position.width, this.m_PreviewSize), "", this.m_Styles.previewBackground);
     if (this.m_ListArea.GetSelection().Length != 0)
     {
         EditorWrapper      editorWrapper = null;
         UnityEngine.Object currentObject = ObjectSelector.GetCurrentObject();
         if (this.m_PreviewSize < 75f)
         {
             string text;
             if (currentObject != null)
             {
                 editorWrapper = this.m_EditorCache[currentObject];
                 string str = ObjectNames.NicifyVariableName(currentObject.GetType().Name);
                 if (editorWrapper != null)
                 {
                     text = editorWrapper.name + " (" + str + ")";
                 }
                 else
                 {
                     text = currentObject.name + " (" + str + ")";
                 }
                 text = text + "      " + AssetDatabase.GetAssetPath(currentObject);
             }
             else
             {
                 text = "None";
             }
             this.LinePreview(text, currentObject, editorWrapper);
         }
         else
         {
             if (this.m_EditorCache == null)
             {
                 this.m_EditorCache = new EditorCache(EditorFeatures.PreviewGUI);
             }
             string text3;
             if (currentObject != null)
             {
                 editorWrapper = this.m_EditorCache[currentObject];
                 string text2 = ObjectNames.NicifyVariableName(currentObject.GetType().Name);
                 if (editorWrapper != null)
                 {
                     text3 = editorWrapper.GetInfoString();
                     if (text3 != "")
                     {
                         text3 = string.Concat(new string[]
                         {
                             editorWrapper.name,
                             "\n",
                             text2,
                             "\n",
                             text3
                         });
                     }
                     else
                     {
                         text3 = editorWrapper.name + "\n" + text2;
                     }
                 }
                 else
                 {
                     text3 = currentObject.name + "\n" + text2;
                 }
                 text3 = text3 + "\n" + AssetDatabase.GetAssetPath(currentObject);
             }
             else
             {
                 text3 = "None";
             }
             if (this.m_ShowWidePreview.faded != 0f)
             {
                 GUI.color = new Color(1f, 1f, 1f, this.m_ShowWidePreview.faded);
                 this.WidePreview(this.m_PreviewSize, text3, currentObject, editorWrapper);
             }
             if (this.m_ShowOverlapPreview.faded != 0f)
             {
                 GUI.color = new Color(1f, 1f, 1f, this.m_ShowOverlapPreview.faded);
                 this.OverlapPreview(this.m_PreviewSize, text3, currentObject, editorWrapper);
             }
             GUI.color = Color.white;
             this.m_EditorCache.CleanupUntouchedEditors();
         }
     }
 }
Пример #22
0
        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
            {
                int firstHumanBoneAncestor = AvatarSetupTool.GetFirstHumanBoneAncestor(this.m_Bones, i);
                AvatarSetupTool.BoneWrapper boneWrapper = this.m_Bones[(firstHumanBoneAncestor <= 0) ? 0 : firstHumanBoneAncestor];
                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 == 54)
                    {
                        AvatarSetupTool.BoneWrapper boneWrapper2 = this.m_Bones[8];
                        if (boneWrapper2.bone == null)
                        {
                            error  = "Chest must be assigned before assigning UpperChest.";
                            result = BoneState.InvalidHierarchy;
                            return(result);
                        }
                    }
                    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);
        }
Пример #23
0
        private WrapMode WrapModeIconPopup(Keyframe key, WrapMode oldWrap, float hOffset)
        {
            float              width = (float)CurveEditorWindow.s_WrapModeMenuIcon.image.width;
            Vector3            viewTransformPoint = this.m_CurveEditor.DrawingToViewTransformPoint(new Vector3(key.time, key.value));
            Rect               position           = new Rect(viewTransformPoint.x + width * hOffset, viewTransformPoint.y, width, width);
            WrapModeFixedCurve wrapModeFixedCurve = (WrapModeFixedCurve)oldWrap;

            Enum[]   array1    = Enum.GetValues(typeof(WrapModeFixedCurve)).Cast <Enum>().ToArray <Enum>();
            string[] array2    = ((IEnumerable <string>)Enum.GetNames(typeof(WrapModeFixedCurve))).Select <string, string>((Func <string, string>)(x => ObjectNames.NicifyVariableName(x))).ToArray <string>();
            int      selected  = Array.IndexOf <Enum>(array1, (Enum)wrapModeFixedCurve);
            int      controlId = GUIUtility.GetControlID("WrapModeIconPopup".GetHashCode(), EditorGUIUtility.native, position);
            int      selectedValueForControl = EditorGUI.PopupCallbackInfo.GetSelectedValueForControl(controlId, selected);

            GUIContent[] options = EditorGUIUtility.TempContent(array2);
            Event        current = Event.current;
            EventType    type    = current.type;

            switch (type)
            {
            case EventType.KeyDown:
                if (current.MainActionKeyForControl(controlId))
                {
                    if (Application.platform == RuntimePlatform.OSXEditor)
                    {
                        position.y = (float)((double)position.y - (double)(selectedValueForControl * 16) - 19.0);
                    }
                    EditorGUI.PopupCallbackInfo.instance = new EditorGUI.PopupCallbackInfo(controlId);
                    EditorUtility.DisplayCustomMenu(position, options, selectedValueForControl, new EditorUtility.SelectMenuItemFunction(EditorGUI.PopupCallbackInfo.instance.SetEnumValueDelegate), (object)null);
                    current.Use();
                    break;
                }
                break;

            case EventType.Repaint:
                GUIStyle.none.Draw(position, CurveEditorWindow.s_WrapModeMenuIcon, controlId, false);
                break;

            default:
                if (type == EventType.MouseDown && current.button == 0 && position.Contains(current.mousePosition))
                {
                    if (Application.platform == RuntimePlatform.OSXEditor)
                    {
                        position.y = (float)((double)position.y - (double)(selectedValueForControl * 16) - 19.0);
                    }
                    EditorGUI.PopupCallbackInfo.instance = new EditorGUI.PopupCallbackInfo(controlId);
                    EditorUtility.DisplayCustomMenu(position, options, selectedValueForControl, new EditorUtility.SelectMenuItemFunction(EditorGUI.PopupCallbackInfo.instance.SetEnumValueDelegate), (object)null);
                    GUIUtility.keyboardControl = controlId;
                    current.Use();
                    break;
                }
                break;
            }
            return((WrapMode)array1[selectedValueForControl]);
        }
 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;
             }
         }
     }
 }