Esempio n. 1
0
    override public void OnInspectorGUI()
    {
        serializedObject.Update();

        EditorGUI.BeginChangeCheck();

        EditorGUILayout.PropertyField(creature_asset);
        EditorGUILayout.PropertyField(local_time_scale);
        EditorGUILayout.PropertyField(region_offsets_z);
        EditorGUILayout.PropertyField(counter_clockwise);

        bool did_change = EditorGUI.EndChangeCheck();

        // new assignment
        if ((creature_asset.objectReferenceValue != null) && did_change)
        {
            UpdateData();
        }

        if (creature_asset.objectReferenceValue != null)
        {
            CreatureAsset cur_asset = (CreatureAsset)creature_asset.objectReferenceValue;
            // asset changed
            if (cur_asset.GetIsDirty())
            {
                UpdateData();
                cur_asset.SetIsDirty(false);
            }

            // animations
            if (cur_asset.creature_manager != null)
            {
                string[] animation_names = new string[cur_asset.creature_manager.animations.Keys.Count];
                int      i = 0;
                foreach (string cur_name in cur_asset.creature_manager.animations.Keys)
                {
                    animation_names[i] = cur_name;
                    i++;
                }

                animation_choice_index.intValue = EditorGUILayout.Popup("Animation:",
                                                                        animation_choice_index.intValue, animation_names);

                should_loop.boolValue = EditorGUILayout.Toggle("Loop", should_loop.boolValue);

                if (!Application.isPlaying)
                {
                    updateTargetAnimation();
                }

                serializedObject.ApplyModifiedProperties();
            }
        }
    }
Esempio n. 2
0
    public virtual void LateUpdate()
    {
        if (creature_manager != null)
        {
            doSwapMesh();

            if (creature_asset.GetIsDirty() || vertices == null)
            {
                CreateRenderingData();
                creature_asset.SetIsDirty(false);
            }

            UpdateTime();
            UpdateRenderingData();

            meshFilter.sharedMesh = active_mesh;
        }
    }
    /*
     * public List<UIVertex> ConvertMesh()
     * {
     *  Vector3[] vertices = active_mesh.vertices;
     *  int[] triangles = active_mesh.triangles;
     *  Vector3[] normals = active_mesh.normals;
     *  Vector2[] uv = active_mesh.uv;
     *
     *  List<UIVertex> vertexList = new List<UIVertex>(triangles.Length);
     *
     *  UIVertex vertex;
     *  for (int i = 0; i < triangles.Length; i++)
     *  {
     *      vertex = new UIVertex();
     *      int triangle = triangles[i];
     *
     *      vertex.position = (vertices[triangle] - active_mesh.bounds.center);
     *      vertex.uv0 = uv[triangle];
     *      vertex.normal = normals[triangle];
     *
     *      vertexList.Add(vertex);
     *
     *      if (i % 3 == 0)
     *          vertexList.Add(vertex);
     *  }
     *
     *  return vertexList;
     * }
     */

    // Update is called once per frame
    void LateUpdate()
    {
        if (creature_manager != null)
        {
            doSwapMesh();

            if (creature_asset.GetIsDirty() || vertices == null)
            {
                CreateRenderingData();
                creature_asset.SetIsDirty(false);
            }

            UpdateTime();
            UpdateRenderingData();
        }

        var renderer = GetComponent <CanvasRenderer>();

        renderer.SetMesh(active_mesh);
        renderer.materialCount = 1;
        renderer.SetMaterial(material, 0);
    }