protected void Init()
 {
     if (!(base.gameObject == null))
     {
         if (AvatarSetupTool.sHumanParent.Length != HumanTrait.BoneCount)
         {
             throw new Exception("Avatar's Human parent list is out of sync");
         }
         this.m_IsBiped = AvatarBipedMapper.IsBiped(base.gameObject.transform, null);
         if (this.m_Bones == null)
         {
             this.m_Bones = AvatarSetupTool.GetHumanBones(base.serializedObject, base.modelBones);
         }
         this.ValidateMapping();
         if (this.m_CurrentTransformEditor != null)
         {
             UnityEngine.Object.DestroyImmediate(this.m_CurrentTransformEditor);
             this.m_CurrentTransformEditor = null;
         }
         this.m_CurrentTransformEditorFoldout = true;
         this.m_HasSkinnedMesh = (base.gameObject.GetComponentInChildren <SkinnedMeshRenderer>() != null);
         this.InitPose();
         SceneView.RepaintAll();
     }
 }
        protected void Init()
        {
            if (gameObject == null)
            {
                return;
            }

            m_HumanBoneArray = serializedObject.FindProperty("m_HumanDescription.m_Human");
            m_Skeleton       = serializedObject.FindProperty("m_HumanDescription.m_Skeleton");

            m_IsBiped = AvatarBipedMapper.IsBiped(gameObject.transform, null);

            // Handle human bones
            if (m_Bones == null)
            {
                m_Bones = AvatarSetupTool.GetHumanBones(m_HumanBoneArray, modelBones);
            }
            ValidateMapping();

            if (m_CurrentTransformEditor != null)
            {
                DestroyImmediate(m_CurrentTransformEditor);
                m_CurrentTransformEditor = null;
            }
            m_CurrentTransformEditorFoldout = true;
            m_HasSkinnedMesh = (gameObject.GetComponentInChildren <SkinnedMeshRenderer>() != null);

            // Handle pose
            InitPose();

            // Repaint
            SceneView.RepaintAll();
        }
Ejemplo n.º 3
0
        internal void SwitchToEditMode()
        {
            m_EditMode = EditMode.Starting;

            // Lock inspector
            ChangeInspectorLock(true);

            // Store current setup in hierarchy
            sceneSetup = EditorSceneManager.GetSceneManagerSetup();

            // Load temp scene
            Scene scene = EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);

            scene.name = "Avatar Configuration";

            // Instantiate character
            m_GameObject = Instantiate(prefab) as GameObject;
            if (serializedAssetImporter.FindProperty("m_OptimizeGameObjects").boolValue)
            {
                AnimatorUtility.DeoptimizeTransformHierarchy(m_GameObject);
            }

            // First get all available modelBones
            Dictionary <Transform, bool> modelBones = AvatarSetupTool.GetModelBones(m_GameObject.transform, true, null);

            AvatarSetupTool.BoneWrapper[] humanBones = AvatarSetupTool.GetHumanBones(serializedAssetImporter, modelBones);

            m_ModelBones = AvatarSetupTool.GetModelBones(m_GameObject.transform, false, humanBones);

            Selection.activeObject = m_GameObject;

            // Unfold all nodes in hierarchy
            // TODO@MECANIM: Only expand actual bones
            foreach (SceneHierarchyWindow shw in Resources.FindObjectsOfTypeAll(typeof(SceneHierarchyWindow)))
            {
                shw.SetExpandedRecursive(m_GameObject.GetInstanceID(), true);
            }
            CreateEditor();

            m_EditMode = EditMode.Editing;

            // Frame in scene view
            m_SceneStates = new List <SceneStateCache>();
            foreach (SceneView s in SceneView.sceneViews)
            {
                m_SceneStates.Add(new SceneStateCache {
                    state = new SceneView.SceneViewState(s.sceneViewState), view = s
                });
                s.sceneViewState.showFlares          = false;
                s.sceneViewState.showMaterialUpdate  = false;
                s.sceneViewState.showFog             = false;
                s.sceneViewState.showSkybox          = false;
                s.sceneViewState.showImageEffects    = false;
                s.sceneViewState.showParticleSystems = false;
                s.FrameSelected();
            }
        }
Ejemplo n.º 4
0
        internal void SwitchToEditMode()
        {
            this.m_EditMode = AvatarEditor.EditMode.Starting;
            this.ChangeInspectorLock(true);
            this.sceneSetup = EditorSceneManager.GetSceneManagerSetup();
            EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects).name = "Avatar Configuration";
            this.m_GameObject = UnityEngine.Object.Instantiate <GameObject>(this.prefab);
            if (base.serializedObject.FindProperty("m_OptimizeGameObjects").boolValue)
            {
                AnimatorUtility.DeoptimizeTransformHierarchy(this.m_GameObject);
            }
            Dictionary <Transform, bool> modelBones = AvatarSetupTool.GetModelBones(this.m_GameObject.transform, true, null);

            AvatarSetupTool.BoneWrapper[] humanBones = AvatarSetupTool.GetHumanBones(base.serializedObject, modelBones);
            this.m_ModelBones      = AvatarSetupTool.GetModelBones(this.m_GameObject.transform, false, humanBones);
            Selection.activeObject = this.m_GameObject;
            UnityEngine.Object[] array = Resources.FindObjectsOfTypeAll(typeof(SceneHierarchyWindow));
            for (int i = 0; i < array.Length; i++)
            {
                SceneHierarchyWindow sceneHierarchyWindow = (SceneHierarchyWindow)array[i];
                sceneHierarchyWindow.SetExpandedRecursive(this.m_GameObject.GetInstanceID(), true);
            }
            this.CreateEditor();
            this.m_EditMode    = AvatarEditor.EditMode.Editing;
            this.m_SceneStates = new List <AvatarEditor.SceneStateCache>();
            IEnumerator enumerator = SceneView.sceneViews.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    SceneView sceneView = (SceneView)enumerator.Current;
                    this.m_SceneStates.Add(new AvatarEditor.SceneStateCache
                    {
                        state = new SceneView.SceneViewState(sceneView.sceneViewState),
                        view  = sceneView
                    });
                    sceneView.sceneViewState.showFlares          = false;
                    sceneView.sceneViewState.showMaterialUpdate  = false;
                    sceneView.sceneViewState.showFog             = false;
                    sceneView.sceneViewState.showSkybox          = false;
                    sceneView.sceneViewState.showImageEffects    = false;
                    sceneView.sceneViewState.showParticleSystems = false;
                    sceneView.FrameSelected();
                }
            }
            finally
            {
                IDisposable disposable;
                if ((disposable = (enumerator as IDisposable)) != null)
                {
                    disposable.Dispose();
                }
            }
        }
Ejemplo n.º 5
0
 internal void Initialize()
 {
     if (this.m_Bones == null)
     {
         this.m_Bones = AvatarSetupTool.GetHumanBones(base.serializedObject, base.modelBones);
     }
     this.m_FocusedMuscle         = -1;
     this.m_MuscleBodyGroupToggle = new bool[this.m_Muscles.Length];
     for (int i = 0; i < this.m_Muscles.Length; i++)
     {
         this.m_MuscleBodyGroupToggle[i] = false;
     }
     this.m_MuscleName = HumanTrait.MuscleName;
     for (int j = 0; j < this.m_MuscleName.Length; j++)
     {
         if (this.m_MuscleName[j].StartsWith("Right"))
         {
             this.m_MuscleName[j] = this.m_MuscleName[j].Substring(5).Trim();
         }
         if (this.m_MuscleName[j].StartsWith("Left"))
         {
             this.m_MuscleName[j] = this.m_MuscleName[j].Substring(4).Trim();
         }
     }
     this.m_MuscleCount   = HumanTrait.MuscleCount;
     this.m_MuscleToggle  = new bool[this.m_MuscleCount];
     this.m_MuscleValue   = new float[this.m_MuscleCount];
     this.m_MuscleMin     = new SerializedProperty[this.m_MuscleCount];
     this.m_MuscleMax     = new SerializedProperty[this.m_MuscleCount];
     this.m_MuscleMinEdit = new float[this.m_MuscleCount];
     this.m_MuscleMaxEdit = new float[this.m_MuscleCount];
     for (int k = 0; k < this.m_MuscleCount; k++)
     {
         this.m_MuscleToggle[k] = false;
         this.m_MuscleValue[k]  = 0f;
         this.m_MuscleMin[k]    = null;
         this.m_MuscleMin[k]    = null;
     }
     this.m_Modified = new SerializedProperty[this.m_Bones.Length];
     for (int m = 0; m < this.m_Bones.Length; m++)
     {
         this.m_Modified[m] = null;
     }
     this.InitializeProperties();
     this.ResetValuesFromProperties();
     this.m_MuscleMasterValue = new float[this.m_MasterMuscle.Length];
     for (int n = 0; n < this.m_MasterMuscle.Length; n++)
     {
         this.m_MuscleMasterValue[n] = 0f;
     }
 }
Ejemplo n.º 6
0
 internal void Initialize()
 {
     if (this.m_Bones == null)
     {
         this.m_Bones = AvatarSetupTool.GetHumanBones(this.serializedObject, this.modelBones);
     }
     this.m_FocusedMuscle         = -1;
     this.m_MuscleBodyGroupToggle = new bool[this.m_Muscles.Length];
     for (int index = 0; index < this.m_Muscles.Length; ++index)
     {
         this.m_MuscleBodyGroupToggle[index] = false;
     }
     this.m_MuscleName = HumanTrait.MuscleName;
     for (int index = 0; index < this.m_MuscleName.Length; ++index)
     {
         if (this.m_MuscleName[index].StartsWith("Right"))
         {
             this.m_MuscleName[index] = this.m_MuscleName[index].Substring(5).Trim();
         }
         if (this.m_MuscleName[index].StartsWith("Left"))
         {
             this.m_MuscleName[index] = this.m_MuscleName[index].Substring(4).Trim();
         }
     }
     this.m_MuscleCount   = HumanTrait.MuscleCount;
     this.m_MuscleToggle  = new bool[this.m_MuscleCount];
     this.m_MuscleValue   = new float[this.m_MuscleCount];
     this.m_MuscleMin     = new SerializedProperty[this.m_MuscleCount];
     this.m_MuscleMax     = new SerializedProperty[this.m_MuscleCount];
     this.m_MuscleMinEdit = new float[this.m_MuscleCount];
     this.m_MuscleMaxEdit = new float[this.m_MuscleCount];
     for (int index = 0; index < this.m_MuscleCount; ++index)
     {
         this.m_MuscleToggle[index] = false;
         this.m_MuscleValue[index]  = 0.0f;
         this.m_MuscleMin[index]    = (SerializedProperty)null;
         this.m_MuscleMin[index]    = (SerializedProperty)null;
     }
     this.m_Modified = new SerializedProperty[this.m_Bones.Length];
     for (int index = 0; index < this.m_Bones.Length; ++index)
     {
         this.m_Modified[index] = (SerializedProperty)null;
     }
     this.InitializeProperties();
     this.ResetValuesFromProperties();
     this.m_MuscleMasterValue = new float[this.m_MasterMuscle.Length];
     for (int index = 0; index < this.m_MasterMuscle.Length; ++index)
     {
         this.m_MuscleMasterValue[index] = 0.0f;
     }
 }
Ejemplo n.º 7
0
        internal void SwitchToEditMode()
        {
            this.m_EditMode = AvatarEditor.EditMode.Starting;
            this.ChangeInspectorLock(true);
            this.sceneSetup = EditorSceneManager.GetSceneManagerSetup();
            EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects).name = "Avatar Configuration";
            this.m_GameObject = UnityEngine.Object.Instantiate <GameObject>(this.prefab);
            if (base.serializedObject.FindProperty("m_OptimizeGameObjects").boolValue)
            {
                AnimatorUtility.DeoptimizeTransformHierarchy(this.m_GameObject);
            }
            Animator component = this.m_GameObject.GetComponent <Animator>();

            if (component != null && component.runtimeAnimatorController == null)
            {
                AnimatorController animatorController = new AnimatorController();
                animatorController.hideFlags = HideFlags.DontSave;
                animatorController.AddLayer("preview");
                animatorController.layers[0].stateMachine.hideFlags = HideFlags.DontSave;
                component.runtimeAnimatorController = animatorController;
            }
            Dictionary <Transform, bool> modelBones = AvatarSetupTool.GetModelBones(this.m_GameObject.transform, true, null);

            AvatarSetupTool.BoneWrapper[] humanBones = AvatarSetupTool.GetHumanBones(base.serializedObject, modelBones);
            this.m_ModelBones      = AvatarSetupTool.GetModelBones(this.m_GameObject.transform, false, humanBones);
            Selection.activeObject = this.m_GameObject;
            UnityEngine.Object[] array = Resources.FindObjectsOfTypeAll(typeof(SceneHierarchyWindow));
            for (int i = 0; i < array.Length; i++)
            {
                SceneHierarchyWindow sceneHierarchyWindow = (SceneHierarchyWindow)array[i];
                sceneHierarchyWindow.SetExpandedRecursive(this.m_GameObject.GetInstanceID(), true);
            }
            this.CreateEditor();
            this.m_EditMode    = AvatarEditor.EditMode.Editing;
            this.m_SceneStates = new List <AvatarEditor.SceneStateCache>();
            foreach (SceneView sceneView in SceneView.sceneViews)
            {
                this.m_SceneStates.Add(new AvatarEditor.SceneStateCache
                {
                    state = new SceneView.SceneViewState(sceneView.m_SceneViewState),
                    view  = sceneView
                });
                sceneView.m_SceneViewState.showFlares         = false;
                sceneView.m_SceneViewState.showMaterialUpdate = false;
                sceneView.m_SceneViewState.showFog            = false;
                sceneView.m_SceneViewState.showSkybox         = false;
                sceneView.m_SceneViewState.showImageEffects   = false;
                sceneView.FrameSelected();
            }
        }
Ejemplo n.º 8
0
 protected void Init()
 {
     if (base.gameObject == null)
     {
         return;
     }
     if (this.m_Bones == null)
     {
         this.m_Bones = AvatarSetupTool.GetHumanBones(base.serializedObject, base.modelBones);
     }
     this.ValidateMapping();
     if (this.m_CurrentTransformEditor != null)
     {
         UnityEngine.Object.DestroyImmediate(this.m_CurrentTransformEditor);
         this.m_CurrentTransformEditor = null;
     }
     this.m_CurrentTransformEditorFoldout = true;
     this.m_HasSkinnedMesh = (base.gameObject.GetComponentInChildren <SkinnedMeshRenderer>() != null);
     this.InitPose();
     SceneView.RepaintAll();
 }
Ejemplo n.º 9
0
        internal void SwitchToEditMode()
        {
            // Lock inspector
            ChangeInspectorLock(true);

            string assetPath = AssetDatabase.GetAssetPath(target);
            AvatarConfigurationStage stage = AvatarConfigurationStage.CreateStage(assetPath, this);

            StageUtility.GoToStage(stage, true);

            m_EditMode = EditMode.Starting;

            // Instantiate character
            m_GameObject = stage.gameObject;
            if (serializedAssetImporter.FindProperty("m_OptimizeGameObjects").boolValue)
            {
                AnimatorUtility.DeoptimizeTransformHierarchy(m_GameObject);
            }

            SerializedProperty humanBoneArray = serializedAssetImporter.FindProperty("m_HumanDescription.m_Human");

            // First get all available modelBones
            Dictionary <Transform, bool> modelBones = AvatarSetupTool.GetModelBones(m_GameObject.transform, true, null);

            AvatarSetupTool.BoneWrapper[] humanBones = AvatarSetupTool.GetHumanBones(humanBoneArray, modelBones);

            m_ModelBones = AvatarSetupTool.GetModelBones(m_GameObject.transform, false, humanBones);

            // Unfold all nodes in hierarchy
            // TODO@MECANIM: Only expand actual bones
            foreach (SceneHierarchyWindow shw in Resources.FindObjectsOfTypeAll(typeof(SceneHierarchyWindow)))
            {
                shw.SetExpandedRecursive(m_GameObject.GetInstanceID(), true);
            }

            CreateEditor();

            m_EditMode = EditMode.Editing;
        }
Ejemplo n.º 10
0
 protected void Init()
 {
     if ((UnityEngine.Object) this.gameObject == (UnityEngine.Object)null)
     {
         return;
     }
     this.m_IsBiped = AvatarBipedMapper.IsBiped(this.gameObject.transform, (List <string>)null);
     if (this.m_Bones == null)
     {
         this.m_Bones = AvatarSetupTool.GetHumanBones(this.serializedObject, this.modelBones);
     }
     this.ValidateMapping();
     if ((UnityEngine.Object) this.m_CurrentTransformEditor != (UnityEngine.Object)null)
     {
         UnityEngine.Object.DestroyImmediate((UnityEngine.Object) this.m_CurrentTransformEditor);
         this.m_CurrentTransformEditor = (Editor)null;
     }
     this.m_CurrentTransformEditorFoldout = true;
     this.m_HasSkinnedMesh = (UnityEngine.Object) this.gameObject.GetComponentInChildren <SkinnedMeshRenderer>() != (UnityEngine.Object)null;
     this.InitPose();
     SceneView.RepaintAll();
 }
Ejemplo n.º 11
0
        internal void Initialize()
        {
            // Handle human bones
            if (m_Bones == null)
            {
                m_Bones = AvatarSetupTool.GetHumanBones(serializedObject, modelBones);
            }

            m_FocusedMuscle = -1;

            m_MuscleBodyGroupToggle = new bool[m_Muscles.Length];
            for (int i = 0; i < m_Muscles.Length; i++)
            {
                m_MuscleBodyGroupToggle[i] = false;
            }

            m_MuscleName = HumanTrait.MuscleName;
            for (int i = 0; i < m_MuscleName.Length; i++)
            {
                if (m_MuscleName[i].StartsWith("Right"))
                {
                    m_MuscleName[i] = m_MuscleName[i].Substring(5).Trim();
                }
                if (m_MuscleName[i].StartsWith("Left"))
                {
                    m_MuscleName[i] = m_MuscleName[i].Substring(4).Trim();
                }
            }
            m_MuscleCount = HumanTrait.MuscleCount;

            m_MuscleToggle = new bool[m_MuscleCount];
            m_MuscleValue  = new float[m_MuscleCount];
            m_MuscleMin    = new SerializedProperty[m_MuscleCount];
            m_MuscleMax    = new SerializedProperty[m_MuscleCount];

            m_MuscleMinEdit = new float[m_MuscleCount];
            m_MuscleMaxEdit = new float[m_MuscleCount];

            for (int i = 0; i < m_MuscleCount; i++)
            {
                m_MuscleToggle[i] = false;
                m_MuscleValue[i]  = 0;
                m_MuscleMin[i]    = null;
                m_MuscleMin[i]    = null;
            }

            m_Modified = new SerializedProperty[m_Bones.Length];
            for (int i = 0; i < m_Bones.Length; i++)
            {
                m_Modified[i] = null;
            }

            InitializeProperties();
            ResetValuesFromProperties();

            m_MuscleMasterValue = new float[m_MasterMuscle.Length];
            for (int i = 0; i < m_MasterMuscle.Length; i++)
            {
                m_MuscleMasterValue[i] = 0;
            }
        }